Chapter 2 Introduction to R
This lecture introduces you to basic operations when you first start using R such as navigation, the object-oriented framework, loading a package, and creating some data vectors.
2.2 Commenting Code
Most computer languages have a special character that is used to “comment out” lines so that it is not run by the program. It is used for two important purposes. First, we can add text to document our functions and it will not interfere with the program. And two, we can use it to run a program while ignoring some of the code, often for debugging purposes.
The # hash tag is used for comments in R.
##==============================================
##
## Here is some documentation for this script
##
##==============================================
x <- 1:10
sum( x )
## [1] 55
2.3 Help
You will use the help functions frequently to figure out what arguments and values are needed for specific functions. Because R is very customizable, you will find that many functions have several or dozens of arguments, and it is difficult to remember the correct syntax and values. But don’t worry, to look them up all you need is the function name and a call for help:
help( dotchart ) # opens an external helpfile
If you just need to remind yourself which arguments are defined in a function, you can use the args() command:
## function (x, labels = NULL, groups = NULL, gdata = NULL, cex = par("cex"),
## pt.cex = cex, pch = 21, gpch = 21, bg = par("bg"), color = par("fg"),
## gcolor = par("fg"), lcolor = "gray", xlim = range(x[is.finite(x)]),
## main = NULL, xlab = NULL, ylab = NULL, ...)
## NULL
If you can’t recall a function name, you can list all of the functions from a specific package as follows:
help( package=“stats” ) # lists all functions in stats package
2.4 Install Programs (packages)
When you open R by default it will launch a core set of programs, called “packages” in R speak, that are use for most data operations. To see which packages are currently active use the search() function.

The real magic for R comes from the over 7,000 contributed packages available on the CRAN: https://cran.r-project.org/web/views/
A package consists of custom functions and datasets that are generated by users. They are packaged together so that they can be shared with others. A package also includes documentation that describes each function, defines all of the arguments, and documents any datasets that are included.
If you know a package name, it is easy to install. In R Studio you can select Tools -> Install Packages and a list of available packages will be generated. But it is easier to use the install.packages() command. We will use the Lahman Package in this course, so let’s install that now.
Description This package provides the tables from Sean Lahman’s Baseball Database as a set of R data.frames. It uses the data on pitching, hitting and fielding performance and other tables from 1871 through 2013, as recorded in the 2014 version of the database.
See the documentation here: https://cran.r-project.org/web/packages/Lahman/Lahman.pdf
You will be asked to select a “mirror”. In R speak this just means the server from which you will download the package (choose anything nearby). R is a community of developers and universities that create code and maintain the infrastructure. A couple of dozen universities around the world host servers that contain copies of the R packages so that they can be easily accessed everywhere.
If the package is successfully installed you will get a message similar to this:
package ‘Lahman’ successfully unpacked and MD5 sums checked
Once a new program is installed you can now open (“load” in R speak) the package using the library() command:
If you now type search() you can see that Lahman has been added to the list of active programs. We can now access all of the functions and data that are available in the Lahman package.
2.5 Accessing Built-In Datasets in R
One nice feature of R is that is comes with a bunch of built-in datasets that have been contributed by users are are loaded automatically. You can see the list of available datasets by typing:
This will list all of the default datasets in core R packages. If you want to see all of the datasets available in installed packages as well use:
2.5.1 Basic Data Operations
Let’s ignore the underlying data structure right now and look at some ways that we might interact with data.
We will use the USArrests dataset available in the core files.
To access the data we need to load it into working memory. Anything that is active in R will be listed in the environment, which you can check using the ls() command. We will load the dataset using the data() command.
## character(0)
## [1] "USArrests"
Now that we have loaded a dataset, we can start to access the variables and analyze relationships. Let’s get to know our dataset.
## [1] "Murder" "Assault" "UrbanPop" "Rape"
## [1] "Alabama" "Alaska" "Arizona" "Arkansas"
## [5] "California" "Colorado" "Connecticut" "Delaware"
## [9] "Florida" "Georgia" "Hawaii" "Idaho"
## [13] "Illinois" "Indiana" "Iowa" "Kansas"
## [17] "Kentucky" "Louisiana" "Maine" "Maryland"
## [21] "Massachusetts" "Michigan" "Minnesota" "Mississippi"
## [25] "Missouri" "Montana" "Nebraska" "Nevada"
## [29] "New Hampshire" "New Jersey" "New Mexico" "New York"
## [33] "North Carolina" "North Dakota" "Ohio" "Oklahoma"
## [37] "Oregon" "Pennsylvania" "Rhode Island" "South Carolina"
## [41] "South Dakota" "Tennessee" "Texas" "Utah"
## [45] "Vermont" "Virginia" "Washington" "West Virginia"
## [49] "Wisconsin" "Wyoming"
## [1] 50
## [1] 50 4
## Murder Assault UrbanPop Rape
## Min. : 0.800 Min. : 45.0 Min. :32.00 Min. : 7.30
## 1st Qu.: 4.075 1st Qu.:109.0 1st Qu.:54.50 1st Qu.:15.07
## Median : 7.250 Median :159.0 Median :66.00 Median :20.10
## Mean : 7.788 Mean :170.8 Mean :65.54 Mean :21.23
## 3rd Qu.:11.250 3rd Qu.:249.0 3rd Qu.:77.75 3rd Qu.:26.18
## Max. :17.400 Max. :337.0 Max. :91.00 Max. :46.00
We can see that the dataset consists of four variables: Murder, Assault, UrbanPop, and Rape. We also see that our unit of analysis is the state. But where does the data come from, and how are these variables measured?
To see the documentation for a specific dataset you will need to use the help() function:
We get valuable information about the source and metrics:
Description This data set contains statistics, in arrests per 100,000 residents for assault, murder, and rape in each of the 50 US states in 1973. Also given is the percent of the population living in urban areas.
Format A data frame with 50 observations on 4 variables.
[,1] Murder numeric Murder arrests (per 100,000) [,2] Assault numeric Assault arrests (per 100,000) [,3] UrbanPop numeric Percent urban population [,4] Rape numeric Rape arrests (per 100,000)
To access a specific variable inside of a dataset, you will use the $ operator between the dataset name and the variable name:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.800 4.075 7.250 7.788 11.250 17.400
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 45.0 109.0 159.0 170.8 249.0 337.0
2.5.2 Using the Lahman Data
Let’s take a look at some of the data available in the Lahman package.
data( package = "Lahman" )
# Data sets in package ‘Lahman’:
#
# AllstarFull AllstarFull table
# Appearances Appearances table
# AwardsManagers AwardsManagers table
# AwardsPlayers AwardsPlayers table
# AwardsShareManagers AwardsShareManagers table
# AwardsSharePlayers AwardsSharePlayers table
# Batting Batting table
# BattingPost BattingPost table
# CollegePlaying CollegePlaying table
# Fielding Fielding table
# FieldingOF FieldingOF table
# FieldingPost FieldingPost data
# HallOfFame Hall of Fame Voting Data
# LahmanData Lahman Datasets
# Managers Managers table
# ManagersHalf ManagersHalf table
# Master Master table
# Pitching Pitching table
# PitchingPost PitchingPost table
# Salaries Salaries table
# Schools Schools table
# SeriesPost SeriesPost table
# Teams Teams table
# TeamsFranchises TeamFranchises table
# TeamsHalf TeamsHalf table
# battingLabels Variable Labels
# fieldingLabels Variable Labels
# pitchingLabels Variable Labels
We see that we have lots of datasets to choose from here. I will use the Master dataset, which is a list of all of the Major League Baseball players over the past century, and their personal information.
## [1] "playerID" "birthYear" "birthMonth" "birthDay"
## [5] "birthCountry" "birthState" "birthCity" "deathYear"
## [9] "deathMonth" "deathDay" "deathCountry" "deathState"
## [13] "deathCity" "nameFirst" "nameLast" "nameGiven"
## [17] "weight" "height" "bats" "throws"
## [21] "debut" "finalGame" "retroID" "bbrefID"
## [25] "deathDate" "birthDate"
## [1] 19105
## playerID birthYear birthMonth birthDay
## Length:19105 Min. :1820 Min. : 1.000 Min. : 1.00
## Class :character 1st Qu.:1895 1st Qu.: 4.000 1st Qu.: 8.00
## Mode :character Median :1937 Median : 7.000 Median :16.00
## Mean :1931 Mean : 6.629 Mean :15.61
## 3rd Qu.:1969 3rd Qu.:10.000 3rd Qu.:23.00
## Max. :1996 Max. :12.000 Max. :31.00
## NA's :132 NA's :302 NA's :449
## birthCountry birthState birthCity deathYear
## Length:19105 Length:19105 Length:19105 Min. :1872
## Class :character Class :character Class :character 1st Qu.:1942
## Mode :character Mode :character Mode :character Median :1967
## Mean :1964
## 3rd Qu.:1990
## Max. :2017
## NA's :9664
## deathMonth deathDay deathCountry deathState
## Min. : 1.000 Min. : 1.00 Length:19105 Length:19105
## 1st Qu.: 3.000 1st Qu.: 8.00 Class :character Class :character
## Median : 6.000 Median :15.00 Mode :character Mode :character
## Mean : 6.484 Mean :15.57
## 3rd Qu.:10.000 3rd Qu.:23.00
## Max. :12.000 Max. :31.00
## NA's :9665 NA's :9666
## deathCity nameFirst nameLast
## Length:19105 Length:19105 Length:19105
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
##
## nameGiven weight height bats
## Length:19105 Min. : 65.0 Min. :43.00 B : 1175
## Class :character 1st Qu.:170.0 1st Qu.:71.00 L : 4957
## Mode :character Median :185.0 Median :72.00 R :11788
## Mean :186.4 Mean :72.27 NA's: 1185
## 3rd Qu.:200.0 3rd Qu.:74.00
## Max. :320.0 Max. :83.00
## NA's :854 NA's :785
## throws debut finalGame retroID
## L : 3653 Length:19105 Length:19105 Length:19105
## R :14472 Class :character Class :character Class :character
## S : 1 Mode :character Mode :character Mode :character
## NA's: 979
##
##
##
## bbrefID deathDate birthDate
## Length:19105 Min. :1872-03-17 Min. :1820-04-17
## Class :character 1st Qu.:1942-06-05 1st Qu.:1896-11-21
## Mode :character Median :1967-03-06 Median :1939-01-01
## Mean :1964-10-11 Mean :1933-03-08
## 3rd Qu.:1990-09-22 3rd Qu.:1970-04-02
## Max. :2017-02-19 Max. :1996-08-12
## NA's :9666 NA's :449
We can use help(Master) to get information about the dataset, including a data dictionary.
2.6 MASTER TABLE
Description
Master table - Player names, DOB, and biographical info. This file is to be used to get details about players listed in the Batting, Pitching, and other files where players are identified only by playerID.
Usage
data(Master)
Format
A data frame with 19105 observations on the following 26 variables.
- playerID: A unique code asssigned to each player. The playerID links the data in this file with records on players in the other files.
- birthYear: Year player was born
- birthMonth: Month player was born
- birthDay: Day player was born
- birthCountry: Country where player was born
- birthState: State where player was born
- birthCity: City where player was born
- deathYear: Year player died
- deathMonth: Month player died
- deathDay: Day player died
- deathCountry: Country where player died
- deathState: State where player died
- deathCity: City where player died
- nameFirst: Player’s first name
- nameLast: Player’s last name
- nameGiven: Player’s given name (typically first and middle)
- weight: Player’s weight in pounds
- height: Player’s height in inches
- bats: a factor: Player’s batting hand (left (L), right (R), or both (B))
- throws: a factor: Player’s throwing hand (left(L) or right(R))
- debut: Date that player made first major league appearance
- finalGame: Date that player made first major league appearance (blank if still active)
- retroID: ID used by retrosheet, http://www.retrosheet.org/
- bbrefID: ID used by Baseball Reference website, http://www.baseball-reference.com/
- birthDate: Player’s birthdate, in as.Date format
- deathDate: Player’s deathdate, in as.Date format
Details
debut, finalGame were converted from character strings with as.Date.
Source
Lahman, S. (2016) Lahman’s Baseball Database, 1871-2015, 2015 version, http://www.seanlahman.com/baseball-archive/statistics/
2.6.1 Example Analysis
Perhaps I am curious about some of the data. I see that we have information on the birth month of professional baseball players. If you have read Malcolm Gladwell’s book Outliers you know there is an interesting cumulative advantage phenomenon that can occur with atheletes as they are young. If you are born near the end of the cutoff, you are on average six months older than other players in your league, and therefore slightly larger physically and more coordinated on average. Six months does not sound like much, but the slight size and coordination advantage means more playing time, which also improves skill. Over time, this small difference accumulates so that those lucky enough to be born near the cutoff become the best players.
Gladwell looked at studies of hockey. Do we see this in baseball?
##
## 1 2 3 4 5 6 7 8 9 10 11 12
## 1631 1439 1528 1450 1449 1366 1503 1831 1661 1759 1620 1566


