Example data
Let's pretend we're interacting with a JSON based product catalog. This catalog has a product which has an id, a name, a price, and an optional set of tags.
Example JSON data for a product API
An example product in this API is:
{ "id": 1, "name": "A green door", "price": 12.50, "tags": ["home", "green"] }
While generally straightforward, that example leaves some open questions. For example, one may ask:
- What is id?
- Is name required?
- Can price be 0?
- Are all tags strings?
When you're talking about a data format, you want to have metadata about what fields mean, and what valid inputs for those fields are. JSON schema is a specification for standardizing how to answer those questions for JSON data.
Starting the schema
To start a schema definition, let's begin with a basic JSON schema:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object" }
The above schema has four properties called keywords. The title and description keywords are descriptive only, in that they do not add constraints to the data being validated. The intent of the schema is stated with these two keywords (that is, this schema describes a product).
The type keyword defines the first constraint on our JSON data: it has to be a JSON Object.
Finally, the $schema keyword states that this schema is written according to the draft v4 specification.
Defining the properties
Next let's answer our previous questions about this API, starting with id.
What is id?
id is a numeric value that uniquely identifies a product. Since this is the canonical identifier for a product, it doesn't make sense to have a product without one, so it is required.
In JSON Schema terms, we can update our schema to:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "integer" } }, "required": ["id"] }
Is name required?
name is a string value that describes a product. Since there isn't much to a product without a name, it also is required. Adding this gives us the schema:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "integer" }, "name": { "description": "Name of the product", "type": "string" } }, "required": ["id", "name"] }
Can price be 0?
According to Acme's docs, there are no free products. In JSON schema a number can have a minimum. By default this minimum is inclusive, so we need to specify exclusiveMinimum. Therefore we can update our schema with price:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "integer" }, "name": { "description": "Name of the product", "type": "string" }, "price": { "type": "number", "minimum": 0, "exclusiveMinimum": true } }, "required": ["id", "name", "price"] }
Are all tags strings?
Finally, we come to the tags property. Unlike the previous properties, tags have many values, and is represented as a JSON array. According to Acme's docs, all tags must be strings, but you aren't required to specify tags. We simply leave tags out of the list of required properties.
However, Acme's docs add two constraints:
- there must be at least one tag,
- all tags must be unique.
The first constraint can be added with minItems, and the second one by specifying uniqueItems as being true:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "integer" }, "name": { "description": "Name of the product", "type": "string" }, "price": { "type": "number", "minimum": 0, "exclusiveMinimum": true }, "tags": { "type": "array", "items": { "type": "string" }, "minItems": 1, "uniqueItems": true } }, "required": ["id", "name", "price"] }
Summary
The above example is by no means definitive of all the types of data JSON schema can define. For more definitive information see the full standard draft.
As a final example, here's a spec for an array of products, with the products having 2 new properties. The first is a dimensions property for the size of the product, and the second is a warehouseLocation field for where the warehouse that stores them is geographically located.
And also, since JSON Schema defines a reference schema for a geographic location, instead of coming up with our own, we'll reference the canonical one.
Set of products:
[ { "id": 2, "name": "An ice sculpture", "price": 12.50, "tags": ["cold", "ice"], "dimensions": { "length": 7.0, "width": 12.0, "height": 9.5 }, "warehouseLocation": { "latitude": -78.75, "longitude": 20.4 } }, { "id": 3, "name": "A blue mouse", "price": 25.50, "dimensions": { "length": 3.1, "width": 1.0, "height": 1.0 }, "warehouseLocation": { "latitude": 54.4, "longitude": -32.7 } } ]
Set of products schema:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product set", "type": "array", "items": { "title": "Product", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "number" }, "name": { "type": "string" }, "price": { "type": "number", "minimum": 0, "exclusiveMinimum": true }, "tags": { "type": "array", "items": { "type": "string" }, "minItems": 1, "uniqueItems": true }, "dimensions": { "type": "object", "properties": { "length": {"type": "number"}, "width": {"type": "number"}, "height": {"type": "number"} }, "required": ["length", "width", "height"] }, "warehouseLocation": { "description": "Coordinates of the warehouse with the product", "$ref": "http://json-schema.org/geo" } }, "required": ["id", "name", "price"] } }


Code of Conduct¶
Summary¶
- Treat everyone with respect and kindness
- Be thoughtful in how you communicate
- Don’t be destructive or inflammatory
- If you encounter an issue, please email<EMAIL_ADDRESS>Goals of This Document¶
Windmill Engineering is committed to providing a friendly, safe, and welcoming environment for all of our users, contributors, followers, and Fans, regardless of: gender identity or expression; sexual orientation; disability; neurodivergence; physical appearance; body size; ethnicity; nationality; race; age; religion; level of technical experience; education; socio-economic status; or similar personal characteristics.
The first goal of the Code of Conduct is to specify a baseline standard of behavior so that people with different social values and communication styles can talk effectively, productively, and respectfully.
The second goal is to provide a mechanism for resolving conflicts in the community when they arise.
The third goal of the Code of Conduct is to make our community welcoming to people from different backgrounds. Diversity is critical to the project; for Windmill to be successful, it needs contributors and users from all backgrounds.
We believe that healthy debate and disagreement are essential to a healthy project and community. However, it is never okay to be disrespectful. We value diverse opinions, but we value respectful behavior more.
Code of Conduct¶
Our Pledge¶
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of gender identity or expression, sexual orientation, disability, neurodivergence, physical appearance, body size, ethnicity, nationality, race, age, religion, level of technical experience, education, socio-economic status, or similar personal characteristics.
Our Standards¶
Examples of behavior that contributes to creating a positive environment include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Unwelcome comments regarding a person’s lifestyle choices and practices, including those related to food, health, parenting, drugs, and employment
- Publishing others’ private information, such as a physical or electronic address, without explicit permission (also known as “doxing”)
- Deliberate misgendering. This includes deadnaming or persistently using a pronoun that does not correctly reflect a person’s gender. You must address people by the name they give you when not addressing them by their username or handle
- Physical contact and simulated physical contact (e.g., textual descriptions like
*hug*
or*backrub*
) without consent or after a request to stop - Threats of violence, both physical and psychological
- Incitement of violence towards any individual, including encouraging a person to commit suicide or to engage in self-harm
- Harassing photography or recording, including logging online activity for harassment purposes
- Continued one-on-one communication after requests to cease
- Other conduct which could reasonably be considered inappropriate in a professional setting
Our open source community prioritizes marginalized people’s safety over privileged people’s comfort. We will not act on complaints regarding:
- “Reverse” -isms, including “reverse racism,” “reverse sexism,” and “cisphobia”
- Reasonable communication of boundaries, such as “leave me alone,” “go away,” or “I’m not discussing this with you”
- Refusal to explain or debate social justice concepts
- Communicating in a “tone” you don’t find congenial
- Criticizing racist, sexist, cissexist, or otherwise oppressive behavior or assumptions
Our Responsibilities¶
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Scope¶
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include: using an official project e-mail address; posting via an official social media account; or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct also applies outside the project spaces when the project maintainers have a reasonable belief that an individual’s behavior may have a negative impact on the project or its community.
Conflict Resolution¶
We do not believe that all conflict is bad; healthy debate and disagreement often yield positive results. However, it is never okay to be disrespectful or to engage in behavior that violates the project’s Code of Conduct.
If you see someone violating the Code of Conduct, you are encouraged to address the behavior directly with those involved. Many issues can be resolved quickly and easily, and this gives people more control over the outcome of their dispute. If you are unable to resolve the matter for any reason, or if the behavior is threatening or harassing, report it. We are dedicated to providing an environment where participants feel welcome and safe.
Reports should be directed to<EMAIL_ADDRESS>We will investigate every complaint, but you may not receive a direct response. We will use our discretion in determining when and how to follow up on reported incidents, which may range from not taking action to permanent expulsion from the project and project-sponsored spaces. We will notify the accused of the report and provide them an opportunity to discuss it before any action is taken. The identity of the reporter will be omitted from the details of the report supplied to the accused. In potentially harmful situations, such as ongoing harassment or threats to anyone’s safety, we may take action without notice.
Attribution¶
This Code of Conduct is adapted from the Contributor Covenant (v1.4), with additional content adapted from TODO Group’s Open Code of Conduct (no longer maintained).


Authenticating Users & App Clients¶
To protect your Nobackend application data, one of the steps you’ll take is to authenticate your app’s users. By ensuring that they are who they say they are, you can help ensure that your application’s data is available in secure ways. After you’ve created permission rules that define access to your application and have associated these rules with users, you’ll want to add code that authenticates your user, as described in this topic.

Note

You manage access to your application’s data by creating permission rules that govern which users can do what. Users authenticated as Application User have access according to these rules. For more about managing permissions, see [Using Permissions](using-permissions.html).