| Class and Description |
|---|
| AbstractAntJavaBasedPlayMojo
Base class for Ant Java task using mojos.
|
| AbstractAntJavaBasedPlayMojo.JavaRunnable
Internal runnable wrapper for Ant Java task.
|
| AbstractArchivingMojo
Base class for Play! packaging mojos.
|
| AbstractDependencyProcessingPlayMojo
Base class for Play! dependency processing mojos.
|
| AbstractPlayDistMojo
Base class for Play! distribution packaging mojos.
|
| AbstractPlayMojo
Base class for all Play! mojos.
|
| AbstractPlayRunMojo
Base class for Play! server synchronously starting ("run" and "test") mojos.
|
| AbstractPlayServerMojo
Base class for Play! server mojos.
|
| AbstractPlayStartServerMojo
Base class for Play! server asynchronously starting ("start" and "start-server") mojos.
|
| AbstractPlayStopServerMojo
Base class for Play! server stopping ("stop" and "stop-server") mojos.
|
| AbstractPlayWarMojo
Base class for Play! war packaging mojos.
|
| ConfigurationParser
Play! configuration file ("conf/application.conf") reader.
|
| PidFileDeleter
Shutdown hook responsible for deleting "server.pid" file.
|
Copyright © 2010–2016. All rights reserved.


This is a mob movie parody that actually delivers more laughs per minute than most straight comedies. "Analyze This" is a pleasurable movie experience, and a real hoot; a grandly hysterical comedy that pokes fun at all the expected mob cliches, and is guaranteed to offend everyone (including some mobsters).
Billy Crystal stars as a psychiatrist, Ben Sobel, who offers therapy to divorcees and couples. One day, he has an accidental fender bender with a mobster's car - Crystal offers his business card in case the guy changes his mind about filing a suit. "Forget about it. I said forget about it," snarls Jelly, the mobster (Joe Viterelli). Of course, Jelly does not forget when he notices that his boss, Paul Vitti (Robert De Niro), is suffering from headaches and is not performing up to par on the job. After all, he's Don Vitti, one of the major crime bosses in New York City.
Jelly suggests that Paul visit the psychiatrist. Once he's there, the Don intimidates Ben by telling him that he didn't see his face in the papers and doesn't know him. Ben agrees but his life turns upside down when he starts to counsel Paul. Analyze This steals ever narrative device you can imagine from classic mob films like "The Godfather," "GoodFellas," and "Casino." There's the voice-over delivered by De Niro, the typical mob kisses and hugs, shoot-outs in restaurants, several comical "whackings", and Tony Bennett songs playing all the while. All of this is done with style and grace.
Just as graceful and ingratiating as ever is De Niro, a proven potent comic force ("We're No Angels" and "The King of Comedy") who steals every scene he's in. He mugs mercilessly and whimpers incessantly - there's one touching scene where he sobs over his father's death. De Niro is as fit, trimmed, and handsome as he was in "Casino" - no wonder he originally wanted Martin Scorsese to direct.
Billy Crystal has been on the sentimental bandwagon ever since "City Slickers," but here he learns a vital lesson: less is more. With a bespectacled look and a curly beard, Crystal lightens up the screen with his pleasing charm and nuanced timing. He learned the great trick - to pause with a glance before delivering the punch line. Here he is pitch-perfect in one of his most memorable screen roles to date. Crystal's last scene as he mimics a swaggering, posturing Italian mafioso will leave you incredulous with laughter.
Unfortunately, there is one major flaw: the casting of Lisa Kudrow as Laura, Ben's fiancee who keeps getting interrupted at every wedding opportunity by Paul's henchmen. Kudrow does well, but isn't given enough to do. This is a real shame, considering there could have been some winning byplay between De Niro and Kudrow, but the three or four writers listed seemed to have nixed the idea of supplying more than one scene between them. Still, there are enough comic zingers, one-liners, and subtle humor to compensate. Besides, you have the prim Chazz Palminteri as the rival mob boss, Primo Sindrone.
"Analyze This" may not be great shakes or worthy of being placed in the annals of great comedy classics, but it is as satisfying and entertaining as any other comedy I've seen as of late. And that's that.
For more reviews, check out JERRY AT THE MOVIES at http://buffs.moviething.com/buffs/faust/
E-mail me with any questions, concerns or complaints at<EMAIL_ADDRESS>or at<EMAIL_ADDRESS>The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


We added a blog_email item to config.py and changed blog_author to just the author’s name. Examples:
py[“blog_email”] =<EMAIL_ADDRESS>py[“blog_author”] = “Joe Man”
We no longer adjust blog_title from what you set in config.py. Now we have a blog_title_with_path variable which is in the data dict which is the blog_title with the path information. People who want the title of their blog to be the title and not include the path should use $blog_title. Folks who want the old behavior where the path was appended to the title should use $blog_title_with_path .
We now support WSGI, mod_python, and Twisted in addition to CGI.
Upped our Python requirement to Python 2.2. If you have an earlier version than that, you won’t be able to use PyBlosxom 1.2.
Changed defaultFlavour to default_flavour. This property allows you to specify the flavour to use by default if the URI doesn’t specify one. It default to html.
We moved the main PyBlosxom site to http://pyblosxom.sourceforge.net/ . There’s a “powered by pyblosxom” image at http://pyblosxom.sourceforge.net/images/pb_pyblosxom.gif
You should adjust your templates accordingly.
We now have a Request and a Response object. See API documentation for more details.
Don’t use os.environ directly—use the http dict. For example, this is bad:
path_info = os.environ["HTTP_PATHINFO"]
This is what you should be doing:
http = request.getHttp()
path_info = http["HTTP_PATHINFO"]
If you use os.environ directly, it’s likely your plugin won’t work with non-CGI installations of PyBlosxom.
We added __iter__, read, readline, readlines, seek, and tell to the Request object. All of them access the input stream. You should not use sys.stdin directly.
Usage:
data = request.read()
data_part = request.read(1024)
one_line = request.readline()
lines = request.readlines()
The output stream should be accessed through the PyBlosxom Response object. The following methods are implemented in the Response object: __iter__, close, flush, read, readline, readlines, seek, tell, write, writelines, setStatus, and addHeader. You should not use sys.stdout directly. See the API for more details.
Usage:
response = request.getResponse()
response.addHeader('Status', '200 Ok')
response.addHeader('Content-type', 'text/html')
response.write("Hello World")
response.writelines(["list", "of", "data"])
Instead of doing:
form = request.getHttp()["form"]
you can now do:
form = request.getForm()
Plugins should not be importing the config module and looking at the py dict directly. You should instead use the Request getConfiguration() method to get the config py dict.


Edit user profile
Profile
Back to profile
Change password
Edit user profile
First name
*
Last name
*
E-mail
*


DONNIE BRASCO A film review by James Berardinelli Copyright 1997 James Berardinelli
Rating (0 to 10): 7.5 Alternative Scale: *** out of ****
United States, 1997 U.S. Release Date: 2/28/97 (wide) Running Length: 2:06 MPAA Classification: R (Profanity, violence, mature themes) Theatrical Aspect Ratio: 2.35:1
Cast: Al Pacino, Johnny Depp, Michael Madsen, Bruno Kirby, James Russo, Anne Heche Director: Mike Newell Producers: Mark Johnson, Barry Levinson, Louis DiGiaimo, Gail Mutrux Screenplay: Paul Attanasio based on the book DONNIE BRASCO: MY UNDERCOVER LIFE IN THE MAFIA by Joseph Pistone with Richard Woodley Cinematography: Peter Sova Music: Patrick Doyle U.S. Distributor: TriStar Pictures
Al Pacino in a Mafia movie feels as natural as peanut butter with jelly. Mike Newell, the director of such popular British comedies as ENCHANTED APRIL and FOUR WEDDINGS AND A FUNERAL, is another matter altogether. When you think of a director for New York-based, mob- related motion pictures, names like Brian De Palma, Francis Ford Coppola, and Martin Scorsese leap to mind. Unexpectedly, however, Newell slides effortlessly into the genre, fashioning a motion picture that is simultaneously like and unlike traditional wiseguy films.
DONNIE BRASCO is based on the true story of FBI agent Joe Pistone (Johnny Depp), who went undercover and infiltrated the New York City mob during the late 1970s. Joe, who went by the name of "Donnie Brasco", played his role so effectively that he rose to extraordinary heights within the organization, holding a place alongside his mentor, Lefty (Al Pacino), in the inner circle of boss Sonny Black (Michael Madsen). But, the more time he spent with members of the Mafia, the more like them he became. And, after a while, Joe could no longer tell where his true loyalties lay: to his wife (Anne Heche), family, and government, or to the wiseguys who had adopted him into their exclusive club and lifestyle.
Perhaps the most impressive thing that Newell has done with DONNIE BRASCO is to cull an atypically low-key and introspective performance from Al Pacino, an actor known for manic, scenery-chewing efforts. Lefty is a world-weary hit man with 26 kills under his belt and little to show for it. "30 years, I'm bustin' my hump... for what?" he laments when he is passed over for promotion within the mob. His dream is to buy a boat and sail far away from civilization, but he doesn't have the money or the gumption to chase that golden fantasy. Pacino presents Lefty as a tragic, and at times pathetic, character who earns our pity and understanding, if not our sympathy. There's little hint of Michael Corleone here -- Lefty is an impotent doubter who knows how it will all end.
While not on Pacino's level, Johnny Depp is competent as the title character, a man who loses his perspective as he becomes seduced by the mobster's lifestyle. Depp lets us see the conflict within Joe as his friendship with Lefty grows into something real and as his wife and children become little more than distant images. Near the beginning of DONNIE BRASCO, Joe attempts to prevent a hit; by the end, he comes perilously close to taking part. If there are times when Joe's character doesn't seem whole, the blame lies more with the script's failure to provide the needed background or motivation than with Depp's performance.
Although DONNIE BRASCO is set against a backdrop of crime and violence (and Newell doesn't shrink from showing these elements, although he's more restrained than a Scorsese might be), it, like many better gangster films, is really about family and relationships. Lefty and Joe have a surrogate father/son bond that gradually supersedes all other attachments in either of their lives. As Lefty says at one point, "[The mob] is my family, even more than my [real] family." It's because DONNIE BRASCO focuses on characters and relationships that it makes for compelling viewing.
Although the film contains many of the usual mob cliches and stock secondary characters, these don't detract much from the viewer's enjoyment. Truth may be stranger than fiction, but many "based on real events" motion pictures aren't nearly as well-executed or involving as DONNIE BRASCO. The film has all the right little touches to be believable, such as Lefty's fascinating lesson to his protege about how to dress, act, and speak to be respected in wiseguy circles. DONNIE BRASCO takes us into a world that the movies frequently open to us, but somehow this trip seems more real and less glamorized than most. The result is a satisfying film going experience.
- James Berardinelli e-mail<EMAIL_ADDRESS>ReelViews web site: http://www.cybernex.net/~berardin
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


The tuple/remove.h
header defines an algorithm that removes an element from a tuple.
#include <chaos/preprocessor/tuple/remove.h>
The CHAOS_PP_TUPLE_REMOVE
macro removes the element at the index specified by its first argument from its second argument.
CHAOS_PP_TUPLE_REMOVE
(i, tuple)
The zero-based index of the element to be removed.
Valid values range from 0
to
- 1.
CHAOS_PP_TUPLE_SIZE
(tuple)
The tuple from which an element is to be removed.
This macro expands to a tuple containing all of the elements of tuple except the i-th element.
The efficiency of the algorithm's use of the recursion backend can be described in terms of the number of recursion steps required to complete the algorithm. The asymptotic upper and lower bounds are Θ, where n is i.
This macro operates on the nil tuple representation used by the core tuple operations defined in <chaos/preprocessor/tuple/core.h>
.
Specifically, ()
is a one-element tuple, not a zero-element tuple.
This macro uses bypass semantics.
If bypass semantics are already in effect, CHAOS_PP_TUPLE_REMOVE_BYPASS
must be used instead.
#include<chaos/preprocessor/config.h>
#include<chaos/preprocessor/tuple/remove.h>
#ifCHAOS_PP_VARIADICS
CHAOS_PP_TUPLE_REMOVE
(0, (a, b, c)) // (b, c)CHAOS_PP_TUPLE_REMOVE
(2, (a, b, c)) // (a, b)CHAOS_PP_TUPLE_REMOVE
(0, (a)) // #endif
The CHAOS_PP_TUPLE_REMOVE_ID
macro indirectly expands to CHAOS_PP_TUPLE_REMOVE
.
CHAOS_PP_TUPLE_REMOVE_ID
()
This macro effectively allows CHAOS_PP_TUPLE_REMOVE
to pass through itself without becoming disabled.
The CHAOS_PP_TUPLE_REMOVE_
macro expands to a λ expression representing CHAOS_PP_TUPLE_REMOVE
.
CHAOS_PP_TUPLE_REMOVE_
This macro is a shorthand form of the following λ binding:
The CHAOS_PP_TUPLE_REMOVE_BYPASS
macro behaves identically to CHAOS_PP_TUPLE_REMOVE
except that it is parametized by the bypass recursion state.
CHAOS_PP_TUPLE_REMOVE_BYPASS
(s, i, tuple)
The current bypass recursion state.
The zero-based index of the element to be removed.
Valid values range from 0
to
- 1.
CHAOS_PP_TUPLE_SIZE
(tuple)
The tuple from which an element is to be removed.
If bypass semantics are already in effect, this macro must be used instead of CHAOS_PP_TUPLE_REMOVE
.
The CHAOS_PP_TUPLE_REMOVE_BYPASS_ID
macro indirectly expands to CHAOS_PP_TUPLE_REMOVE_BYPASS
.
CHAOS_PP_TUPLE_REMOVE_BYPASS_ID
()
This macro effectively allows CHAOS_PP_TUPLE_REMOVE_BYPASS
to pass through itself without becoming disabled.
The CHAOS_PP_TUPLE_REMOVE_BYPASS_
macro expands to a λ expression representing CHAOS_PP_TUPLE_REMOVE_BYPASS
.
CHAOS_PP_TUPLE_REMOVE_BYPASS_
This macro is a shorthand form of the following λ binding:


Pingr - Tell search engines about your sitemap changes
Pingr is a super-simple gem built for the blogit project.
Installation
Add this line to your application's Gemfile:
gem 'pingr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pingr
Usage
From within your app (most likely a controller):
def ping_sitemaps
Pingr::Request.new(my_sitemap_url) # This will ping Google and Bing
end
A good way to do this would be using Rails's after filters:
class PostsController < ActionController::Base
after_filter :ping_sitemaps, only: [:create, :update, :destroy]
# ...
private
def ping_sitemaps
Pingr::Request.new(my_sitemap_url)
end
end
You can view the supported search engines and add your own by viewing the code in this directory:
https://github.com/KatanaCode/pingr/tree/master/lib/pingr/search_engines
Modes
By default, Pingr is set to :test mode, meaning it won't actually perform the requests. If the Rails environment is :production then the mode is set to :live which will perform requests to the search engines.
You can change this by manually setting Pingr.mode
# in config/initializers/pingr.rb
Pingr.mode = :live if Rails.env =~ /staging|production/
NOTE: Search engines may penalise or black-list you if you perform too many requests - they recommend no more than one per hour.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
About Katana
Katana are web and mobile app developers in Edinburgh, Scotland.