Authentication levels¶
Nobackend supports four levels of authentication:
- Application user: Grant’s user access to an API Services application, based on the roles and permissions assigned to the user.
- Application client: Grants full access to perform API requests against an API Services application.
- Organization client: Grants full access to perform API requests against an API Services organization.
- Admin user: Grants full access to perform API requests against any API Services organization that the user is an admin of.
Because the scope of access provided by the application client, organization client, and admin user authentication levels is so broad (and as a result, so powerful), it’s a bad practice to use them from a mobile app or any client-side code. Instead, they’re better suited to server-side implementations, such as web applications.
For a more detailed description of available authentication levels, see [Authentication levels](user-authentication-types.html).
Application user authentication (user login)¶
Using the username and password values specified when the user entity was created, your app can connect to the Usergrid application endpoint to request an access token. It’s also acceptable to use the user’s email address in place of the username.
Request syntax¶
curl -X POST "https://api.tbaas.co/<orgName>/<appName>/token" -d '{"grant_type":"password", "username":<username>, "password":<password>}'
Example request¶
curl -X POST "https://api.tbaas.co/my-org/my-app/token" -d '{"grant_type":"password", "username":"john.doe", "password":"testpw"}'
Example response¶
The results include the access token needed to make subsequent API requests on behalf of the application user:
{
"access_token": "5wuGd-lcEeCUBwBQVsAACA:F8zeMOlcEeCUBwBQVsAACA:YXU6AAABMq0hdy4",
"expires_in": 3600,
"user": {
...
}
}
Application client authentication¶
Using your app’s client id and client secret values, your app can connect to the Nobackend application endpoint to request an access token. The client ID and secret for your app can be found in ‘Getting Started’ section of the API Services admin portal, under ‘Server App Credentials’.
Warning
You should never authenticate this way from a client-side app such as a mobile app. A hacker could analyze your app and extract the credentials for malicious use even if those credentials are compiled and in binary format. See [Security Best Practices](../security-and-auth/securing-your-app.html) for additional considerations in keeping access to your app and its data secure.
Request syntax¶
curl -X POST "https://api.tbaas.co/<orgName>/<appName>/token" -d '{"grant_type":"client_credentials", "client_id":<application_clientID>, "client_secret":"<application_client_secret>"}'
Example request¶
curl -X POST "https://api.tbaas.co/my-org/my-app/token" -d '{"grant_type":"client_credentials", "client_id":"YXB7NAD7EM0MEeJ989xIxPRxEkQ", "client_secret":"YXB7NAUtV9krhhMr8YCw0QbOZH2pxEf"}'
Example response¶
The results include the access token needed to make subsequent API requests on behalf of the application:
{
"access_token": "F8zeMOlcEeCUBwBQVsAACA:YXA6AAABMq0d4Mep_UgbZA0-sOJRe5yWlkq7JrDCkA",
"expires_in": 3600,
"application": {
...
}
}
Admin user authentication¶
If you do require admin user access, your app can connect to the Nobackend management endpoint to request an access token. Your app supplies the username and password of an admin user in the request.
Warning
Authenticating as an admin user grants full access to one or more organizations and all of the applications contained in those organizations. Due to this, be cautious when implementing this type of authentication in client-side code. Instead, consider implementing admin user access in server-side code only. See [Security Best Practices](../security-and-auth/securing-your-app.html) for additional considerations in keeping access to your app and its data secure.
Request syntax¶
curl -X POST "https://api.tbaas.co/management/token" -d '{"grant_type":"password", "username":<admin_username>, "password":<admin_password>}'
Example Request¶
curl -X POST "https://api.tbaas.co/management/token" -d '{"grant_type":"password", "username":"testadmin", "password":"testadminpw"}'
Example response¶
The results include the access token needed to make subsequent API requests on behalf of the admin user:
{
"access_token": "f_GUbelXEeCfRgBQVsAACA:YWQ6AAABMqz_xUyYeErOkKjnzN7YQXXlpgmL69fvaA",
"expires_in": 3600,
"user": {
...
}
}
Organization client authentication¶
If you do require organization level access, your app can connect to the Usergrid management endpoint to request an access token. Access to an organization requires the client id and client secret credentials. The client ID and secret for your organization can be found on the ‘Org Administration’ page of the API Services admin console under ‘Organization API Credentials’.
Warning
You should never authenticate this way from a client-side app such as a mobile app. A hacker could analyze your app and extract the credentials for malicious use even if those credentials are compiled and in binary format. See [Security Best Practices](../security-and-auth/securing-your-app.html) for additional considerations in keeping access to your app and its data secure.
Request syntax¶
curl -X POST "https://api.tbaas.co/management/token" -d '{"grant_type":"client_credentials", "client_id":<org_clientID>, "client_secret":<org_client_secret>}'
Example request¶
curl -X POST "https://api.tbaas.co/management/token" -d '{"grant_type":"client_credentials", "client_id":"YXB7NAD7EM0MEeJ989xIxPRxEkQ", "client_secret":"YXB7NAUtV9krhhMr8YCw0QbOZH2pxEf"}'
Example response¶
The results include the access token needed to make subsequent API requests to the organization:
{
"access_token": "gAuFEOlXEeCfRgBQVsAACA:b3U6AAABMqz-Cn0wtDxxkxmQLgZvTMubcP20FulCZQ",
"expires_in": 3600,
"organization": {
...
}
}


|
MetroCollect
2.3.4
|
Small struct to implement MetricsController delegate. More...
Public Member Functions | |
| void | metricsContollerCollectedMetricsValues (const MetroCollect::MetricsController &, const MetroCollect::MetricsDiffArray &, const MetroCollect::MetricsDataArray &, const MetroCollect::MetricsDataArray &) override |
| Function called every time the MetricsController has collected new values. More... | |
| void | metricsContollerCollectedMetricsStats (const MetroCollect::MetricsController &, const MetroCollect::MetricsController::MetricsStats &) override |
| Function called every time the MetricsController has computed statistics. More... | |
| bool | metricsContollerShouldStopCollectingMetrics (const MetroCollect::MetricsController &) override |
| Function called after each iteration to ask the delegate whether the controller should stop collecting metrics. More... | |
Public Attributes | |
| size_t | iterationCount |
| Number of iterations remaining to be done. More... | |
| std::vector< std::pair< std::string, std::string > > | names |
| Name of collected metrics. More... | |
Small struct to implement MetricsController delegate.
Definition at line 96 of file MetroCollectStats.cc.
|
inlineoverridevirtual |
Function called every time the MetricsController has computed statistics.
| metricsController | the calling MetricsController |
| metricsStats | computed statistics |
Implements MetroCollect::MetricsControllerDelegate.
Definition at line 108 of file MetroCollectStats.cc.
|
inlineoverridevirtual |
Function called every time the MetricsController has collected new values.
| metricsController | the calling MetricsController |
| metricsDiff | computed metrics differences |
| previousMetrics | earlier collected metrics |
| currentMetrics | latest collected metrics |
Implements MetroCollect::MetricsControllerDelegate.
Definition at line 100 of file MetroCollectStats.cc.
|
inlineoverridevirtual |
Function called after each iteration to ask the delegate whether the controller should stop collecting metrics.
| metricsController | the calling MetricsController |
Implements MetroCollect::MetricsControllerDelegate.
Definition at line 112 of file MetroCollectStats.cc.
| size_t MetroCollectStats::iterationCount |
Number of iterations remaining to be done.
Definition at line 97 of file MetroCollectStats.cc.
| std::vector<std::pair<std::string, std::string> > MetroCollectStats::names |
Name of collected metrics.
Definition at line 98 of file MetroCollectStats.cc.


Public Member Functions | |
| int | getButton () |
| int | getClientX () |
| int | getClientY () |
| int | getScreenX () |
| int | getScreenY () |
| float | getLatitude () |
| float | getLongitude () |
| float | getAltitude () |
| bool | getDidHitGlobe () |
| bool | getAltKey () |
| bool | getCtrlKey () |
| bool | getShiftKey () |
| GEEventEmitter | getRelatedTarget () |
| int KmlMouseEvent.getButton | ( | ) |
The button on the mouse was pressed. Possible values include 0, 1, 2, where 0 is left, 1 is middle, and 2 is right mouse key.
| int KmlMouseEvent.getClientX | ( | ) |
The x coordinate at which the event occurred, measured in pixels from the left edge of the plug-in window.
| int KmlMouseEvent.getClientY | ( | ) |
The y coordinate at which the event occurred, measured in pixels from the top edge of the plug-in window.
| int KmlMouseEvent.getScreenX | ( | ) |
The x coordinate at which the event occurred, measured in pixels from the left edge of the computer screen.
| int KmlMouseEvent.getScreenY | ( | ) |
The y coordinate at which the event occurred, measured in pixels from the top edge of the computer screen.
| float KmlMouseEvent.getLatitude | ( | ) |
The latitude at which the event occurred, in decimal degrees.
| float KmlMouseEvent.getLongitude | ( | ) |
The longitude at which the event occurred, in decimal degrees.
| float KmlMouseEvent.getAltitude | ( | ) |
The altitude at which the event occurred, in meters.
| bool KmlMouseEvent.getDidHitGlobe | ( | ) |
Indicates whether a mouse action occurred while on the Google Earth globe.
| bool KmlMouseEvent.getAltKey | ( | ) |
Indicates whether the ALT key was held down when an event occurred.
| bool KmlMouseEvent.getCtrlKey | ( | ) |
Indicates whether the CTRL key was held down when an event occurred.
| bool KmlMouseEvent.getShiftKey | ( | ) |
Indicates whether the SHIFT key was held down when an event occurred.
| GEEventEmitter KmlMouseEvent.getRelatedTarget | ( | ) |
Used with the mouseover and mouseout events to specify a secondary target. For mouseover, it specifies the object that the mouse was over. For mouseout, it specifies the new object that the mouse is over.