Tasks that include MPU support require even more parameters to create than those that don't. Passing each parameter to xTaskCreateRestricted() individually would be unwieldy so instead the structure TaskParameters_t is used to allow the parameters to be configured statically at compile time. The structure is defined in task.h as:
typedef struct xTASK_PARAMETERS { TaskFunction_t pvTaskCode; const signed char * const pcName; unsigned short usStackDepth; void *pvParameters; UBaseType_t uxPriority; portSTACK_TYPE *puxStackBuffer; MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; } TaskParameters_t; ....where MemoryRegion_t is defined as: typedef struct xMEMORY_REGION { void *pvBaseAddress; unsigned long ulLengthInBytes; unsigned long ulParameters; } MemoryRegion_t;
Example usage (please refer to the FreeRTOS-MPU demo applications for a much more complete and comprehensive example): /* Declare the stack
that will be used by the task. The stack
alignment must match its size and be a power of
2, so if 128 words are reserved for the stack
then it must be aligned to ( 128 * 4 ) bytes.
This example used GCC syntax. */ static
portSTACK_TYPE xTaskStack[ 128 ]
__attribute__((aligned(128*4))); /* Declare an array that will be
accessed by the task. The task should only be
able to read from the array, and not write to it.
*/ char cReadOnlyArray[ 512 ]
__attribute__((aligned(512))); /* Fill in a TaskParameters_t
structure to define the task - this is the
structure passed to the xTaskCreateRestricted()
function. */ static const
TaskParameters_t xTaskDefinition = {
vTaskFunction, /* pvTaskCode
*/ "A task", /*
pcName */ 128, /*
usStackDepth - defined in words, not bytes.
*/ NULL, /*
pvParameters */ 1, /* uxPriority - priority 1, start in User mode.
*/ xTaskStack, /*
puxStackBuffer - the array to use as the task
stack. */ /*
xRegions - In this case only one of the three
user definable regions is actually used. The
parameters are used to set the region to read
only. */ { /* Base
address Length Parameters */ {
cReadOnlyArray, mainREAD_ONLY_ALIGN_SIZE,
portMPU_REGION_READ_ONLY }, { 0, 0, 0 }, { 0, 0,
0 }, } }; void main( void ) { /* Create the task defined by xTaskDefinition.
NULL is used as the second parameter as a task
handle is not required. */
xTaskCreateRestricted( &xTaskDefinition, NULL
); /* Start the RTOS
scheduler. */ vTaskStartScheduler();
/* Should not reach here!
*/ }
[
Back to the top ] [ About FreeRTOS
] [ Sitemap
] [
Report an error on this page (with anti-spam) ]
Copyright (C) 2004-2010 Richard Barry. Copyright
(C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd. |


Module jaypha.io.binarywriter
An adaptor to treat File objects as output ranges
suitable for writing binary output. lockingTextWriter
is unsuitable because it performs UTF conversions.
struct BinaryWriter
Methods
| this(File file) | Constructs with a File. |
| void put(T)(T e) | Outputs a single value. |
| void put(void[] e) | Outputs an array. |


Touch css framework
thanks for using touch, we're waiting for your feedback to improve it.
version 1.0.0 alpha
documentation
/
on twitter
/
on facebook


Snookes1516.github.io
Roman Food Facts: What Did the Romans Eat? - Primary Facts. Professional College Homework Help for Students. Order all your homework assignments from a truly remarkable online service. Let our professional writers provide. This is the new website for Woodlands Junior homework help. Hundreds of pages of easy to read information and facts on many homework topics including. Woodlands Junior-rivers Homework Help, Help With Academic. Primary school homework help romans - lostivale.eu. Robert Louis Stevenson: Facts and Information - Primary Facts. Primary school homework help romans OHMYHOME. It helped me very much on my homework and it got me to know all about Robert Louis Stevenson. The Romans came to Britain nearly 2000 years ago and changed our country. Even today, evidence of the Romans being here, can be seen in the ruins of Roman.
Primary homework help the romans. Primary homework help co uk romans gods - commit your assignment to us and we will do our best for you confide your dissertation to qualified scholars engaged Homework help the romans - Primary homework Home Federation of Lydden and River Primary School. Primary Homework Help for Kids - by Mandy Barrow. Best Academic Help. Starting at $7.98 per page. Get DISCOUNT Now! Help With Academic Papers Online - Best in UK, Woodlands Junior-rivers Homework. Welcome. Welcome to Jeavons Wood Primary School website. We hope you will enjoy using this site and that it will help you to discover more about our vibrant school.
Welcome to the Lydden and River Primary Schools Federation website. The children, parents, staff and governors are very proud of our two successful schools which. Primary homework help boudicca - Best and Reasonably. Primary homework help co uk romans gods - nardonegroup.org. Primary homework help co uk romans weapons. Primary school homework help romans - Perfectly crafted and custom academic writings. original papers at affordable costs available here will make your education.
This is also spelled boadicea and why didn t the romans primary homework help romans roman army to colchester the ww2 lands. All help boudicca. The Romans ate a varied diet consisting of vegetables, meat and fish. The poorest Romans ate quite simple meals, but the rich were used to eating a wide range. Primary homework help romans - markquette.com. Home Jeavons Wood Primary School.
This would have completely destroyed my academic performance! When did the Romans invade Britain? Woodlands junior-rivers homework help. Am a primary teacher looking. Internet is crowded with fraudulent sites, deceitful services that are after your money and do not care about results of their devastating activity. Primary homework help romans math homework help for 7th graders primary homework help co uk war evacuation homework help for 5th grade math help in essay writing. Primary homework help the romans - center-miami.com. Primary school homework help romans - Start working on your dissertation now with qualified assistance presented by the service Dissertations and resumes
Primary homework help co uk romans weapons - Instead of worrying about essay writing get the necessary help here professional researches at affordable costs available. Facts about Romans for Kids - Roman Britain Homework.


Governor Orders All Nonessential Functions to Suspend In-Person Operations
Governor Lamont has signed an executive order directing all nonessential functions in Connecticut to suspend in-person operations effective Monday, March 23 at 8PM.
Settings Menu
NoticeGovernor Lamont's "Stay Safe, Stay Home" executive order remains in effect. All non-essential workers statewide are being directed to work from home. For the latest information, executive orders, and guidance related to coronavirus (COVID-19), visit ct.gov/coronavirus
NOTICE:Governor Lamont's most recent press conference on COVID-19 was held on Tuesday, March 31, at 4PM >> WATCH VIDEO
The Centers for Disease Control and Prevention (CDC) is responding to an outbreak of respiratory disease caused by a novel (new) coronavirus that was first detected in China and which has now been detected in many locations internationally
In Connecticut and throughout the world, influenza(flu) activity is high. The CDC encourages all people aged 6 months and older to be vaccinated. It is not too late to get vaccinated for the flu. Check with your healthcare provider, call your local health department, or visit the HealthMap Vaccine Finder
TEST DATA
in Connecticut
Last Update: March 31, 2020 | 4:00 p.m.
FAQ
on Connecticut’s response
Last Update: March 30, 2020 | 10:00 p.m.
Latest Guidance:
|


The ways to implement security for Java EE web applications are discussed in a general way in Securing Containers. This chapter provides more detail and a few examples that explore these security services as they relate to web components.
A web application is accessed using a web browser over a network, such as the Internet or a company's intranet. As discussed in Distributed Multitiered Applications, the Java EE platform uses a distributed multitiered application model, and web applications run in the web tier.
Web applications contain resources that can be accessed by many users. These resources often traverse unprotected, open networks, such as the Internet. In such an environment, a substantial number of web applications will require some type of security.
Securing applications and their clients in the business tier and the EIS tier is discussed in Chapter 49, "Getting Started Securing Enterprise Applications".
The following topics are addressed here:
In the Java EE platform, web components provide the dynamic extension capabilities for a web server. Web components can be Java servlets or JavaServer Faces pages.
Certain aspects of web application security can be configured when the application is installed, or deployed, to the web container. Annotations and/or deployment descriptors are used to relay information to the deployer about security and other aspects of the application. Specifying this information in annotations or in the deployment descriptor helps the deployer set up the appropriate security policy for the web application. Any values explicitly specified in the deployment descriptor override any values specified in annotations.
Security for Java EE web applications can be implemented in the following ways.
Declarative security can be implemented using either metadata annotations or an application's deployment descriptor. See Overview of Java EE Security for more information.
Declarative security for web applications is described in Securing Web Applications.
Programmatic security is embedded in an application and can be used to make security decisions when declarative security alone is not sufficient to express the security model of an application. Declarative security alone may not be sufficient when conditional login in a particular work flow, instead of for all cases, is required in the middle of an application. See Overview of Java EE Security for more information.
Servlet 3.1 provides the authenticate
, login
, and logout
methods of the HttpServletRequest
interface. With the addition of the authenticate
, login
, and logout
methods to the Servlet specification, an application deployment descriptor is no longer required for web applications but may still be used to further specify security requirements beyond the basic default values.
Programmatic security is discussed in Using Programmatic Security with Web Applications.
Message security works with web services and incorporates security features, such as digital signatures and encryption, into the header of a SOAP message, working in the application layer, ensuring end-to-end security. Message security is not a component of Java EE 7 and is mentioned here for informational purposes only.
Some of the material in this chapter builds on material presented earlier in this tutorial. In particular, this chapter assumes that you are familiar with the information in the following chapters:
Web applications are created by application developers who give, sell, or otherwise transfer the application to an application deployer for installation into a runtime environment. Application developers communicate how to set up security for the deployed application by using annotations or deployment descriptors. This information is passed on to the deployer, who uses it to define method permissions for security roles, set up user authentication, and set up the appropriate transport mechanism. If the application developer doesn't define security requirements, the deployer will have to determine the security requirements independently.
Some elements necessary for security in a web application cannot be specified as annotations for all types of web applications. This chapter explains how to secure web applications using annotations wherever possible. It explains how to use deployment descriptors where annotations cannot be used.
A security constraint is used to define the access privileges to a collection of resources using their URL mapping.
If your web application uses a servlet, you can express the security constraint information by using annotations. Specifically, you use the @HttpConstraint
and, optionally, the @HttpMethodConstraint
annotations within the @ServletSecurity
annotation to specify a security constraint.
If your web application does not use a servlet, however, you must specify a security-constraint
element in the deployment descriptor file. The authentication mechanism cannot be expressed using annotations, so if you use any authentication method other than BASIC
(the default), a deployment descriptor is required.
The following subelements can be part of a security-constraint
.
Web resource collection (web-resource-collection
): A list of URL patterns (the part of a URL after the host name and port you want to constrain) and HTTP operations (the methods within the files that match the URL pattern you want to constrain) that describe a set of resources to be protected. Web resource collections are discussed in Specifying a Web Resource Collection.
Authorization constraint (auth-constraint
): Specifies whether authentication is to be used and names the roles authorized to perform the constrained requests. For more information about authorization constraints, see Specifying an Authorization Constraint.
User data constraint (user-data-constraint
): Specifies how data is protected when transported between a client and a server. User data constraints are discussed in Specifying a Secure Connection.
A web resource collection consists of the following subelements.
web-resource-name
is the name you use for this resource. Its use is optional.
url-pattern
is used to list the request URI to be protected. Many applications have both unprotected and protected resources. To provide unrestricted access to a resource, do not configure a security constraint for that particular request URI.
The request URI is the part of a URL after the host name and port. For example, let's say that you have an e-commerce site with a catalog that you would want anyone to be able to access and browse, and a shopping cart area for customers only. You could set up the paths for your web application so that the pattern /cart/*
is protected but nothing else is protected. Assuming that the application is installed at context path /myapp
, the following are true.
http://localhost:8080/myapp/index.xhtml
is not protected.
http://localhost:8080/myapp/cart/index.xhtml
is protected.
A user will be prompted to log in the first time he or she accesses a resource in the cart/
subdirectory.
http-method
or http-method-omission
is used to specify which methods should be protected or which methods should be omitted from protection. An HTTP method is protected by a web-resource-collection
under any of the following circumstances:
If no HTTP methods are named in the collection (which means that all are protected)
If the collection specifically names the HTTP method in an http-method
subelement
If the collection contains one or more http-method-omission
elements, none of which names the HTTP method
An authorization constraint (auth-constraint
) contains the role-name
element. You can use as many role-name
elements as needed here.
An authorization constraint establishes a requirement for authentication and names the roles authorized to access the URL patterns and HTTP methods declared by this security constraint. If there is no authorization constraint, the container must accept the request without requiring user authentication. If there is an authorization constraint but no roles are specified within it, the container will not allow access to constrained requests under any circumstances. Each role name specified here must either correspond to the role name of one of the security-role
elements defined for this web application or be the specially reserved role name *
, which indicates all roles in the web application. Role names are case sensitive. The roles defined for the application must be mapped to users and groups defined on the server, except when default principal-to-role mapping is used.
For more information about security roles, see Declaring Security Roles. For information on mapping security roles, see Mapping Roles to Users and Groups.
For a servlet, the @HttpConstraint
and @HttpMethodConstraint
annotations accept a rolesAllowed
element that specifies the authorized roles.
A user data constraint (user-data-constraint
in the deployment descriptor) contains the transport-guarantee
subelement. A user data constraint can be used to require that a protected transport-layer connection, such as HTTPS, be used for all constrained URL patterns and HTTP methods specified in the security constraint. The choices for transport guarantee are CONFIDENTIAL
, INTEGRAL
, or NONE
. If you specify CONFIDENTIAL
or INTEGRAL
as a security constraint, it generally means that the use of SSL is required and applies to all requests that match the URL patterns in the web resource collection, not just to the login dialog box.
The strength of the required protection is defined by the value of the transport guarantee, as follows.
Specify CONFIDENTIAL
when the application requires that data be transmitted so as to prevent other entities from observing the contents of the transmission.
Specify INTEGRAL
when the application requires that the data be sent between client and server in such a way that it cannot be changed in transit.
Specify NONE
to indicate that the container must accept the constrained requests on any connection, including an unprotected one.
|
Note: In practice, Java EE servers treat the |
The user data constraint is handy to use in conjunction with basic and form-based user authentication. When the login authentication method is set to BASIC
or FORM
, passwords are not protected, meaning that passwords sent between a client and a server on an unprotected session can be viewed and intercepted by third parties. Using a user data constraint with the user authentication mechanism can alleviate this concern. Configuring a user authentication mechanism is described in Specifying an Authentication Mechanism in the Deployment Descriptor.
To guarantee that data is transported over a secure connection, ensure that SSL support is configured for your server. SSL support is already configured for GlassFish Server.
|
Note: After you switch to SSL for a session, you should never accept any non-SSL requests for the rest of that session. For example, a shopping site might not use SSL until the checkout page, and then it might switch to using SSL to accept your card number. After switching to SSL, you should stop listening to non-SSL requests for this session. The reason for this practice is that the session ID itself was not encrypted on the earlier communications. This is not so bad when you're only doing your shopping, but after the credit card information is stored in the session, you don't want anyone to use that information to fake the purchase transaction against your credit card. This practice could be easily implemented by using a filter. |
You can create security constraints for resources within your application. For example, you could allow users with the role of PARTNER
full access to all resources at the URL pattern /acme/wholesale/*
and allow users with the role of CLIENT
full access to all resources at the URL pattern /acme/retail/*
. This is the recommended way to protect resources if you do not want to protect some HTTP methods while leaving other HTTP methods unprotected. An example of a deployment descriptor that would demonstrate this functionality is the following:
<!-- SECURITY CONSTRAINT #1 --> <security-constraint> <web-resource-collection> <web-resource-name>wholesale</web-resource-name> <url-pattern>/acme/wholesale/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>PARTNER</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> <!-- SECURITY CONSTRAINT #2 --> <security-constraint> <web-resource-collection> <web-resource-name>retail</web-resource-name> <url-pattern>/acme/retail/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>CLIENT</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>
A user authentication mechanism specifies
The way a user gains access to web content
With basic authentication, the realm in which the user will be authenticated
With form-based authentication, additional attributes
When an authentication mechanism is specified, the user must be authenticated before access is granted to any resource that is constrained by a security constraint. There can be multiple security constraints applying to multiple resources, but the same authentication method will apply to all constrained resources in an application.
Before you can authenticate a user, you must have a database of user names, passwords, and roles configured on your web or application server. For information on setting up the user database, see Managing Users and Groups in GlassFish Server.
The Java EE platform supports the following authentication mechanisms:
Basic authentication
Form-based authentication
Digest authentication
Client authentication
Mutual authentication
Basic, form-based, and digest authentication are discussed in this section. Client and mutual authentication are discussed in Chapter 50, "Java EE Security: Advanced Topics".
HTTP basic authentication and form-based authentication are not very secure authentication mechanisms. Basic authentication sends user names and passwords over the Internet as Base64-encoded text. Form-based authentication sends this data as plain text. In both cases, the target server is not authenticated. Therefore, these forms of authentication leave user data exposed and vulnerable. If someone can intercept the transmission, the user name and password information can easily be decoded.
However, when a secure transport mechanism, such as SSL, or security at the network level, such as the Internet Protocol Security (IPsec) protocol or virtual private network (VPN) strategies, is used in conjunction with basic or form-based authentication, some of these concerns can be alleviated. To specify a secure transport mechanism, use the elements described in Specifying a Secure Connection.
Specifying HTTP basic authentication requires that the server request a user name and password from the web client and verify that the user name and password are valid by comparing them against a database of authorized users in the specified or default realm.
Basic authentication is the default when you do not specify an authentication mechanism.
When basic authentication is used, the following actions occur.
A client requests access to a protected resource.
The web server returns a dialog box that requests the user name and password.
The client submits the user name and password to the server.
The server authenticates the user in the specified realm and, if successful, returns the requested resource.
Figure 48-1 shows what happens when you specify HTTP basic authentication.
Form-based authentication allows the developer to control the look and feel of the login authentication screens by customizing the login screen and error pages that an HTTP browser presents to the end user. When form-based authentication is declared, the following actions occur.
A client requests access to a protected resource.
If the client is unauthenticated, the server redirects the client to a login page.
The client submits the login form to the server.
The server attempts to authenticate the user.
If authentication succeeds, the authenticated user's principal is checked to ensure that it is in a role that is authorized to access the resource. If the user is authorized, the server redirects the client to the resource by using the stored URL path.
If authentication fails, the client is forwarded or redirected to an error page.
Figure 48-2 shows what happens when you specify form-based authentication.
The section The hello1-formauth Example: Form-Based Authentication with a JavaServer Faces Application is an example application that uses form-based authentication.
When you create a form-based login, be sure to maintain sessions using cookies or SSL session information.
For authentication to proceed appropriately, the action of the login form must always be j_security_check
. This restriction is made so that the login form will work no matter which resource it is for and to avoid requiring the server to specify the action field of the outbound form. The following code snippet shows how the form should be coded into the HTML page:
<form method="POST" action="j_security_check"> <input type="text" name="j_username"> <input type="password" name="j_password"> </form>
Like basic authentication, digest authentication authenticates a user based on a user name and a password. However, unlike basic authentication, digest authentication does not send user passwords over the network. Instead, the client sends a one-way cryptographic hash of the password and additional data. Although passwords are not sent on the wire, digest authentication requires that clear-text password equivalents be available to the authenticating container so that it can validate received authenticators by calculating the expected digest.
To specify an authentication mechanism, use the login-config
element. It can contain the following subelements.
The auth-method
subelement configures the authentication mechanism for the web application. The element content must be either NONE
, BASIC
, DIGEST
, FORM
, or CLIENT-CERT
.
The realm-name
subelement indicates the realm name to use when the basic authentication scheme is chosen for the web application.
The form-login-config
subelement specifies the login and error pages that should be used when form-based login is specified.
|
Note: Another way to specify form-based authentication is to use the |
When you try to access a web resource that is constrained by a security-constraint
element, the web container activates the authentication mechanism that has been configured for that resource. The authentication mechanism specifies how the user will be prompted to log in. If the login-config
element is present and the auth-method
element contains a value other than NONE
, the user must be authenticated to access the resource. If you do not specify an authentication mechanism, authentication of the user is not required.
The following example shows how to declare form-based authentication in your deployment descriptor:
<login-config> <auth-method>FORM</auth-method> <realm-name>file</realm-name> <form-login-config> <form-login-page>/login.xhtml</form-login-page> <form-error-page>/error.xhtml</form-error-page> </form-login-config> </login-config>
The login and error page locations are specified relative to the location of the deployment descriptor. Examples of login and error pages are shown in Creating the Login Form and the Error Page.
The following example shows how to declare digest authentication in your deployment descriptor:
<login-config> <auth-method>DIGEST</auth-method> </login-config>
You can declare security role names used in web applications by using the security-role
element of the deployment descriptor. Use this element to list all the security roles that you have referenced in your application.
The following snippet of a deployment descriptor declares the roles that will be used in an application using the security-role
element and specifies which of these roles is authorized to access protected resources using the auth-constraint
element:
<security-constraint> <web-resource-collection> <web-resource-name>Protected Area</web-resource-name> <url-pattern>/security/protected/*</url-pattern> <http-method>PUT</http-method> <http-method>DELETE</http-method> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>manager</role-name> </auth-constraint> </security-constraint> <!-- Security roles used by this web application --> <security-role> <role-name>manager</role-name> </security-role> <security-role> <role-name>employee</role-name> </security-role>
In this example, the security-role
element lists all the security roles used in the application: manager
and employee
. This enables the deployer to map all the roles defined in the application to users and groups defined in GlassFish Server.
The auth-constraint
element specifies the role, manager
, that can access the HTTP methods PUT, DELETE, GET, and POST located in the directory specified by the url-pattern
element (/security/protected/*
).
The @ServletSecurity
annotation cannot be used in this situation because its constraints apply to all URL patterns specified by the @WebServlet
annotation.
Programmatic security is used by security-aware applications when declarative security alone is not sufficient to express the security model of the application.
The following methods of the HttpServletRequest
interface enable you to authenticate users for a web application programmatically.
authenticate
allows an application to instigate authentication of the request caller by the container from within an unconstrained request context. A login dialog box displays and collects the user name and password for authentication purposes.
login
allows an application to collect user name and password information as an alternative to specifying form-based authentication in an application deployment descriptor.
logout
allows an application to reset the caller identity of a request.
The following example code shows how to use the login
and logout
methods:
package test; import java.io.IOException; import java.io.PrintWriter; import java.math.BigDecimal; import javax.ejb.EJB; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name="TutorialServlet", urlPatterns={"/TutorialServlet"}) public class TutorialServlet extends HttpServlet { @EJB private ConverterBean converterBean; /** * Processes requests for both HTTP <code>GET</code> * and <code>POST</code> methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println("<html>"); out.println("<head>"); out.println("<title>Servlet TutorialServlet</title>"); out.println("</head>"); out.println("<body>"); request.login("TutorialUser", "TutorialUser"); BigDecimal result = converterBean.dollarToYen(new BigDecimal("1.0")); out.println("<h1>Servlet TutorialServlet result of dollarToYen= " + result + "</h1>"); out.println("</body>"); out.println("</html>"); } catch (Exception e) { throw new ServletException(e); } finally { request.logout(); out.close(); } } }
The following example code shows how to use the authenticate
method:
package com.example.test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class TestServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
request.authenticate(response);
out.println("Authenticate Successful");
} finally {
out.close();
}
}
In general, security management should be enforced by the container in a manner that is transparent to the web component. The security API described in this section should be used only in the less frequent situations in which the web component methods need to access the security context information.
Servlet 3.1 specifies the following methods that enable you to access security information about the component's caller.
getRemoteUser
determines the user name with which the client authenticated. The getRemoteUser
method returns the name of the remote user (the caller) associated by the container with the request. If no user has been authenticated, this method returns null
.
isUserInRole
determines whether a remote user is in a specific security role. If no user has been authenticated, this method returns false
. This method expects a String
user role-name
parameter.
The security-role-ref
element should be declared in the deployment descriptor with a role-name
subelement containing the role name to be passed to the method. Using security role references is discussed in Declaring and Linking Role References.
getUserPrincipal
determines the principal name of the current user and returns a java.security.Principal
object. If no user has been authenticated, this method returns null
. Calling the getName
method on the Principal
returned by getUserPrincipal
returns the name of the remote user.
Your application can make business-logic decisions based on the information obtained using these APIs.
The following code demonstrates the use of programmatic security for the purposes of programmatic login. This servlet does the following.
It displays information about the current user.
It prompts the user to log in.
It prints out the information again to demonstrate the effect of the login
method.
It logs the user out.
It prints out the information again to demonstrate the effect of the logout
method.
package enterprise.programmatic_login; import java.io.*; import java.net.*; import javax.annotation.security.DeclareRoles; import javax.servlet.*; import javax.servlet.http.*; @DeclareRoles("javaee7user") public class LoginServlet extends HttpServlet { /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { String userName = request.getParameter("txtUserName"); String password = request.getParameter("txtPassword"); out.println("Before Login" + "<br><br>"); out.println("IsUserInRole?.." + request.isUserInRole("javaee7user")+"<br>"); out.println("getRemoteUser?.." + request.getRemoteUser()+"<br>"); out.println("getUserPrincipal?.." + request.getUserPrincipal()+"<br>"); out.println("getAuthType?.." + request.getAuthType()+"<br><br>"); try { request.login(userName, password); } catch(ServletException ex) { out.println("Login Failed with a ServletException.." + ex.getMessage()); return; } out.println("After Login..."+"<br><br>"); out.println("IsUserInRole?.." + request.isUserInRole("javaee7user")+"<br>"); out.println("getRemoteUser?.." + request.getRemoteUser()+"<br>"); out.println("getUserPrincipal?.." + request.getUserPrincipal()+"<br>"); out.println("getAuthType?.." + request.getAuthType()+"<br><br>"); request.logout(); out.println("After Logout..."+"<br><br>"); out.println("IsUserInRole?.." + request.isUserInRole("javaee7user")+"<br>"); out.println("getRemoteUser?.." + request.getRemoteUser()+"<br>"); out.println("getUserPrincipal?.." + request.getUserPrincipal()+"<br>"); out.println("getAuthType?.." + request.getAuthType()+"<br>"); } finally { out.close(); } } ... }
A security role reference is a mapping between the name of a role that is called from a web component using isUserInRole(String role)
and the name of a security role that has been defined for the application. If no security-role-ref
element is declared in a deployment descriptor and the isUserInRole
method is called, the container defaults to checking the provided role name against the list of all security roles defined for the web application. Using the default method instead of using the security-role-ref
element limits your flexibility to change role names in an application without also recompiling the servlet making the call.
The security-role-ref
element is used when an application uses the HttpServletRequest.isUserInRole(String role)
. The value passed to the isUserInRole
method is a String
representing the role name of the user. The value of the role-name
element must be the String
used as the parameter to the HttpServletRequest.isUserInRole(String role)
. The role-link
must contain the name of one of the security roles defined in the security-role
elements. The container uses the mapping of security-role-ref
to security-role
when determining the return value of the call.
For example, to map the security role reference cust
to the security role with role name bankCustomer
, the elements would look like this:
<servlet> ... <security-role-ref> <role-name>cust</role-name> <role-link>bankCustomer</role-link> </security-role-ref> ... </servlet>
If the servlet method is called by a user in the bankCustomer
security role, isUserInRole("cust")
returns true
.
The role-link
element in the security-role-ref
element must match a role-name
defined in the security-role
element of the same web.xml
deployment descriptor, as shown here:
<security-role> <role-name>bankCustomer</role-name> </security-role>
A security role reference, including the name defined by the reference, is scoped to the component whose deployment descriptor contains the security-role-ref
deployment descriptor element.
Some basic setup is required before any of the example applications will run correctly. The examples use annotations, programmatic security, and/or declarative security to demonstrate adding security to existing web applications.
Here are some other locations where you will find examples of securing various types of applications:
The cart-secure Example: Securing an Enterprise Bean with Declarative Security
The converter-secure Example: Securing an Enterprise Bean with Programmatic Security
GlassFish samples: https://glassfish-samples.java.net/
To set up your system for running the security examples, you need to configure a user database that the application can use for authenticating users. Before continuing, follow these steps.
Make sure that GlassFish Server has been started (see Starting and Stopping GlassFish Server).
Add an authorized user to GlassFish Server. For the examples in this chapter and in Chapter 49, "Getting Started Securing Enterprise Applications", add a user to the file
realm of GlassFish Server, and assign the user to the group TutorialUser
.
From the Administration Console, expand the Configurations node, then expand the server-config node.
Expand the Security node.
Expand the Realms node.
Select the File node.
On the Edit Realm page, click Manage Users.
On the File Users page, click New.
In the User ID field, enter a user ID.
In the Group List field, enter TutorialUser
.
In the New Password and Confirm New Password fields, enter a password.
Click OK.
Be sure to write down the user name and password for the user you create so that you can use it for testing the example applications. Authentication is case sensitive for both the user name and password, so write down the user name and password exactly. This topic is discussed more in Managing Users and Groups in GlassFish Server.
Set up Default Principal to Role Mapping in GlassFish Server.
From the Administration Console, expand the Configurations node, then expand the server-config node.
Select the Security node.
Select the Default Principal to Role Mapping Enabled check box.
Click Save.
This example explains how to use basic authentication with a servlet. With basic authentication of a servlet, the web browser presents a standard login dialog box that is not customizable. When a user submits his or her name and password, the server determines whether the user name and password are those of an authorized user and sends the requested web resource if the user is authorized to view it.
In general, the following steps are necessary for adding basic authentication to an unsecured servlet, such as the ones described in Chapter 6, "Getting Started with Web Applications". In the example application included with this tutorial, many of these steps have been completed for you and are listed here simply to show what needs to be done should you wish to create a similar application. This application can be found in the tut-install/examples/security/hello2-basicauth/
directory.
Follow the steps in To Set Up Your System for Running the Security Examples.
Create a web module for the servlet example, hello2
, as described in Chapter 6, "Getting Started with Web Applications".
Add the appropriate security annotations to the servlet. The security annotations are described in Specifying Security for Basic Authentication Using Annotations.
Build, package, and deploy the web application by following the steps in To Build, Package, and Deploy the hello2-basicauth Example Using NetBeans IDE or To Build, Package, and Deploy the hello2-basicauth Example Using Maven.
Run the web application by following the steps described in To Run the hello2-basicauth Example.
The default authentication mechanism used by GlassFish Server is basic authentication. With basic authentication, GlassFish Server spawns a standard login dialog box to collect user name and password data for a protected resource. Once the user is authenticated, access to the protected resource is permitted.
To specify security for a servlet, use the @ServletSecurity
annotation. This annotation allows you to specify both specific constraints on HTTP methods and more general constraints that apply to all HTTP methods for which no specific constraint is specified. Within the @ServletSecurity
annotation, you can specify the following annotations:
The @HttpMethodConstraint
annotation, which applies to a specific HTTP method
The more general @HttpConstraint
annotation, which applies to all HTTP methods for which there is no corresponding @HttpMethodConstraint
annotation
Both the @HttpMethodConstraint
and @HttpConstraint
annotations within the @ServletSecurity
annotation can specify the following:
A transportGuarantee
element that specifies the data protection requirements (that is, whether or not SSL/TLS is required) that must be satisfied by the connections on which requests arrive. Valid values for this element are NONE
and CONFIDENTIAL
.
A rolesAllowed
element that specifies the names of the authorized roles.
For the hello2-basicauth
application, the GreetingServlet
has the following annotations:
@WebServlet(name = "GreetingServlet", urlPatterns = {"/greeting"}) @ServletSecurity( @HttpConstraint(transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {"TutorialUser"}))
These annotations specify that the request URI /greeting
can be accessed only by users who have been authorized to access this URL because they have been verified to be in the role TutorialUser
. The data will be sent over a protected transport in order to keep the user name and password data from being read in transit.
If you use the @ServletSecurity
annotation, you do not need to specify security settings in the deployment descriptor. Use the deployment descriptor to specify settings for nondefault authentication mechanisms, for which you cannot use the @ServletSecurity
annotation.
Follow the steps in To Set Up Your System for Running the Security Examples.
From the File menu, choose Open Project.
In the Open Project dialog box, navigate to:
tut-install/examples/security
Select the hello2-basicauth
folder.
Click Open Project.
In the Projects tab, right-click the hello2-basicauth
project and select Build.
This command builds and deploys the example application to your GlassFish Server instance.
Follow the steps in To Set Up Your System for Running the Security Examples.
In a terminal window, go to:
tut-install/examples/security/hello2-basicauth/
Enter the following command:
mvn install
This command builds and packages the application into a WAR file, hello2-basicauth.war
, that is located in the target
directory, then deploys the WAR file.
In a web browser, enter the following URL:
https://localhost:8181/hello2-basicauth/greeting
You may be prompted to accept the security certificate for the server. If so, accept the security certificate. If the browser warns that the certificate is invalid because it is self-signed, add a security exception for the application.
An Authentication Required dialog box appears. Its appearance varies, depending on the browser you use.
Enter a user name and password combination that corresponds to a user who has already been created in the file
realm of GlassFish Server and has been assigned to the group TutorialUser
; then click OK.
Basic authentication is case sensitive for both the user name and password, so enter the user name and password exactly as defined for GlassFish Server.
The server returns the requested resource if all the following conditions are met.
A user with the user name you entered is defined for GlassFish Server.
The user with the user name you entered has the password you entered.
The user name and password combination you entered is assigned to the group TutorialUser
in GlassFish Server.
The role of TutorialUser
, as defined for the application, is mapped to the group TutorialUser
, as defined for GlassFish Server.
Enter a name in the field and click Submit.
Because you have already been authorized, the name you enter in this step does not have any limitations. You have unlimited access to the application now.
The application responds by saying "Hello" to the name you entered.
This example explains how to use form-based authentication with a JavaServer Faces application. With form-based authentication, you can customize the login screen and error pages that are presented to the web client for authentication of the user name and password. When a user submits his or her name and password, the server determines whether the user name and password are those of an authorized user and, if authorized, sends the requested web resource.
This example, hello1-formauth
, adds security to the basic JavaServer Faces application shown in A Web Module That Uses JavaServer Faces Technology: The hello1 Example.
In general, the steps necessary for adding form-based authentication to an unsecured JavaServer Faces application are similar to those described in The hello2-basicauth Example: Basic Authentication with a Servlet. The major difference is that you must use a deployment descriptor to specify the use of form-based authentication, as described in Specifying Security for the Form-Based Authentication Example. In addition, you must create a login form page and a login error page, as described in Creating the Login Form and the Error Page.
This application can be found in the tut-install/examples/security/hello1-formauth/
directory.
When using form-based login mechanisms, you must specify a page that contains the form you want to use to obtain the user name and password, as well as a page to display if login authentication fails. This section discusses the login form and the error page used in this example. Specifying Security for the Form-Based Authentication Example shows how you specify these pages in the deployment descriptor.
The login page can be an HTML page or a servlet, and it must return an HTML page containing a form that conforms to specific naming conventions (see the Java Servlet 3.1 specification for more information on these requirements). To do this, include the elements that accept user name and password information between <form></form>
tags in your login page. The content of an HTML page or servlet for a login page should be coded as follows:
<form method="post" action="j_security_check"> <input type="text" name="j_username"> <input type="password" name= "j_password"> </form>
The full code for the login page used in this example can be found at tut-install/examples/security/hello1-formauth/src/main/webapp/login.html
. Here is the code for this page:
<html lang="en"> <head> <title>Login Form</title> </head> <body> <h2>Hello, please log in:</h2> <form method="post" action="j_security_check"> <table role="presentation"> <tr> <td>Please type your user name: </td> <td><input type="text" name="j_username" size="20"/></td> </tr> <tr> <td>Please type your password: </td> <td><input type="password" name="j_password" size="20"/></td> </tr> </table> <p></p> <input type="submit" value="Submit"/> <input type="reset" value="Reset"/> </form> </body> </html>
The login error page is displayed if the user enters a user name and password combination that is not authorized to access the protected URI. For this example, the login error page can be found at tut-install/examples/security/hello1-formauth/
src/main/webapp/error.html
. For this example, the login error page explains the reason for receiving the error page and provides a link that will allow the user to try again. Here is the code for this page:
<html lang="en"> <head> <title>Login Error</title> </head> <body> <h2>Invalid user name or password.</h2> <p>Please enter a user name or password that is authorized to access this application. For this application, this means a user that has been created in the <code>file</code> realm and has been assigned to the <em>group</em> of <code>TutorialUser</code>.</p> <p><a href="login.html">Return to login page</a></p> </body> </html>
This example takes a very simple servlet-based web application and adds form-based security. To specify form-based instead of basic authentication for a JavaServer Faces example, you must use the deployment descriptor.
The following sample code shows the security elements added to the deployment descriptor for this example, which can be found in tut-install/examples/security/hello1-formauth/src/main/webapp/WEB-INF/web.xml
:
<security-constraint> <display-name>Constraint1</display-name> <web-resource-collection> <web-resource-name>wrcoll</web-resource-name> <description/> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <description/> <role-name>TutorialUser</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <realm-name>file</realm-name> <form-login-config> <form-login-page>/login.xhtml</form-login-page> <form-error-page>/error.xhtml</form-error-page> </form-login-config> </login-config> <security-role> <description/> <role-name>TutorialUser</role-name> </security-role>
Follow the steps in To Set Up Your System for Running the Security Examples.
From the File menu, choose Open Project.
In the Open Project dialog box, navigate to:
tut-install/examples/security
Select the hello1-formauth
folder.
Click Open Project.
In the Projects tab, right-click the hello1-formauth
project and select Run.
This command builds and deploys the example application to your GlassFish Server instance, then opens it in a browser.
Follow the steps in To Set Up Your System for Running the Security Examples.
In a terminal window, go to:
tut-install/examples/security/hello1-formauth/
Enter the following command at the terminal window or command prompt:
mvn install
This command builds and packages the application into a WAR file, hello1-formauth.war
, that is located in the target
directory, then deploys the WAR file to GlassFish Server.
To run the web client for hello1-formauth
, follow these steps.
Open a web browser to the following URL:
http://localhost:8080/hello1-formauth/
In the login form, enter a user name and password combination that corresponds to a user who has already been created in the file
realm of GlassFish Server and has been assigned to the group TutorialUser
.
Form-based authentication is case sensitive for both the user name and password, so enter the user name and password exactly as defined for GlassFish Server.
Click Submit.
If you entered My_Name
as the name and My_Pwd
for the password, the server returns the requested resource if all the following conditions are met.
A user with the user name My_Name
is defined for GlassFish Server.
The user with the user name My_Name
has a password My_Pwd
defined for GlassFish Server.
The user My_Name
with the password My_Pwd
is assigned to the group TutorialUser
on GlassFish Server.
The role TutorialUser
, as defined for the application, is mapped to the group TutorialUser
, as defined for GlassFish Server.
When these conditions are met and the server has authenticated the user, the application appears.
Enter your name and click Submit.
Because you have already been authorized, the name you enter in this step does not have any limitations. You have unlimited access to the application now.
The application responds by saying "Hello" to you.
Next Steps
For additional testing and to see the login error page generated, close and reopen your browser, enter the application URL, and enter a user name and password that are not authorized.


- Blog Posts
- Technical
- VC, Git and Github
- HTML & CSS
- Arrays & Hashes
- Ruby Enumerable Magic
- Intro to Ruby Classes
- FP vs. OOP
- Loops: JS vs. Ruby
- Dynamic vs. Static Typed languages
- Cultural
- DBC warm up
- Abstract Sequential
- Internet & Bias
- Pairing & Feedbacks
- Stereotype Threat
- Values To Live By
- Situations of Conflict
- Cheat Sheets
- SQL
01/30/2015
Stereotype Threat
I was lucky enough to have been raised in a privileged environment. I was educated in one of the best schools in Europe, where people of all background and nationalities were studying together and most students were very smart. My college experience at Wellesley was pretty much similar.
However, after I graduated and started working in Information Technology, I experienced an indirect form of stereotype threat. Not the typical "you made a mistake, that's because you come from a certain ethnic group or gender" type of stereotype threat, but a more subtle one.
There were times when I would work remotely from a wifi cafe. I the curious stares, and moments of disbelief.
What was it about me that could make them so doubtful or surprised that I could be smart?
Trying not to take it to the heart, I thought to myself that not everyone was lucky enough to be open-minded and intelligent. However, there were times when I have witnessed it affecting me. I would become more agitated and it was harder to focus on my work.
I can very much relate to others feeling stereotype threat. It doesn't solely depend on the gender, ethnicity, or the physical appearance in general. You can feel threatened by only talking, thinking, or believing a certain way.
But as my friend would say: "Stop being a victim!".
Although there isn't much to do to change people's prejudices, you can do something to change your own attitude towards them.
You should, of course, continue to ignore these people, but also change your mindset to a more forgiving and hopeful one.
It's helpful to realize that we are in an ever-changing society, and whether or not you know it, every action you do has a consequence on the future generation.
Ignorant people may be surprised to see me working on a laptop, but next time they go to a cafe and see another minority girl working on her laptop, they will get more used to it, which will influence their behavior. This, in turn, will give the girl more confidence, and there you go - a lovely butterly effect!
Let's not forget, finally, that as ignorant as some of the population may be, the USA is still a fast-growing country with surprising discoveries and policies that are made everyday. The society as a whole is used to fast changes, and slowly opening up to the possibility that truly anyone can be smart and successful. Isn't that what this country is about, anyway? ;-)
Optimistically,
-Sam


Hell awaits
Diablo IV will get quarterly updates, with more news coming in February 2020
Updates to come regularly in 2020.
by Samuel TolbertWhat you need to know
- Diablo IV was revealed at BlizzCon 2019.
- Game Director Luis Barriga has written a blog post, stating that quarterly updates will be provided for the game.
- These updates will start sometime in February 2020.
- Diablo IV does not currently have a release window.
When Diablo IV was revealed at BlizzCon 2019, Blizzard quickly squashed any notions of the game releasing sometime soon. "We are not coming anytime soon, not even Blizzard soon" was the line used. With that said, it doesn't look like fans will have to wait too long to learn more about the game, as a blog post from Luis Barriga, Game Director for Diablo IV, indicates that new updates will come over the next year in a quarterly fashion, starting in February 2020.
Luis writes that "We've been taking this week to assess and discuss our takeaways from BlizzCon, and we love all the deep discussions happening around the art, features, systems, and world of Diablo IV. We're also excited about a cool update we're planning for you in February of next year. It will be the first in a series of quarterly updates where we'll share behind-the-scenes looks at our progress going forward."
Luis also notes that the reveal cinematic for Diablo IV was meant to establish the tone for the game and the overall creative vision throughout development. More of that dark, grim aesthetic can be seen in the Gothic concept art that Blizzard has released so far. We'll be sure to cover any updates and information released beginning in February next year. Diablo IV is set to be available on the PlayStation 4, PC and Xbox One.

- Best keyboards for PlayStation 4 in 2019
- Best PlayStation 4 Games
We may earn a commission for purchases using our links. Learn more.


featurepositioning relatives
In 1958, English pictorial photographer Henry Peach Robinson created the world’s first photomontage by combivvtttttning five different negatives to make one complete print of a young girl on her deathbed. “Fading Away”—Robinson’s first and most famous composite photo—depicts a young girl dying of consumption and was controversial when it was exhibited, with many believing it was not a suitable subject for photography.


Toggle navigation
DRIBBBLEFOLIO
About
Blog
Resume
Contact
Hello
I’m
Your Name here
, Designer & Coder


Welcome to Gatherers. Type info to begin.
Enter Command:
mv (pos) (dir)
- for moving a unit
pd (pos) (dir) (unit)
- for producing a unit
rg (pos) (dir)
- for performing a ranged attack
done
- for ending your turn
info
- for displaying information about resources and population
exit
- end the game
Type the rank and file without spaces, e.g. c1.
n
- north
e
- east
s
- south
w
- west
nn
- two tiles north
ne
- north east
ee
- two tiles east
se
- south east
ss
- two tiles south
sw
- south west
ww
- two tiles west
nw
- north west
g
or G
- gatherer, who can produce other units
a
or A
- archer, who can perform ranged attacks
c
or C
- cavalryman, who can move twice per turn
s
or S
- spearman, who can take more damage
f
or F
- fortress
W
- wood, for producing an archer
H
- horse, for producing a cavalryman
I
- iron, for producing a spearman
L
- lake, for producing a fortress
P
- plain, just a plain plain
M
- mountain, which gets in the way of archers and cavalry
The objective is to destroy all of your opponent's gatherers.
The board is a five-by-six grid of tiles. Each tile can hold at most one unit. If there is a unit on a tile, it will be displayed as something like 's3', which is a spearman. The number after the letter is the amount of damage that unit can take before being destroyed. Lower-case and upper-case letters are used to indicate ownership of the unit by the first and second player, respectively.
On your turn, you can issue commands to all of your units. You can issue at most one command to each unit per turn (except for cavalrymen). You can move a unit by typing, for example 'mv c1 n'. This will move your unit at position d1 north, to 'd2'. You can move your units north, east, south, or west, but not diagonally. You can attack enemy units with your cavalry and spearmen by attempting to move them to a tile occupied by an enemy unit.
Each tile has a resource (see Types of Resources above). You can look at the resources on the board by entering 'info'. You can only see resources on tiles that have been revealed - a tile is revealed when a unit moves on it. You acquire resources by moving one of your gatherers on a resource tile. Then, your gatherer can produce a unit associated with the resource. For example, a gatherer placed on W (wood) can produce an archer. However, you must be occupying more of the resource for that unit than there are units of that type. For example, if you have two wood and two archers on the board, you cannot create another archer until you acquire more wood or an archer is destroyed.
You can issue a produce command by typing, for example, 'pd c1 n a', which means "produce, with the gatherer at c1, an archer on c2 (north of c1)".
The gatherer is a special unit that does not require resources to be produced. A gatherer on any tile can produce a gatherer. However, on the turn that you produce a gatherer, you cannot produce any other unit.
Archers can perform a ranged attack on enemy units up to two tiles away. To perform a ranged attack, type, for example, 'rg b2 nn' to attack the unit on tile b4 with your archer on b2.
A cavalryman must stop moving if it lands on a mountain tile. An archer cannot perform a ranged attack over mountains. If the ranged attack is over an unrevealed tile, that tile is revealed. If it is a mountain, the ranged attack fails.
A fortress is a special kind of gatherer. It cannot move, but can perform ranged attacks up to one tile away and produce units.


| Name |
Result |
| ringbuffer_instantiated |
success |
| WriteBinaryIntoRingBuffer_which_is_too_small |
success |
| WriteBinaryIntoRingBuffer_which_has_room_enough |
success |
| ReadBinaryFromRingBuffer |
success |
| WriteDataframeToRingbuffer |
success |
| ReadDataframeFromRingbuffer |
success |
| ReadDEDFromDataframeFromRingbuffer |
success |
| ReadMultipleDEDFromDataframeFromRingbuffer |
success |


Obsolete Members for QImage
The following members of class QImage are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.
Public Functions
(obsolete) QImage | alphaChannel() const |
(obsolete) int | numBytes() const |
(obsolete) int | numColors() const |
(obsolete) int | serialNumber() const |
(obsolete) void | setAlphaChannel(const QImage &alphaChannel) |
(obsolete) void | setNumColors(int n) |
(obsolete) void | setText(const char *key, const char *language, const QString &text) |
(obsolete) QString | text(const char *key, const char *language = Q_NULLPTR) const |
(obsolete) QString | text(const QImageTextKeyLang &keywordAndLanguage) const |
(obsolete) QStringList | textLanguages() const |
(obsolete) QList<QImageTextKeyLang> | textList() const |
Member Function Documentation
QImage QImage::alphaChannel() const
Returns the alpha channel of the image as a new grayscale QImage in which each pixel's red, green, and blue values are given the alpha value of the original image. The color depth of the returned image is 8-bit.
You can see an example of use of this function in QPixmap's alphaChannel(), which works in the same way as this function on QPixmaps.
Most usecases for this function can be replaced with QPainter and using composition modes.
Note this returns a color-indexed image if you want the alpha channel in the alpha8 format instead use convertToFormat(Format_Alpha8) on the source image.
Warning: This is an expensive function.
See also setAlphaChannel(), hasAlphaChannel(), convertToFormat(), Pixmap, and Image Transformations.
int QImage::numBytes() const
Returns the number of bytes occupied by the image data.
See also byteCount().
int QImage::numColors() const
Returns the size of the color table for the image.
See also setNumColors() and setColorCount().
int QImage::serialNumber() const
Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same serial number if they refer to the same contents (but they don't have to).
Use cacheKey() instead.
Warning: The serial number doesn't necessarily change when the image is altered. This means that it may be dangerous to use it as a cache key.
See also operator==().
void QImage::setAlphaChannel(const QImage &alphaChannel)
Sets the alpha channel of this image to the given alphaChannel.
If alphaChannel is an 8 bit grayscale image, the intensity values are written into this buffer directly. Otherwise, alphaChannel is converted to 32 bit and the intensity of the RGB pixel values is used.
Note that the image will be converted to the Format_ARGB32_Premultiplied format if the function succeeds.
Use one of the composition modes in QPainter::CompositionMode instead.
Warning: This function is expensive.
See also alphaChannel(), Image Transformations, and Image Formats.
void QImage::setNumColors(int n)
Resizes the color table to contain n entries.
See also numColors() and setColorCount().
void QImage::setText(const char *key, const char *language, const QString &text)
Sets the image text to the given text and associate it with the given key. The text is recorded in the specified language, or in a default language if language is 0.
Use setText() instead.
The language the text is recorded in is no longer relevant since the text is always set using QString and UTF-8 representation.
QString QImage::text(const char *key, const char *language = Q_NULLPTR) const
Returns the text recorded for the given key in the given language, or in a default language if language is 0.
Use text() instead.
The language the text is recorded in is no longer relevant since the text is always set using QString and UTF-8 representation.
QString QImage::text(const QImageTextKeyLang &keywordAndLanguage) const
This is an overloaded function.
Returns the text recorded for the given keywordAndLanguage.
Use text() instead.
The language the text is recorded in is no longer relevant since the text is always set using QString and UTF-8 representation.
QStringList QImage::textLanguages() const
Returns the language identifiers for which some texts are recorded. Note that if you want to iterate over the list, you should iterate over a copy.
The language the text is recorded in is no longer relevant since the text is always set using QString and UTF-8 representation.
See also textKeys().
QList<QImageTextKeyLang> QImage::textList() const
Returns a list of QImageTextKeyLang objects that enumerate all the texts key/language pairs set for this image.
The language the text is recorded in is no longer relevant since the text is always set using QString and UTF-8 representation.
See also textKeys().