JSON
Properties
The grammar has 11 terminals, 7 nonterminals, 17 productions, 27 LALR states and 36 DFA states.
It is case-sensitive.
Whitespace characters are ignored.
It was generated by Farkle 0.0.0-local on .
Syntax
- JSON
-
Object
-
- {
- Object Optional
- }
-
-
Array
-
- [
- Array Optional
- ]
-
-
Object Optional
-
- Nothing
-
Array Optional
-
- Nothing
-
Object Element
-
- Object Element
- ,
- String
- :
- JSON
-
- String
- :
- JSON
-
- Array Reversed
LALR States
| Symbol | Action |
|---|---|
| String | Shift to State 2 |
| Number | Shift to State 3 |
| true | Shift to State 6 |
| false | Shift to State 7 |
| null | Shift to State 8 |
| { | Shift to State 9 |
| [ | Shift to State 10 |
| JSON | Go to State 1 |
| Object | Go to State 4 |
| Array | Go to State 5 |
| Symbol | Action |
|---|---|
| EOF | Accept |
| Symbol | Action |
|---|---|
| } | Reduce <JSON> ::= String |
| ] | Reduce <JSON> ::= String |
| , | Reduce <JSON> ::= String |
| EOF | Reduce <JSON> ::= String |
| Symbol | Action |
|---|---|
| } | Reduce <JSON> ::= Number |
| ] | Reduce <JSON> ::= Number |
| , | Reduce <JSON> ::= Number |
| EOF | Reduce <JSON> ::= Number |
| Symbol | Action |
|---|---|
| } | Reduce <JSON> ::= <Object> |
| ] | Reduce <JSON> ::= <Object> |
| , | Reduce <JSON> ::= <Object> |
| EOF | Reduce <JSON> ::= <Object> |
| Symbol | Action |
|---|---|
| } | Reduce <JSON> ::= <Array> |
| ] | Reduce <JSON> ::= <Array> |
| , | Reduce <JSON> ::= <Array> |
| EOF | Reduce <JSON> ::= <Array> |
| Symbol | Action |
|---|---|
| } | Reduce <JSON> ::= true |
| ] | Reduce <JSON> ::= true |
| , | Reduce <JSON> ::= true |
| EOF | Reduce <JSON> ::= true |
| Symbol | Action |
|---|---|
| } | Reduce <JSON> ::= false |
| ] | Reduce <JSON> ::= false |
| , | Reduce <JSON> ::= false |
| EOF | Reduce <JSON> ::= false |
| Symbol | Action |
|---|---|
| } | Reduce <JSON> ::= null |
| ] | Reduce <JSON> ::= null |
| , | Reduce <JSON> ::= null |
| EOF | Reduce <JSON> ::= null |
| Symbol | Action |
|---|---|
| String | Shift to State 13 |
| } | Reduce <Object Optional> ::= |
| Object Optional | Go to State 11 |
| Object Element | Go to State 12 |
| Symbol | Action |
|---|---|
| String | Shift to State 2 |
| Number | Shift to State 3 |
| true | Shift to State 6 |
| false | Shift to State 7 |
| null | Shift to State 8 |
| { | Shift to State 9 |
| [ | Shift to State 10 |
| ] | Reduce <Array Optional> ::= |
| JSON | Go to State 16 |
| Object | Go to State 4 |
| Array | Go to State 5 |
| Array Optional | Go to State 14 |
| Array Reversed | Go to State 15 |
| Symbol | Action |
|---|---|
| } | Shift to State 17 |
| Symbol | Action |
|---|---|
| } | Reduce <Object Optional> ::= <Object Element> |
| , | Shift to State 18 |
| Symbol | Action |
|---|---|
| : | Shift to State 19 |
| Symbol | Action |
|---|---|
| ] | Shift to State 20 |
| Symbol | Action |
|---|---|
| ] | Reduce <Array Optional> ::= <Array Reversed> |
| , | Shift to State 21 |
| Symbol | Action |
|---|---|
| ] | Reduce <Array Reversed> ::= <JSON> |
| , | Reduce <Array Reversed> ::= <JSON> |
| Symbol | Action |
|---|---|
| } | Reduce <Object> ::= '{' <Object Optional> '}' |
| ] | Reduce <Object> ::= '{' <Object Optional> '}' |
| , | Reduce <Object> ::= '{' <Object Optional> '}' |
| EOF | Reduce <Object> ::= '{' <Object Optional> '}' |
| Symbol | Action |
|---|---|
| String | Shift to State 22 |
| Symbol | Action |
|---|---|
| String | Shift to State 2 |
| Number | Shift to State 3 |
| true | Shift to State 6 |
| false | Shift to State 7 |
| null | Shift to State 8 |
| { | Shift to State 9 |
| [ | Shift to State 10 |
| JSON | Go to State 23 |
| Object | Go to State 4 |
| Array | Go to State 5 |
| Symbol | Action |
|---|---|
| } | Reduce <Array> ::= '[' <Array Optional> ']' |
| ] | Reduce <Array> ::= '[' <Array Optional> ']' |
| , | Reduce <Array> ::= '[' <Array Optional> ']' |
| EOF | Reduce <Array> ::= '[' <Array Optional> ']' |
| Symbol | Action |
|---|---|
| String | Shift to State 2 |
| Number | Shift to State 3 |
| true | Shift to State 6 |
| false | Shift to State 7 |
| null | Shift to State 8 |
| { | Shift to State 9 |
| [ | Shift to State 10 |
| JSON | Go to State 24 |
| Object | Go to State 4 |
| Array | Go to State 5 |
| Symbol | Action |
|---|---|
| : | Shift to State 25 |
| Symbol | Action |
|---|---|
| } | Reduce <Object Element> ::= String ':' <JSON> |
| , | Reduce <Object Element> ::= String ':' <JSON> |
| Symbol | Action |
|---|---|
| ] | Reduce <Array Reversed> ::= <Array Reversed> ',' <JSON> |
| , | Reduce <Array Reversed> ::= <Array Reversed> ',' <JSON> |
| Symbol | Action |
|---|---|
| String | Shift to State 2 |
| Number | Shift to State 3 |
| true | Shift to State 6 |
| false | Shift to State 7 |
| null | Shift to State 8 |
| { | Shift to State 9 |
| [ | Shift to State 10 |
| JSON | Go to State 26 |
| Object | Go to State 4 |
| Array | Go to State 5 |
| Symbol | Action |
|---|---|
| } | Reduce <Object Element> ::= <Object Element> ',' String ':' <JSON> |
| , | Reduce <Object Element> ::= <Object Element> ',' String ':' <JSON> |
DFA States
| Characters | Action |
|---|---|
| Tab, Line Feed, Carriage Return, Space | Go to State 1 |
| " | Go to State 2 |
| Comma | Go to State 3 |
| - | Go to State 4 |
| 0 | Go to State 5 |
| 1…9 | Go to State 6 |
| : | Go to State 7 |
| [ | Go to State 8 |
| ] | Go to State 9 |
| f | Go to State 10 |
| n | Go to State 11 |
| t | Go to State 12 |
| { | Go to State 13 |
| } | Go to State 14 |
| Characters | Action |
|---|---|
| Tab, Line Feed, Carriage Return, Space | Go to State 1 |
| Accept Whitespace (Noise) |
| Characters | Action |
|---|---|
| " | Go to State 30 |
| \ | Go to State 31 |
| In all other cases | Go to State 2 |
| Accept , |
| Characters | Action |
|---|---|
| 0 | Go to State 5 |
| 1…9 | Go to State 6 |
| Characters | Action |
|---|---|
| . | Go to State 25 |
| E, e | Go to State 26 |
| Accept Number |
| Characters | Action |
|---|---|
| 0…9 | Go to State 6 |
| . | Go to State 25 |
| E, e | Go to State 26 |
| Accept Number |
| Accept : |
| Accept [ |
| Accept ] |
| Characters | Action |
|---|---|
| a | Go to State 21 |
| Characters | Action |
|---|---|
| u | Go to State 18 |
| Characters | Action |
|---|---|
| r | Go to State 15 |
| Accept { |
| Accept } |
| Characters | Action |
|---|---|
| u | Go to State 16 |
| Characters | Action |
|---|---|
| e | Go to State 17 |
| Accept true |
| Characters | Action |
|---|---|
| l | Go to State 19 |
| Characters | Action |
|---|---|
| l | Go to State 20 |
| Accept null |
| Characters | Action |
|---|---|
| l | Go to State 22 |
| Characters | Action |
|---|---|
| s | Go to State 23 |
| Characters | Action |
|---|---|
| e | Go to State 24 |
| Accept false |
| Characters | Action |
|---|---|
| 0…9 | Go to State 29 |
| Characters | Action |
|---|---|
| +, - | Go to State 27 |
| 0…9 | Go to State 28 |
| Characters | Action |
|---|---|
| 0…9 | Go to State 28 |
| Characters | Action |
|---|---|
| 0…9 | Go to State 28 |
| Accept Number |
| Characters | Action |
|---|---|
| E, e | Go to State 26 |
| 0…9 | Go to State 29 |
| Accept Number |
| Accept String |
| Characters | Action |
|---|---|
| ", /, \, b, f, n, r, t | Go to State 2 |
| u | Go to State 32 |
| Characters | Action |
|---|---|
| 0…9, A…F, a…f | Go to State 33 |
| Characters | Action |
|---|---|
| 0…9, A…F, a…f | Go to State 34 |
| Characters | Action |
|---|---|
| 0…9, A…F, a…f | Go to State 35 |
| Characters | Action |
|---|---|
| 0…9, A…F, a…f | Go to State 2 |


Lozowski confident Saracens will soon be winning trophies again
Lozowski has found it ‘amusing’ what rival players and coaches have said about Saracens since the salary cap breach was revealed.
Saracens back Alex Lozowski has warned rival clubs they will be back on the trophy trail again soon despite the salary cap breach currently dominating the headlines.
The Gallagher Premiership and Heineken Champions Cup holders face a 35-point deduction in addition to a fine of more than £5million if any appeal against a penalty for breaching the salary cap is not successful.
It would catapult the Allianz Park club into a relegation battle and they may have to prioritise league fixtures over more European success.
England international Lozowski said: “As a player you want to be competing at the top end of competitions.
“Maybe not this season, but we will win championships again and I want to be part of that and we all want to be a part of that.
“The people at the club are too good and care too much and work too hard every day for this to affect us going forward in the long run.
“Whatever happens this season will happen, but as I’ve said, looking to the future I think there is lots to be positive about.”
Lozowski was speaking to the media ahead of Sunday’s Champions Cup opener with Racing 92 in Pool Four.
Maybe not this season, but we will win championships again and I want to be part of that and we all want to be a part of thatAlex Lozowski
Reporters were told not to ask questions about the salary cap breach, with Saracens bringing in a representative from a communications company to help them deal with the fallout from the scandal.
The 26-year-old admitted: “It’s hard not to see it on social media and obviously a lot of people have had a lot to say about it – other teams, coaches and players.
“It is quite amusing to read what they have to say and what they think about it, but in terms of how it makes me feel – it doesn’t really bother me all that much.”
Saracens’ versatile back insisted they were proud of their achievements in Europe last term and were not prepared to “lie down and give it away” while he also revealed the squad have not discussed potential punishments.
“We have an amazing challenge at the weekend against a phenomenal team and the second we start worrying about other things, it could be a long afternoon on Sunday.
“We know what we’ve got to do in terms of our preparation to get ready for a big game.”
He added: “Ever since I have been here, we have been pretty much universally disliked, so it’s not really new to us and that is what happens to you when you have success and win championships.
“I guess what has happened, has made that a bit worse, but we are used to being disliked.”


Before Change
A list of objects returned by ``fn`` on each operator.
return ray.get([w.apply_operator.remote(fn) for w in self.workers])
def validate(self, num_steps=None, profile=False, info=None):
Evaluates the model on the validation data set.
After Change
A list of objects returned by ``fn`` on each operator.
remote_calls = [
w.apply_operator.remote(fn) for w in self.remote_workers
]
local_call = self.local_worker.apply_operator(fn)
return [local_call] + ray.get(remote_calls)
def validate(self, num_steps=None, profile=False, info=None):
Evaluates the model on the validation data set.


{% extends "_post.html" %} {%hyde title: "Down with The Man" created: 2004-05-17 03:35:22 %} {% block article %} {%article%}
So, I’ve ditched MovableType in favor of WordPress. I have to say I’m fairly impressed with it. The installation (including the MT import process) was incredibly simple and painless, save one problem with the dates for the imported entries which was hosing the RSS feed.
Hooray for Free Software.
{%endarticle%} {% endblock %}


Textblock adjusts size, leading, and grades to cast continuously responsive type. It works over your current CSS as a progressive enhancement.
With variable adjustment to weight — Textblock adjusts size, leading, and grades to cast continuously responsive type. It works over your current CSS as a progressive enhancement.
With font-size inversely related to container width, and variable weight and line-height directly related — Textblock adjusts size, leading, and grades to cast continuously responsive type. It works over your current CSS as a progressive enhancement.
With legacy parameter names from v0.9.9 — Textblock adjusts size, leading, and grades to cast continuously responsive type. It works over your current CSS as a progressive enhancement. Some parameter names have changed:
With legacy parameter names from v0.10.0 — Textblock adjusts size, leading, and grades to cast continuously responsive type. It works over your current CSS as a progressive enhancement. Some parameter names have changed:
| v0.9.9 | v0.10.0 | Latest |
|---|---|---|
minFontSize |
minWidthFontSize |
minWidth_FontSize |
maxFontSize |
maxWidthFontSize |
maxWidth_FontSize |
units |
|
fontSize_Units |
minLineHeight |
minWidthLineHeight |
minWidth_LineHeight |
maxLineHeight |
maxWidthLineHeight |
maxWidth_LineHeight |
minVariableGrade |
minWidthVariableGrade |
minWidth_VariableGrade |
maxVariableGrade |
maxWidthVariableGrade |
maxWidth_VariableGrade |


LEARN programming by visualizing code executionOnline Python Tutor is a free educational tool that helps students overcome a fundamental barrier to learning programming: understanding what happens as the computer executes each line of a program's source code. Using this tool, a teacher or student can write a Python program directly in the web browser and visualize what the computer is doing step-by-step as it executes the program. So far, over 250,000 people in over 133 countries have used Online Python Tutor to understand and debug their programs, often as a supplement to textbooks, lecture notes, and online programming tutorials. Users include students taking online courses from Coursera, edX, and Udacity, and professors in over a dozen universities such as MIT, UC Berkeley, UC Davis, the University of Washington, the University of Toronto, the University of Waterloo, Luther College, and Swarthmore College. Here is a visualization showing a Python program that recursively finds the sum of a (cons-style) linked list. Click the “Forward” button to see what happens as the computer executes each line of code. You can also visualize execution in the IPython shell in interactive mode. Watch this one-minute overview:
Read the research paper – Philip J. Guo. Online Python Tutor: Embeddable Web-Based Program Visualization for CS Education. In Proceedings of the ACM Technical Symposium on Computer Science Education (SIGCSE), March 2013. |
EMBED visualizations in digital textbooksUsing a single line of JavaScript code, you can embed an Online Python Tutor visualization within your web page (as shown in the “Learn” box above). The screenshot below shows a few of these visualizations embedded within the online textbook for the introductory CS course at UC Berkeley (CS61A): These visualizations have also been embedded within two other web-based Python textbook projects: How to Think Like a Computer Scientist: Interactive Edition and Computer Science Circles. These textbooks collectively attract around 16,000 unique viewers per month and are being used in at least 25 universities around the world. In addition, instructors have embedded Online Python Tutor visualizations into LMS platforms such as Moodle and edX. |
More Details:
Other Variants:
|


I read a previous posts that talked about getting Auto Still Spell as a bonus PM feat if you met the requirements, but I cannot seem to.
I'm sure I'm missing something so if anyone can point it out I would greatly appreciate it.
Ok, the build I was working on was Bard/RDD/PM. At level 32 I was B10/RDD10/PM12, and I had already taken Still Spell and my spellcraft was 27. (I believe those are the requirements for Auto Still Spell) I have read many times you can ignore the lv9 spell level requirements....unless that got changed in the last patch?
On lv33 (PM13) I got my bonus feat along with your normal feat, but my bonus list was only Epic Energy Resistance. At level 39 (PM16), I also got the normal bonus PM feat, but my only choices were Epic Spells and Epic Energy Resist.
What am I missing?
I do believe you're missing level 9 spells, a prereq. of Auto Still feats.
Try taking PM to over lvl15; seems other lvl9 requirements are ignored then (eg epic spells for a lvl5 bard)
Unfortunately, Autostill spell is not one of those feats that PM 15 goes over. You must be able to cast lvl 9 arcane spells, period. _________________ If everyone is thinking alike, then someone is failing to think.
Yes, this seems to be the answer.
A bard/PM can never get Auto Still Spells due to the lack of lv9 spells.


--- layout: post status: publish published: true title: Executing a SQL script using ADO.NET author: display_name: Tomas Restrepo login: tomasr email<EMAIL_ADDRESS>url: http://winterdom.com/ author_login: tomasr author_email<EMAIL_ADDRESS>author_url: http://winterdom.com/ wordpress_id: 672 wordpress_url: http://winterdom.com/2005/04/executingasqlscriptusingadonet date: '2005-04-11 17:22:20 +0000' date_gmt: '2005-04-11 17:22:20 +0000' categories: - ".NET" tags: [] comments: [] ---
Matt Berther posts here on how to execute SQL Server scripts using ADO.NET, which has its own set of tricks because of the GO-delimiters.
This reminded me that I implemented precisely this feature, though in a different way, for the original SqlTask in NAntContrib for NAnt. Several people have modified the original code since, but you can probably still see traces of the original code here and there. It was a little bit more general purpose, though, since it allowed configurable statement delimiters, including both regular expression-based ones and a few other thingies.


Inserting records in a Sequential File
READ, WRITE, PERFORM..UNTIL, IF, DISPLAY
Introduction
Using the SeqWrite.Cbl
program as a starting point write a program called SeqInsert.Cbl to take
a file of new student records (TransIns.Dat) and insert them into the correct
order into the student file (Students.Dat). To do this you will need
to create a new file (Students.New) containing the merged records.
Download Students.Dat
and save it to theWorkArea directory on drive D:.
Download TransIns.Dat
and save it to the same place.
The File Descriptions
Details of new students are initially recorded in a transaction file (TransIns.Dat).
Records in the file are ordered on ascending StudentId.
Details of existing students are held in the student file (Students.Dat).
Records in this file are also ordered on ascending StudentId.
A program is required which will merge these two files to create a new
student file (Students.New) which contains the records of both files.
Records in the new student file must be ordered on ascending StudentId.
The records in the transaction file, the students file and the new file
all have the same description.
All three records consist of the following items;
|
Field
|
Type
|
Length
|
Value
|
| Student Id |
9
|
7
|
0-9999999
|
| Student Name |
.
|
.
|
Group
|
| Surname |
X
|
8
|
-
|
| Initials |
X
|
2
|
-
|
| DateOfBirth |
.
|
.
|
Group
|
| Year |
9
|
2
|
00-99
|
| Month |
9
|
2
|
01-12
|
| Day |
9
|
2
|
01-31
|
| Course Code |
X
|
4
|
-
|
| Grant |
9
|
4
|
0000-9999
|
| Gender |
X
|
1
|
M/F
|
Further Work
Add code to your program to read the file you have just created and display
the StudentId and StudentName from each record. Display the records
as shown in
the example run below:
Stud-Id Surname
8812356 MACKEY TD
8812357 BOBBIN WE
8812358 DALEY FR
8812359 SWINDON GL
8912345 Insert2 ok
8912351 DEWEY AS
8912352 RICHARDSTR
8912353 GORMAN WJ
8912354 FAHY ML
8912355 RYAN GN
8912356 CORKERY DF
8912357 COFFEY SD
8912358 FORD LM
8912359 GRANT HS
9012351 FLOOD MB
9012352 HUBERT TJ
9012353 JONES VT
9012354 KINGSTONDR
9012355 LANGAN RR
9012356 MORGAN WR
9012357 MANLEY FL
9012358 NORMAN LK
9012359 OTTERMANFD
9123453 Insert3 ok
Sample Solution
When you have written your program and have compiled it and have it working
correctly you may wish to compare it with this
sample solution.
WARNING
Do not look at the solution until you have finished your own or at
least have made a substantial effort to complete it.
Examining the sample solution
Compile and run the sample solution provided. Use the Animator to
step through the program and examine the contents of the records as the
program executes.
As you examine the program, attempt to answer the following questions:-
-
Why is FILLER used in the record descriptions.?
-
In the program, the field StudentName is not described as it is in the
record description above. Why is it still a valid description?
-
Why are the Student File and Transaction File records filled with "9"'s
when the end of file is reached? What problem does this solve neatly?
-
The READ TransFile statement in the paragraph MergeTheFiles is outside
the scope of the second IF statment. Why is the IF statement written
like this?
Last updated : March 1997
e-mail : CSISwebeditor@ul.ie


(To the tune of Bring Me Your Winding-Sheet, Oh Mother Of Mine)
Cold and dark is this awful night, as I shiver in my shed. The Lord He has forsaken me and deprived me of my bed. I have no pies nor pastries to shovel down my gob. Oh the Lord He has forsaken me. All I can do is sob.
I weep in my allotment shed, I weep until the dawn. I curse the very buttercups upon the village lawn. The Lord He has forsaken me and I am so forlorn. I wail and gnash my rotting teeth that I was ever born.
My name is Leo Sayer, I am short, with frizzy hair. I sit here in my wooden shed upon a wooden chair. I curse the fact that I share my name with a singer of pop pap, and then I spill my flask of boiling tea into my lap.
The Lord He has forsaken me, all I can do is whine. O Lord God Almighty, please send me a sign. Please stop people thinking that I'm the singer Leo S, the small-of-stature minstrel who got me in this mess.
He fled to the Antipodes, or so I have been told. He moved across the globe because his records undersold. It seems the Lord forsook him too, but that is only right. I sob and wail in my shed on this dark and awful night.
DETOURS : Muggletonian Celestial Prints … Rapture Ready … Nice Cup Of Tea And A Sit Down


We are about to take part in the social / biz coding venture called codesnappy. More information about it soon!
Opera Software have announced that they are abandoning their proprietary Presto rendering engine in favour of the open source WebKit rendering engine, for future versions of their mobile and desktop web browsers.
With the release of the new version of the most popular JS framework owners introduced new version of the interface with integrated access to other, jQuery related libraries and new, nice user interface.


This directive allows you to embed a map on your AngularJS application and interact bi-directionally with it via the AngularJS scope and the leaflet map library API. In its current state, it's not a full-featured library, although it's easy to use and extend, and a good starting point to learn to code a directive into the great AngularJS library.
The code of the directive and this page has been inspired by the Angular Google Maps directive developed by nlaplante & nmccready. The initial code has been (and is being) evolved and improved by these contributors.
Before using angular-leaflet-directive, you must include some javascript files to your main HTML:
Something like this:
And that's all. Now you can start embedding maps to your application adding the custom tag <leaflet>
with some attributes on your HTML code, and interacting with the scope of your controller. Let's see how it works and how you can use it in the examples page, or take a look of what can be accomplished with it on the demos below.


--- layout: page title: About header-img: "img/about-bg.png" ---
I'm a CTI-trained transition coach and a former Safety & Bidding Coordinator for a Wastewater Treatment Plant construction company and a former yoga teacher. I've had numerous significant transitions in my life so far, and now I'm making another radical change as I start my coding boot camp experience with Flatiron's Learn.co. Stay tuned to see what happens next!


public class Door
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
int |
CLOSED
CLOSED state
|
private boolean |
container
Whether a door or container
|
private Exit |
exit
The Exit behind the door
|
private java.util.Vector<Item> |
items
The containing items if container
|
private Item |
key
The key if locked
|
private boolean |
locked
The door's locked/unlocked state
|
int |
LOCKED
LOCKED state
|
private boolean |
open
The door's open/closed state
|
int |
OPEN
OPEN state
|
private static long |
serialVersionUID
Serializable Class Version Number
|
private java.lang.String |
stateClosed
The door/container's response when closed
|
private java.lang.String |
stateLocked
The door/container's response when locked
|
private java.lang.String |
stateOpen
The door/container's response when open
|
private java.lang.String |
title
The door/container's name
|
| Constructor and Description |
|---|
Door()
Initializes empty Door
|
Door(java.lang.String title)
Initializes Door with name
|
Door(java.lang.String title,
boolean container,
boolean open)
Initializes door/container
|
Door(java.lang.String title,
Exit exit)
Initializes Door
|
Door(java.lang.String title,
Exit exit,
boolean open)
Initializes door
|
| Modifier and Type | Method and Description |
|---|---|
void |
addItem(Item item)
Add items to the container
|
java.lang.String |
getDescription()
Gets the door/container's description
|
Exit |
getExit()
Gets the exit behind the door
|
java.util.Vector<Item> |
getItems()
Gets all items in the container
|
Item |
getKey()
Gets the key needed to unlock the door/container
|
java.lang.String |
getState(int state)
Gets a specified state message
|
java.lang.String |
getTitle()
Gets the door/container's name
|
java.lang.String |
getTitle(boolean processed)
Gets the door/container's name, processed for plural detection
|
boolean |
isContainer()
Gets whether the object is a container
|
boolean |
isLocked()
Gets whether the door/container is locked
|
boolean |
isOpen()
Gets whether the door/container is open
|
void |
removeItem(Item item)
Remove items from the container
|
void |
setExit(Exit exit)
Set the exit behind the door
|
void |
setKey(Item key)
Set the key needed to unlock the door/container
|
void |
setLocked(boolean locked)
Set door/container to locked/unlocked
|
void |
setLocked(java.lang.String stateLocked,
boolean locked)
Sets the door/container's locked state and message
|
void |
setMessages(java.lang.String stateOpen,
java.lang.String stateClosed)
Sets open and closed responses
|
void |
setOpen(boolean open)
Set door/container to open/closed
|
void |
setTitle(java.lang.String title)
Sets the door/container's name
|
java.lang.String |
toString()
Gets the door/container's name
|
public final int CLOSED
private boolean container
private Exit exit
private java.util.Vector<Item> items
private Item key
private boolean locked
public final int LOCKED
private boolean open
public final int OPEN
private static final long serialVersionUID
private java.lang.String stateClosed
private java.lang.String stateLocked
private java.lang.String stateOpen
private java.lang.String title
public Door()
public Door(java.lang.String title)
title
- The door's namepublic Door(java.lang.String title, boolean container, boolean open)
title
- The door/container's namecontainer
- Whether door or containeropen
- Whether opened or closedpublic Door(java.lang.String title, Exit exit)
title
- The door's nameexit
- The connected Locationpublic Door(java.lang.String title, Exit exit, boolean open)
title
- The door's nameexit
- The connected Locationopen
- Whether opened or closedpublic void addItem(Item item)
item
- The item to addpublic java.lang.String getDescription()
public Exit getExit()
public java.util.Vector<Item> getItems()
public Item getKey()
public java.lang.String getState(int state)
state
- State to checkpublic java.lang.String getTitle()
public java.lang.String getTitle(boolean processed)
processed
- Whether the name should be processed for plural detectionpublic boolean isContainer()
public boolean isLocked()
public boolean isOpen()
public void removeItem(Item item)
item
- The item to removepublic void setExit(Exit exit)
exit
- The exit behind the doorpublic void setKey(Item key)
key
- The key itempublic void setLocked(boolean locked)
locked
- Locked: true/falsepublic void setLocked(java.lang.String stateLocked, boolean locked)
stateLocked
- Text to display when lockedlocked
- Whether the door/container is lockedpublic void setMessages(java.lang.String stateOpen, java.lang.String stateClosed)
stateOpen
- Text to display when openstateClosed
- Text to display when closedpublic void setOpen(boolean open)
open
- Open: true/falsepublic void setTitle(java.lang.String title)
title
- The door/container's namepublic java.lang.String toString()
toString
in class java.lang.Object


ZIP archive
feature demo
Click on this
link
to load page stored in ZIP archive (
pages.zip
). Enjoy it!


PLANET SICK-BOY: http://www.sick-boy.com "We Put the SIN in Cinema"
Somewhere between hardcore and softcore pornography lies … well, Lies, a bold, button-pushing film from Jang Sun Woo, the reigning bad boy of Korean cinema. His latest is about the sadomasochistic relationship between a high school virgin and her older lover. The film is based on Jung-Il Chang's novel (adapted by Jang), which has been banned in Korea.
Lies would have been creepy enough left to its own devices, but Jang uses a bunch of interesting cinematic techniques to make the film look and feel like a documentary about defiling a naïve girl. Both principal actors are making their screen debuts, and their characters are only known by their first initials. Lies contains documentary-style interviews with both actors, and each provides narration throughout portions of the film.
Tae Yeon Kim plays Y, an 18-year-old high school virgin who wants to get laid before her graduation. Through her best friend Woori (Hye Jin Jeon), she is introduced to a 38-year-old artist named J (Sang Hyun Lee). Woori is in love with J and his art, but she's too embarrassed to make advances toward the married sculptor. Instead, Woori makes her friend call J, and she finds herself living vicariously through the colorful acts of phone sex that Y has with J.
Y and J eventually agree to meet in person, and the two perform every carnal act imaginable. Lies pulls no punches here, showing it all as Y is violated in every orifice. Jang even uses some clever title cards to announce which cavity J is about to fill (`The First Hole,' `The Second Hole,' and so forth).
The dialogue isn't any less crass than the visuals. J rudely announces, `I'm going in,' before invading one of Y's nooks.  He also paws at her private parts like a monkey looking for bugs.
Strangely, Y seems game for everything, cooing, `I like anything that J does' to the enraptured Woori.  The whippings increase in severity, and it isn't long before Y's brother (Kwon Taek Han) begins to get suspicious about her sister's violent older lover.
Lies is disturbing cinema at either its best or worst form, depending on where you stand on the issue of perversity in modern cinema. It's great that Jang was able to produce such an unflinching look at the bizarre sexual relationship between two obviously unstable people, but other than raising both eyebrows and trousers, I'm not too sure what his point was.
1:52 – Not Rated but contains nudity, strong sexual content, violence and adult language
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


My Wireframes
In Pinterest, you create boards(categories) that you can then pin items to. I choose the page that is used to display pins as a board for my wireframe. This page is trying to solve the problem of organizing your pins by their content. Having no organizational unit would make pinterest a very shallow, messy, cluttered failure. Being able to organize your pins is key and this page is at the heart of that.
This is very visually challenging as there are many pictures/comments that have to be crammed into the page. There are also various navigation peices that have to be shown as well. Not done well, this could lead to a cluttered look. Pinterest solves this my minimizing the navigation pieces and getting them out of your way. They expand out when needed. Also, each pin is exactly the same width as the next. Their heights very greatly the the width restraint insures that there is always 5 rows of pins on the screen which makes thing consistant and very clean.
Noah Bradley
Noah's website is pretty much a single page so I've choosen the home page here to wireframe. This page is solving the problem of putting the artist's artwork on display with out slowing down load times or diminishing the resolution of the art work. The artwork is organized into a single column of images that can be scrolled through easily
Visually, the challenge here is finding the right image size for the thumbnails so that the story of the art comes through even though the art work is at a smaller resolution than it is intended to be viewed at. In the end, the art work is put front and center and looks awesome but still loads quickly.
Engadget
For Engadget, I choose their news feed page. Here, they are trying to solve the problem of condensing a news article down to a great title, a great picture, and enough of the article itself to get you to click through and read the entire thing. Each news article gets the same max width and height to get this done in. The intent is to give the reader enough to decide if the article is for them or not.
The challenge visually is to dress up the article's content visually to entice the reader to click through. They do this by putting a catchy title and picture for the article front and center. The start of the article below this is given second billing by being short and sweet with very few emphasis put on it.


Custom Popup
Open Popup
Lorem Ipsum
Hello, {{name}}
Lorem Ipsum is {{first}} {{name}}'s simply dummy text of the printing and typesetting industry.


Hard to believe that after 7+ years, it's my last day @WebMD. So many good memories.
10/5/2012, 11:50:27 AM
Favs: 0
Retweets: 0
link--- layout: tweet ---
Hard to believe that after 7+ years, it's my last day @WebMD. So many good memories.
10/5/2012, 11:50:27 AM
Favs: 0
Retweets: 0
link


pre
element
Each word is on a new line
Code

Each
word
is
on
a
new
line

Reference
HTML5 pre element


| Release |
Date
|
Features/Fixes
|
Svn
information Tag/Branch |
| 0.9 |
April 28 2005 |
Preview
version |
RELEASE_0_9_BRANCH |
| 1.0 |
April 28 2005 | First release |
RELEASE_1_0_BRANCH |
| 1.5 |
April 28 2005 | Bundled with Glassfish 9.0 and SJSAS 8.2EE |
RELEASE_1_5
(tag) |
| 1.5.1
|
September 4 2006 |
Bug fix release for issue with reconnection with SeeBeyond MQ |
RELEASE_1_5_BRANCH |
| 1.6.0 |
March 6 2006 |
Bug
Fixes Fix for suspend/resume problem with MQ series. |
RELEASE_1_6_BRANCH |
| 1.7-final |
May 14 2007 |
New Features
- reliable redelivery, topic load balancing and inbound resource monitoring. WSMQ redelivery property added |
RELEASE_1_7_BRANCH |
| 2.0.alpha |
May 14 2007 |
New Features - Synchronous Message delivery in inbound path. |
TRUNK |
| 1.5.2 |
Nov 21 2007 |
Bug fixes release - 6604707 |
RELEASE_1_5_2 |
| 2.0 |
Nov 28 2008 |
2.0 Final release |
RELEASE_2_0 (tag) |
| 2.1a |
Sep 15 2010 |
2.1 Final release Bugfix release to support WebLogic JMS Bugs fixed in 2.1a |
RELEASE_2_1_a (tag) |
| 2.1b |
Nov 23 2012 |
2.1 Final release Bug fixes release Bugs fixed in 2.1b |
RELEASE_2_1_b (tag) |
| 2.1c |
May 6 2014 |
2.1 Final release Bug fixes release Bugs fixed in 2.1c |
RELEASE_2_1_c (tag) |
| 2.0.1a |
May 8 2014 |
Bug fix release |
RELEASE_2_0_1_BRANCH |


You are entering an area that requires authentication. You are being redirected to accounts.cbd.int in order to:
Once authorized you will be redirected back to your intended destination.


Georide road trip
Step 1 : Create account
Create an account, fill all the informations requiered. You can have help on create account page with the information about georide.
Create an accountStep 2 : share the url to everyone
You can share this url : https://georide.ripoul.fr/trip/your-username. With this url, your friend can follow you live and have some information.
That's it !
The user can select only the dates in your road trip.Open-Source
This project is open-source ! Feel free to share it to your friends.All contributions are welcome. The project is on github here.


Ingredients
- 1 3/4 cups all purpose flour
- 3/4 cup old fashioned rolled oats
- 1/3 cup light brown sugar
- 2 tsp ground ginger
- 1 1/2 tsp ground cinnamon
- 1/8 tsp ground cloves
- 1/2 tsp salt
- 1 1/2 tsp baking powder
- 1/2 tsp baking soda
- 1/2 cup cold unsalted vegan butter, cut into pieces
- 2 tbsp crystallized ginger, finely chopped
- 1/2 cup almond milk
- t tsp apple cider vinegar
- 2 1/2 tablespoons unsulphured molasses
Instructions
- Preheat oven to 400 degrees F.
- Mix the nut milk and vinegar and allow to curdle.
- Whisk together the flour, oats, sugar, spices, baking powder, baking soda, and salt.
- Cut in the butter with a pastry blender, forming course crumbs.
- Stir in the crystalized ginger.
- Mix the molasses into the curdled milk, and gently combine into the flour mixture. Do not overmix.
- On a lightly floured surface, pat the dough into a circle and cut into wedges.
- Transfer to a baking sheet and bake for 18-20 minutes, until golden brown. A toothpick inserted into the middle should come out clean.
- Move to a wire rack to cool, and serve warm.


"Bring sunshine on a rainy day."
I'm a full stack software engineer who has been described as driven, motivated, and detail oriented. I bring a boost of energy and excitement everywhere I go. I'm a fast learner and enjoy solving complex puzzles. As a former Air Force medic, I'm familiar with working in fast paced environments where attention to detail could mean saving a life.
View LinkedInA full stack application developed over just two days. My goal was simple, create a fitness application for my friends and family.
Users would have the ability to hide or share their weight. A line chart displays your progress. Users can motivate others by posting to the community feed.
This application utilizes the following technologies: React, PostgreSQL, Node, and Express wrapped in Material UI.
A full stack application developed over two weeks for a client using React. This application stores data from events such as festivals and gives brands interested in sponsoring those events the ability to search for the perfect fit using advanced filters.
Sponsorship Hub reduces repetitive work for the researchers and connects brands with events quicker and easier.Adventure Book is a full stack application that was created during a two week sprint. It allows users to read stories with branching options and multiple endings. Administrators can create stories from scratch.
Application was written in React.JS and utilizes Node, Express, and PostgreSQL.This full stack application was created over three days and utilized saga middleware to intercept dispatches before handing off to Redux. It simulates a movie database similar to IMDB.


BJP contract killer of democracy, threatened Opportunist Ajit Pawar: Congress
Congress spokesperson Randeep Surjewala alleged that the BJP threatened Nationalist Congress Party (NCP) leader Ajit Pawar into joining hands with the saffron party to form the government in Maharashtra.
Slamming the new government in Maharashtra as "illegitimate", the Congress on Saturday termed the swearing-in of Bharatiya Janata Party's Devendra Fadnavis as chief minister a black chapter in India's democracy, saying the saffron party acted as the "contract killer" of the democracy.
Addressing a press conference, Congress spokesperson Randeep Surjewala alleged that the BJP threatened Nationalist Congress Party (NCP) leader Ajit Pawar into joining hands with the saffron party to form the government in Maharashtra.
Also Read
He alleged that Maharashtra governor Bhagat Singh Koshyari did not make effort to verify Devendra Fadnavis' claims of having the support of a majority of MLAs before administering the chief minister's oath to him.
Calling Ajit Pawar "opportunist", Randeep Singh Surjewala said the BJP "threatened" the NCP leader who has joined hands with the saffron party, acted as "contract killer" of democracy, and "robbed" Maharashtra.
"Devendra Fadnavis had promised to put Ajit Pawar in jail but has made him the deputy chief minister now," Randeep Surjewala said, adding, "Modi hai toh mumkin hai [It is possible if PM Modi is there]"
Attacking the Governor, the Congress spokesperson said Bhagat Singh Koshyari turned into Home Minister Amit Shah's "hitman". "PM Narendra Modi and Amit Shah are behind the early morning coup," he said.
He further asked why no media was invited by the Governor for Devendra Fadnavis' swearing-in ceremony. "Why wasn't the media invited by the Governor for the oath-taking ceremony. Why was such a level of secrecy maintained? Only a private agency and the government's media DD were called for the oath-taking ceremony," Randeep Surjewala said.
"Governor of Maharashtra met Devendra Fadnavis at night and by 5:47 am, President's Rule in the state was withdrawn. For that, we have a protocol," the Congress said.
The party spokesperson also said that it is looking for legal ways to deal with the Maharashtra developments. "All options are open including a legal way. We are taking advice from our experts. Let's see what they suggest."
"Our MLAs are very loyal to us. Amit Shah can't put their dignity and honestly on sale," Randeep Surjewala concluded.


Store
public struct Store
Shared Web Credentials Store.
Supports reading, adding, and removing shared web credentials. There is also a utility method for generating a new password.
-
Completion block for reading from shared web credentials.
Note
If the error is
nil
, the array will not be empty.Declaration
Swift
public typealias ReadCompletion = (_ credential: Credential?, _ error: CFError?) -> Void
Parameters
credentials
Array of credentials or
nil
.error
System error or
nil
. -
Completion block for writing to shared web credentials.
Note
If the error is
nil
, the operation was a success.Declaration
Swift
public typealias WriteCompletion = (_ error: CFError?) -> Void
Parameters
error
System error or
nil
.
-
Asynchronously obtain one or more shared passwords for a website.
This function requests one or more shared passwords for a given website, depending on whether the optional account parameter is supplied. To obtain results, the website specified in the fqdn parameter must be one which matches an entry in the calling application’s
com.apple.developer.associated-domains
entitlement.Note
The system API
SecRequestSharedWebCredential
returns an array ofCFDictionary
objects for each result. In practice, you only ever get one dictionary in this array. The system UI shows all of the credentials you have saved, but makes you select just one. The one you select is the contents of the results array.Declaration
Swift
public static func get(domain: String? = nil, account: String? = nil, completion: @escaping ReadCompletion)
Parameters
domain
Fully qualified domain name of the website for which passwords are being requested. If
nil
is passed in this argument, the domain name(s) listed in the calling application’scom.apple.developer.associated-domains
entitlement are searched implicitly.account
Account name for which passwords are being requested. The account may be
nil
to request all shared credentials which are available for the site, allowing the caller to discover an existing account.completion
A block which will be called to deliver the requested credential. If no matching items were found, the credential array will be
nil
, and the CFErrorRef parameter will provide the error result. -
Asynchronously store (or update) a shared password for a website.
This function adds a shared password item which will be accessible by Safari and applications that have the specified fully-qualified domain name in their
com.apple.developer.associated-domains
entitlement. If a shared password item already exists for the specified website and account, it will be updated with the provided password.Note
Note:
Since a request involving shared web credentials may potentially require user interaction or other verification to be approved, this function is dispatched asynchronously; your code provides a completion handler that will be called once the results (if any) are available.
Declaration
Swift
public static func add(domain: String, account: String, password: String, completion: WriteCompletion? = nil)
Parameters
domain
The fully qualified domain name of the website requiring the password.
account
The account name associated with this password.
password
The password to be stored.
completion
A block which will be invoked when the function has completed. If the shared password was successfully added, the CFErrorRef parameter passed to the block will be
nil
. If the error parameter is non-nil, an error occurred and the error reference will hold the result. -
Asynchronously remove a shared password for a website.
This function remove a shared password item which will be accessible by Safari and applications that have the specified fully-qualified domain name in their
com.apple.developer.associated-domains
entitlement.Note
Note:
Since a request involving shared web credentials may potentially require user interaction or other verification to be approved, this function is dispatched asynchronously; your code provides a completion handler that will be called once the results (if any) are available.
Declaration
Swift
public static func remove(domain: String, account: String, completion: WriteCompletion? = nil)
Parameters
domain
The fully qualified domain name of the website requiring the password.
account
The account name associated with this password.
completion
A block which will be invoked when the function has completed. If the shared password was successfully removed, the CFErrorRef parameter passed to the block will be
nil
. If the error parameter is non-nil, an error occurred and the error reference will hold the result.
-
Returns a randomly generated password.
Declaration
Swift
public static func generatePassword() -> String?
Return Value
Optional
String
password in the formxxx-xxx-xxx-xxx
wherex
is taken from the sets"abcdefghkmnopqrstuvwxy"
,"ABCDEFGHJKLMNPQRSTUVWXYZ"
,"3456789"
with at least one character from each set being present ornil
if it failed.


{{Refimprove|date=November 2007}} {{Infobox prepared food | name = Strozzapreti | image = | caption = Uncooked strozzapreti | alternate_name = | country = Italy | region = | creator = | course = | type = Pasta | served = | main_ingredient = | variations = | calories = | other = }} Strozzapreti ({{IPA-it|ˌstrɔttsaˈprɛːti}}; "priest-choker" or "priest-strangler" <ref>"Strozza" is third person singular indicative of "strozzare"</ref> in Italian) are an elongated form of cavatelli, or hand-rolled pasta typical of the Emilia-Romagna, Tuscany, Marche and Umbria regions of Italy as well as in the state of San Marino. The name is also used for a baked cheese and vegetable dumpling, prepared in some regions of Italy and in the French island of Corsica.
Contents |
{{Unreferenced section|date=November 2014}} There are several legends to explain the name.
One is that gluttonous priests were so enthralled by the savory pasta that they ate too quickly and choked themselves, sometimes to death. Another explanation involves the "azdora" ("housewife" in the Romagna's dialect), who "chokes" the dough strips to make the strozzapreti: "... in that particular moment you would presume that the azdora would express such a rage (perhaps triggered by the misery and difficulties of her life) to be able to strangle a priest!" Another legend goes that wives would customarily make the pasta for churchmen as partial payment for land rents (In Romagna, the Catholic Church had extensive land properties rented to farmers), and their husbands would be angered enough by the venal priests eating their wives' food to wish the priests would choke as they stuffed their mouth with it. The name surely reflects the diffuse anticlericalism of the people of Romagna and Tuscany.
The dough (see some regional variations below) is rolled out in thick flat sheets. It is then cut into strips. The strips are lightly rolled or twisted between the palms. The large pasta is separated into 10 cm pieces by pinching. Unlike spaghetti or macaroni, this pasta is not uniform in size or shape.
The dough traditionally used for strozzapreti in Romagna is made with wheat flour, water, salt, and (optionally) eggs.
In Emilia the dough is made from flour, water, Parmesan cheese, and egg whites, all beaten together.
Pici is a somewhat similar form of pasta from Tuscany in which hand-rolled, solid fat tubes of dough are cut but left untwisted; the taut, rope-like appearance provides yet another popular explanation for the association with strangling.
Strozzapreti ({{lang-co|sturzapreti}}) refers also to large gnocchi made of cheese and vegetables, and then baked, typical of Corsica. Seasoned spinach or chard is rolled into balls together with brocciu cheese, and then baked in oven.


Hippo.NET Build Tool Released
Here. From Jan Tielens: Hippo.NET is a tool for streamlining the build process of .NET projects in a team envirionment. It provides continuous integration by monitoring the shared Visual SourceSafe database and starting the build process when changes are detected. An important design goal is to provide a nice and easy-to-use user interface, to monitor builds and trigger the build process when needed.
Now you can download a stable version of this tool, with full source code.
Current features are:
- Client/server model
- Trigger build from remote clients
- Implements the build process proposed by Microsoft
- Automatic build number updates in AssemblyInfo files
- Build history information
- Current activity information
- Fully configurable
- Rich Windows Forms UI


{% extends 'base.html' %} {% block head %}
This example is a quick exercise to illustrate how the navbar and its contents work. Some navbars extend
the width of the viewport, others are confined within a .container
. For positioning of
navbars, checkout the top and fixed top examples.
At the smallest breakpoint, the collapse plugin is used to hide the links and show a menu button to toggle the collapsed content.


fun RecyclerView.setItemDecorationSpacing(spacingPx: Float): Unit
Add an RecyclerViewItemDecoration to this RecyclerView. Item decorations can affect both measurement and drawing of individual item views.
spacingPx
- Spacing in pixels to set as a item margin.
See Also


Nonsense Story App
{% if flask_debug %}
Flask is in debug mode. This is not safe for production
{{line}}
{% for n in lines %}
{{n}}
{% endfor %}


...express your thoughts
This is the home for your thoughts and ideas.
Easily search for entries in your journal.
Your entries are totally private. Only you can access your entries


Here you can find all my interesting thoughts and opinions.


Off Canvas Partial Touch
with hammer.js, fastClick and Flexbox
- Click to show the sidebar
- Click the content to show the sidebar (only before the red line)
- Swipe the content with your mouse or finger to the right (only before the red line)
- Click to hide the sidebar
- Click the content to hide the sidebar (anywhere)
- Swipe the content with your mouse or finger to the left (anywhere)


81 Python Code Snippets
81 Python Code Snippets for Everyday Problems
POSTED ON DECEMBER 27, 2019 BY JEREMY GRIFSKI
If you’ve been following me for any amount of time, you know that I regularly publish Python code snippets for everyday problems. Well, I figured I’d finally aggregate all those responses in one massive article with links to all those resources.
As a heads up, I’m looking to start porting all of the code snippets in this article to Jupyter Notebooks. If you’re interested in that kind of project, head on over to the GitHub repo. I’d appreciate the help!
Table of Contents
- Table of Contents
- Everyday Problems
- Inverting a Dictionary
- Summing Elements of Two Lists
- Checking if a File Exists
- Converting Two Lists Into a Dictionary
- Checking if a List Is Empty
- Cloning a List
- Retrieving the Last Item of a List
- Making a Python Script Shortcut
- Sorting a List of Strings
- Parsing a Spreadsheet
- Sorting a List of Dictionaries
- Writing a List Comprehension
- Merging Two Dictionaries
- Formatting a String
- Printing on the Same Line
- Testing Performance
- Performing a Reverse Dictionary Lookup
- Checking if a String Contains a Substring
- Share Your Own Problems
Everyday Problems
In this section, we’ll take a look at various common scenarios that arise and how to solve them with Python code. Specifically, I’ll share a brief explanation of the problem with a list of Python code solutions. Then, I’ll link all the resources I have.
Inverting a Dictionary
Sometimes when we have a dictionary, we want to be able to flip its keys and values. Of course, there are concerns like “how do we deal with duplicate values?” and “what if the values aren’t hashable?” That said, in the simple case, there are a few solutions:
1. # Use to invert dictionaries that have unique values
2. my_inverted_dict = dict(map(reversed, my_dict.items()))
4. # Use to invert dictionaries that have unique values
5. my_inverted_dict = {value: key for key, value in my_dict.items()}
7. # Use to invert dictionaries that have non-unique values
8. from collections import defaultdict
9. my_inverted_dict = defaultdict(list)
10. {my_inverted_dict[v].append(k) for k, v in my_dict.items()}
12. # Use to invert dictionaries that have non-unique values
13. my_inverted_dict = dict()
14. for key, value in my_dict.items():
15. my_inverted_dict.setdefault(value, list()).append(key)
17. # Use to invert dictionaries that have lists of values
18. my_dict = {value: key for key in my_inverted_dict for value in my_map[key]}
For more explanation, check out my article titled “How to Invert a Dictionary in Python.” It includes a breakdown of each solution, their performance metrics, and when they’re applicable. Likewise, I have a YouTube video which covers the same topic.
Summing Elements of Two Lists
Let’s say you have two lists, and you want to merge them together into a single list by element. In other words, you want to add the first element of the first list to the first element of the second list and store the result in a new list. Well, there are several ways to do that:
1. ethernet_devices = [1, [7], [2], [8374163], [84302738]]
2. usb_devices = [1, [7], [1], [2314567], [0]]
4. # The long way
5. all_devices = [
6. ethernet_devices[0] + usb_devices[0],
7. ethernet_devices[1] + usb_devices[1],
8. ethernet_devices[2] + usb_devices[2],
9. ethernet_devices[3] + usb_devices[3],
10. ethernet_devices[4] + usb_devices[4]
11. ]
13. # Some comprehension magic
14. all_devices = [x + y for x, y in zip(ethernet_devices, usb_devices)]
16. # Let's use maps
17. import operator
18. all_devices = list(map(operator.add, ethernet_devices, usb_devices))
20. # We can't forget our favorite computation library
21. import numpy as np
22. all_devices = np.add(ethernet_devices, usb_devices)
If you’d like a deeper explanation, check out my article titled “How to Sum Elements of Two Lists in Python” which even includes a fun challenge. Likewise, you might get some value out of my YouTube video on the same topic.
Checking if a File Exists
One of the amazing perks of Python is how easy it is to manage files. Unlike Java, Python has a built-in syntax for file reading and writing. As a result, checking if a file exists is a rather brief task:
1. # Brute force with a try-except block (Python 3+)
2. try:
3. with open('/path/to/file', 'r') as fh:
4. pass
5. except FileNotFoundError:
6. pass
8. # Leverage the OS package (possible race condition)
9. import os
10. exists = os.path.isfile('/path/to/file')
12. # Wrap the path in an object for enhanced functionality
13. from pathlib import Path
14. config = Path('/path/to/file')
15. if config.is_file():
16. pass
As always, you can learn more about these solutions in my article titled “How to Check if a File Exists in Python” which features three solutions and performances metrics.
Converting Two Lists Into a Dictionary
Previously, we talked about summing two lists in Python. As it turns out, there’s a lot we can do with two lists. For example, we could try mapping one onto the other to create a dictionary.
As with many of these problems, there are a few concerns. For instance, what if the two lists aren’t the same size? Likewise, what if the keys aren’t unique or hashable? That said, in the simple case, there are some straightforward solutions:
1. column_names = ['id', 'color', 'style']
2. column_values = [1, 'red', 'bold']
4. # Convert two lists into a dictionary with zip and the dict constructor
5. name_to_value_dict = dict(zip(column_names, column_values))
7. # Convert two lists into a dictionary with a dictionary comprehension
8. name_to_value_dict = {key:value for key, value in zip(column_names, column_values)}
10. # Convert two lists into a dictionary with a loop
11. name_value_tuples = zip(column_names, column_values)
12. name_to_value_dict = {}
13. for key, value in name_value_tuples:
14. if key in name_to_value_dict:
15. pass # Insert logic for handling duplicate keys
16. else:
17. name_to_value_dict[key] = value
Once again, you can find an explanation for each of these solutions and more in my article titled “How to Convert Two Lists Into a Dictionary in Python.” If you are a visual person, you might prefer my YouTube video which covers mapping lists to dictionaries as well.
Checking if a List Is Empty
If you come from a statically typed language like Java or C, you might be bothered by the lack of static types in Python. Sure, not knowing the type of a variable can sometimes be frustrating, but there are perks as well. For instance, we can check if a list is empty by its type flexibility—among other methods:
1. my_list = list()
3. # Check if a list is empty by its length
4. if len(my_list) == 0:
5. pass # the list is empty
7. # Check if a list is empty by direct comparison (only works for lists)
8. if my_list == []:
9. pass # the list is empty
11. # Check if a list is empty by its type flexibility **preferred method**
12. if not my_list:
13. pass # the list is empty
If you’d like to learn more about these three solutions, check out my article titled “How to Check if a List in Empty in Python.” If you’re in a pinch, check out my YouTube video which covers the same topic.
Cloning a List
One of my favorite subjects in programming is copying data types. After all, it’s never easy in this reference-based world we live, and that’s true for Python as well. Luckily, if we want to copy a list, there are a few ways to do it:
1. my_list = [27, 13, -11, 60, 39, 15]
3. # Clone a list by brute force
4. my_duplicate_list = [item for item in my_list]
6. # Clone a list with a slice
7. my_duplicate_list = my_list[:]
9. # Clone a list with the list constructor
10. my_duplicate_list = list(my_list)
12. # Clone a list with the copy function (Python 3.3+)
13. my_duplicate_list = my_list.copy() # preferred method
15. # Clone a list with the copy package
16. import copy
17. my_duplicate_list = copy.copy(my_list)
18. my_deep_duplicate_list = copy.deepcopy(my_list)
20. # Clone a list with multiplication?
21. my_duplicate_list = my_list * 1 # do not do this
When it comes to cloning, it’s important to be aware of the difference between shallow and deep copies. Luckily, I have an article covering that topic.
Finally, you can find out more about the solutions listed above in my article titled “How to Clone a List in Python.” In addition, you might find value in my related YouTube video titled “7 Ways to Copy a List in Python Featuring The Pittsburgh Penguins.”
Retrieving the Last Item of a List
Since we’re on the topic of lists, lets talk about getting the last item of a list. In most languages, this involves some convoluted mathematical expression involving the length of the list. What if I told you there is are several more interesting solutions in Python?
1. my_list = ['red', 'blue', 'green']
3. # Get the last item with brute force using len
4. last_item = my_list[len(my_list) - 1]
6. # Remove the last item from the list using pop
7. last_item = my_list.pop()
9. # Get the last item using negative indices *preferred & quickest method*
10. last_item = my_list[-1]
12. # Get the last item using iterable unpacking
13. *_, last_item = my_list
As always, you can learn more about these solutions from my article titled “How to Get the Last Item of a List in Python” which features a challenge, performance metrics, and a YouTube video.
Making a Python Script Shortcut
Sometimes when you create a script, you want to be able to run it conveniently at the click of a button. Fortunately, there are several ways to do that.
First, we can create a Windows shortcut with the following settings:
1. \path\to\trc-image-titler.py -o \path\to\output
Likewise, we can also create a batch file with the following code:
1. @echo off
2. \path\to\trc-image-titler.py -o \path\to\output
Finally, we can create a bash script with the following code:
1. #!/bin/sh
2. python /path/to/trc-image-titler.py -o /path/to/output
If you’re looking for more explanation, check out the article titled “How to Make a Python Script Shortcut with Arguments.”
Sorting a List of Strings
Sorting is a common task that you’re expected to know how to implement in Computer Science. Despite the intense focus on sorting algorithms in most curriculum, no one really tells you how complicated sorting can actually get. For instance, sorting numbers is straightforward, but what about sorting strings? How do we decide a proper ordering? Fortunately, there are a lot of options in Python:
1. my_list = ["leaf", "cherry", "fish"]
3. # Brute force method using bubble sort
4. my_list = ["leaf", "cherry", "fish"]
5. size = len(my_list)
6. for i in range(size):
7. for j in range(size):
8. if my_list[i] < my_list[j]:
9. temp = my_list[i]
10. my_list[i] = my_list[j]
11. my_list[j] = temp
13. # Generic list sort *fastest*
14. my_list.sort()
16. # Casefold list sort
17. my_list.sort(key=str.casefold)
19. # Generic list sorted
20. my_list = sorted(my_list)
22. # Custom list sort using casefold (>= Python 3.3)
23. my_list = sorted(my_list, key=str.casefold)
25. # Custom list sort using current locale
26. import locale
27. from functools import cmp_to_key
28. my_list = sorted(my_list, key=cmp_to_key(locale.strcoll))
30. # Custom reverse list sort using casefold (>= Python 3.3)
31. my_list = sorted(my_list, key=str.casefold, reverse=True)
If you’re curious about how some of these solutions work, or you just want to know what some of the potential risks are, check out my article titled “How to Sort a List of Strings in Python.”
Parsing a Spreadsheet
One of the more interesting use cases for Python is data science. Unfortunately, however, that means handling a lot of raw data in various formats like text files and spreadsheets. Luckily, Python has plenty of built-in utilities for reading different file formats. For example, we can parse a spreadsheet with ease:
1. # Brute force solution
2. csv_mapping_list = []
3. with open("/path/to/data.csv") as my_data:
4. line_count = 0
5. for line in my_data:
6. row_list = [val.strip() for val in line.split(",")]
7. if line_count == 0:
8. header = row_list
9. else:
10. row_dict = {key: value for key, value in zip(header, row_list)}
11. csv_mapping_list.append(row_dict)
12. line_count += 1
14. # CSV reader solution
15. import csv
16. csv_mapping_list = []
17. with open("/path/to/data.csv") as my_data:
18. csv_reader = csv.reader(my_data, delimiter=",")
19. line_count = 0
20. for line in csv_reader:
21. if line_count == 0:
22. header = line
23. else:
24. row_dict = {key: value for key, value in zip(header, line)}
25. csv_mapping_list.append(row_dict)
26. line_count += 1
28. # CSV DictReader solution
29. import csv
30. with open("/path/to/dict.csv") as my_data:
31. csv_mapping_list = list(csv.DictReader(my_data))
In this case, we try to get our output in a list of dictionaries. If you want to know more about how this works, check out the complete article titled “How to Parse a Spreadsheet in Python.”
Sorting a List of Dictionaries
Once you have a list of dictionaries, you might want to organize them in some specific order. For example, if the dictionaries have a key for date, we can try sorting them in chronological order. Luckily, sorting is another relatively painless task:
1. csv_mapping_list = [
2. {
3. "Name": "Jeremy",
4. "Age": 25,
5. "Favorite Color": "Blue"
6. },
7. {
8. "Name": "Ally",
9. "Age": 41,
10. "Favorite Color": "Magenta"
11. },
12. {
13. "Name": "Jasmine",
14. "Age": 29,
15. "Favorite Color": "Aqua"
16. }
17. ]
19. # Custom sorting
20. size = len(csv_mapping_list)
21. for i in range(size):
22. min_index = i
23. for j in range(i + 1, size):
24. if csv_mapping_list[min_index]["Age"] > csv_mapping_list[j]["Age"]:
25. min_index = j
26. csv_mapping_list[i], csv_mapping_list[min_index] = csv_mapping_list[min_index], csv_mapping_list[i]
28. # List sorting function
29. csv_mapping_list.sort(key=lambda item: item.get("Age"))
31. # List sorting using itemgetter
32. from operator import itemgetter
33. f = itemgetter('Name')
34. csv_mapping_list.sort(key=f)
36. # Iterable sorted function
37. csv_mapping_list = sorted(csv_mapping_list, key=lambda item: item.get("Age"))
All these solutions and more outlined in my article titled “How to Sort a List of Dictionaries in Python.”
Writing a List Comprehension
One of my favorite Python topics to chat about is list comprehensions. As someone who grew up on languages like Java, C/C++, and C#, I had never seen anything quite like a list comprehension until I played with Python. Now, I’m positively obsessed with them. As a result, I put together an entire list of examples:
1. # Define a generic 1D list of constants
2. my_list = [2, 5, -4, 6]
4. # Duplicate a 1D list of constants
5. [item for item in my_list]
7. # Duplicate and scale a 1D list of constants
8. [2 * item for item in my_list]
10. # Duplicate and filter out non-negatives from 1D list of constants
11. [item for item in my_list if item < 0]
13. # Duplicate, filter, and scale a 1D list of constants
14. [2 * item for item in my_list if item < 0]
16. # Generate all possible pairs from two lists
17. [(a, b) for a in (1, 3, 5) for b in (2, 4, 6)]
19. # Redefine list of contents to be 2D
20. my_list = [[1, 2], [3, 4]]
22. # Duplicate a 2D list
23. [[item for item in sub_list] for sub_list in my_list]
25. # Duplicate an n-dimensional list
26. def deep_copy(to_copy):
27. if type(to_copy) is list:
28. return [deep_copy(item) for item in to_copy]
29. else:
30. return to_copy
As always, you can find a more formal explanation of all this code in my article titled “How to Write a List Comprehension in Python.” As an added bonus, I have a YouTube video which shares several examples of list comprehensions.
Merging Two Dictionaries
In this collection, we talk a lot about handling data structures like lists and dictionaries. Well, this one is no different. In particular, we’re looking at merging two dictionaries. Of course, combining two dictionaries comes with risks. For example, what if there are duplicate keys? Luckily, we have solutions for that:
1. yusuke_power = {"Yusuke Urameshi": "Spirit Gun"}
2. hiei_power = {"Hiei": "Jagan Eye"}
3. powers = dict()
5. # Brute force
6. for dictionary in (yusuke_power, hiei_power):
7. for key, value in dictionary.items():
8. powers[key] = value
10. # Dictionary Comprehension
11. powers = {key: value for d in (yusuke_power, hiei_power) for key, value in d.items()}
13. # Copy and update
14. powers = yusuke_power.copy()
15. powers.update(hiei_power)
17. # Dictionary unpacking (Python 3.5+)
18. powers = {**yusuke_power, **hiei_power}
20. # Backwards compatible function for any number of dicts
21. def merge_dicts(*dicts: dict):
22. merged_dict = dict()
23. for dictionary in dicts:
24. merge_dict.update(dictionary)
25. return merged_dict
If you’re interested, I have an article which covers this exact topic called “How to Merge Two Dictionaries in Python” which features four solutions as well performance metrics.
Formatting a String
Whether we like to admit it or not, we often find ourselves burying print statements throughout our code for quick debugging purposes. After all, a well placed print statement can save you a lot of time. Unfortunately, it’s not always easy or convenient to actually display what we want. Luckily, Python has a lot of formatting options:
1. name = "Jeremy"
2. age = 25
4. # String formatting using concatenation
5. print("My name is " + name + ", and I am " + str(age) + " years old.")
7. # String formatting using multiple prints
8. print("My name is ", end="")
9. print(name, end="")
10. print(", and I am ", end="")
11. print(age, end="")
12. print(" years old.")
14. # String formatting using join
15. print(''.join(["My name is ", name, ", and I am ", str(age), " years old"]))
17. # String formatting using modulus operator
18. print("My name is %s, and I am %d years old." % (name, age))
20. # String formatting using format function with ordered parameters
21. print("My name is {}, and I am {} years old".format(name, age))
23. # String formatting using format function with named parameters
24. print("My name is {n}, and I am {a} years old".format(a=age, n=name))
26. # String formatting using f-Strings (Python 3.6+)
27. print(f"My name is {name}, and I am {age} years old")
Keep in mind that these solutions don’t have to be used with print statements. In other words, feel free to use solutions like f-strings wherever you need them.
As always, you can find an explanation of all these solutions and more in my article titled “How to Format a String in Python.” If you’d rather see these snippets in action, check out my YouTube video titled “6 Ways to Format a String in Python Featuring My Cat.”
Printing on the Same Line
Along a similar line as formatting strings, sometimes you just need to print on the same line in Python. As the print
command is currently designed, it automatically applies a newline to the end of your string. Luckily, there are a few ways around that:
1. # Python 2 only
2. print "Live PD",
4. # Backwards compatible (also fastest)
5. import sys
6. sys.stdout.write("Breaking Bad")
8. # Python 3 only
9. print("Mob Psycho 100", end="")
As always, if you plan to use any of these solutions, check out the article titled “How to Print on the Same Line in Python” for additional use cases and caveats.
Testing Performance
Finally, sometimes you just want to compare a couple chunks of code. Luckily, Python has a few straightforward options:
1. # Brute force solution
2. import datetime
3. start_time = datetime.datetime.now()
4. [(a, b) for a in (1, 3, 5) for b in (2, 4, 6)] # example snippet
5. end_time = datetime.datetime.now()
6. print end_time - start_time
8. # timeit solution
9. import timeit
10. min(timeit.repeat("[(a, b) for a in (1, 3, 5) for b in (2, 4, 6)]"))
12. # cProfile solution
13. import cProfile
14. cProfile.run("[(a, b) for a in (1, 3, 5) for b in (2, 4, 6)]")
Again, if you want more details, check the article titled “How to Performance Test Python Code.”
Performing a Reverse Dictionary Lookup
Earlier we talked about reversing a dictionary which is fine in some circumstances. Of course, if our dictionary is enormous, it might not make sense to outright flip the dict. Instead, we can lookup a key based on a value:
1. my_dict = {"color": "red", "width": 17, "height": 19}
2. value_to_find = "red"
4. # Brute force solution (fastest) -- single key
5. for key, value in my_dict.items():
6. if value == value_to_find:
7. print(f'{key}: {value}')
8. break
10. # Brute force solution -- multiple keys
11. for key, value in my_dict.items():
12. if value == value_to_find:
13. print(f'{key}: {value}')
15. # Generator expression -- single key
16. key = next(key for key, value in my_dict.items() if value == value_to_find)
17. print(f'{key}: {value_to_find}')
19. # Generator expression -- multiple keys
20. exp = (key for key, value in my_dict.items() if value == value_to_find)
21. for key in exp:
22. print(f'{key}: {value}')
24. # Inverse dictionary solution -- single key
25. my_inverted_dict = {value: key for key, value in my_dict.items()}
26. print(f'{my_inverted_dict[value_to_find]}: {value_to_find}')
28. # Inverse dictionary solution (slowest) -- multiple keys
29. my_inverted_dict = dict()
30. for key, value in my_dict.items():
31. my_inverted_dict.setdefault(value, list()).append(key)
32. print(f'{my_inverted_dict[value_to_find]}: {value_to_find}')
If this seems helpful, you can check out the source article titled “How to Perform a Reverse Dictionary Lookup in Python“. One of the things I loved about writing this article was learning about generator expressions. If you’re seeing them for the first time, you might want to check it out.
Checking if a String Contains a Substring
One thing I find myself searching more often than I should is the way to check if a string contains a substring in Python. Unlike most programming languages, Python leverages a nice keyword for this problem. Of course, there are also method-based solutions as well:
1. addresses = [
2. "123 Elm Street",
3. "531 Oak Street",
4. "678 Maple Street"
5. ]
6. street = "Elm Street"
8. # Brute force (don't do this)
9. for address in addresses:
10. address_length = len(address)
11. street_length = len(street)
12. for index in range(address_length - street_length + 1):
13. substring = address[index:street_length + index]
14. if substring == street:
15. print(address)
17. # The index method
18. for address in addresses:
19. try:
20. address.index(street)
21. print(address)
22. except ValueError:
23. pass
25. # The find method
26. for address in addresses:
27. if address.find(street) > 0:
28. print(address)
30. # The in keyword (fastest/preferred)
31. for address in addresses:
32. if street in address:
33. print(address)
If you’re like me and forget about the in
keyword, you might want to bookmark the “How to Check if a String Contains a Substring” article.
Share Your Own Problems
As you can see, this article and its associated series is already quite large. That said, I’d love to continue growing them. As a result, you should consider sharing some of your own problems. After all, there has be something you Google regularly. Why not share it with us?
In the meantime, help grow this collection by hopping on my newsletter, visiting the shop, subscribing to my YouTube channel, and/or becoming a patron. In addition, you’re welcome to browse the following related articles:
Otherwise, thanks for stopping by! I appreciate the support.
Reference : https://therenegadecoder.com.