CONTENDER, THE (director/writer: Rod Lurie; cinematographer: Denis Maloney; editor: Michael Jablow; cast: Gary Oldman (Shelly Runyon), Joan Allen (Laine Hanson), Jeff Bridges (President Jackson Evans), Christian Slater (Reginald Webster), Sam Elliott (Kermit Newman), William Petersen (Jack Hathaway), Saul Rubinek (Jerry Toliver), Philip Baker Hall (Oscar Billings), Kristen Shaw (Fiona Hathaway), Robin Thomas (William Hanson), Mariel Hemingway (Cynthia Lee), Mike Binder (Lewis Hollis); Runtime: 132; DreamWorks Pictures; 2000)
Reviewed by Dennis Schwartz
A thrilling but shamelessly manipulative political thriller, the second feature dealing with presidential politics from the director who was once a film critic, Rod Lurie (Deterrence). He has vastly honed his skills as a filmmaker in comparison with his debut film, which was a failure artistically and commercially.
"The Contender" is a film that is grounded in having a clear understanding of how politically underhanded and sly the system is and how those in it operate on a level that would make Machiavelli proud of them.
I was taken aback by how great the entire ensemble cast is, with the leads being superb in getting the maximum out of their juicy roles, even if they have to chew the scenery to do it. The cast is so good that it overcomes the shrill oratory, the manipulative, obvious and unbelievable political situations, and an ending that tries to play it so safe, that it takes away the juice in the story that gave this film its power in the first place. I thoroughly enjoyed it, even though I knew it was a manipulative film, trying to get me to bite at its revelations about the double-standards between men and women politicians, without giving me a fair chance to swallow everything without choking on what I was asked to swallow.
The film opens as President Jackson Evans (Jeff Bridges), a Bill Clinton type, is shown to be a politically savvy politician, more interested in working his political skills than he is in standing up for his issues. The film's running gag being that he's a glutton for food, which he spends more time at than on anything else, trying to test the White House kitchen staff by ordering exotic foods to see if he can catch them empty- handed. This only occurs when he orders something ordinary -- a Muenster cheese sandwich.
Due to the sudden death of the current VP, President Evans has to pick someone to fill the vacancy. The leading contender for the post is the ambitious governor of Virginia, Jack Hathaway (William Petersen), a loyal Democrat and a noted patriot, who is egged on to be more assertive by his shrewish wife (Kristen Shaw). He becomes a hero in one of the opening scenes, even though the woman he tried to save dies anyway.  There was something about that action that didn't seem right. It will later on play an important part in the film's plot.
The President's choice for vice president is Laine Hanson (Joan Allen), an Ohio senator and a daughter of a former Republican governor. She is pro-choice, an atheist who recently switched parties from Republican to Democrat, and is an articulate, poised, and attractive candidate. She is divorced and currently married to her former campaign manager (Robin Thomas), and is the mother of a 6-year-old boy. The President taps her for the job because he wants to leave a legacy that he was the one who chose the first woman to hold that office.
In an interesting scene, she consults with her father (Philip Baker Hall) for his approval and advice, realizing that she will have a fight on her hands from the disappointed Hathaway.  She receives the President's phone call, offering her the position, when she is in the middle of having sex with her husband. The film pulls no punches about her being active sexually. It makes the viewer face the fact that a woman in high office is still a woman and has to be accepted just like a man in that position would be.
The heart of the film is the fight over her confirmation and all the backroom manuevering to get her the job. She faces opposition from Sheldon Runyon (Gary Oldman), the powerful McCarthyite-like congressman who will chair the confirmation hearings. Runyon is opposed to Hanson's nomination because he wants to get even with the President for some other political battles they had and because he doesn't like her or her views. He finds ammunition for his opposition when he runs a private investigation on her, ala Starr, and finds evidence that when she was in college pledging for a sorority, she was allegedly having sex with two boys at a fraternity house as part of the initiation. He comes armed with photos of her in action and eyewitnesses. He even leaks the story to the Internet, which posts the pictures so that television and the tabloids can pick it up. Hanson refuses to comment on the issue, taking the high moral ground, saying it is no one's business but her own.
A sidebar to the story is about a 28-year-old freshman congressman from the small state of Delaware, Reginald Webster (Slater), who worms his way onto Runyon's powerful committteee by promising to support him 100 percent. He is supposed to be a young Bill Clinton-type, first starting his climb to the top. When he sees the sleazy direction the confirmation hearings are going in and when called into the President's office to be bullied by him, he is overawed by the power of the office, and he begins to have some pangs of conscience. The President is shown as being figuratively and literally a shark-eater, as he is eating a shark sandwich when conferring with Webster.
Senator Hanson is seen as both a liberal and a vegetarian. This is underscored when she has a courtesy luncheon date about her confirmation with the steak eating right-wing chairman Runyon and orders a spicy pasta dish, despite his insistence that she better eat voraciously like he does if she wants to get power in Washington.
The story in itself is more soap opera than drama, but what gives it verve is the super performances from the three stars, Jeff Bridges, Gary Oldman, and Joan Allen. They give depth to their roles and they are all seen in many different lights and shades. Jeff Bridges steals every scene he is in, offering a fascinating look at a president who could be likable though sinister, sneakily clever, and also very politically human in a generous and gracious way. He was thoroughly believable as an updated Bill Clinton-type, post-Lewinsky.
In a supporting role, as an advisor to the President, Kermit Newman (Sam Elliott), makes his presence felt in a very forceful performance as the political realist who has the President's ear but knows when to stop giving advice and follow his leader.
 The film was fascinating when it didn't have a message to deliver with some bogus pat speech and, instead, set up a logical argument showing that Senator Hanson should be confirmed for office despite allegations of her youthful sex scandal.
REVIEWED ON 11/2/2000 GRADE: B
Dennis Schwartz: "Ozus' World Movie Reviews"
http://www.sover.net/~ozus
<EMAIL_ADDRESS>© ALL RIGHTS RESERVED DENNIS SCHWARTZ
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


--- layout: withmenu ---
We are honoured to have you come celebrate with us! Please do not feel obliged to give us a gift. For those who have asked for suggestions, we are registered at the following sites:


Header fields involved in the handshake are:
Sequence number
Acknowledgement numbers
SYN and ACK flags
The steps in the handshake are used to synchronize the sequence and acknowledgement numbers between the server and the client.
Client Server
| -> SYN |
| Seq: 329 Ack: 0 |
| |
| <- SYN/ACK |
| Seq: 498 Ack: 330 |
| |
| -> ACK |
| Seq: 330 Ack: 449 |


Round one
current score is zero
How many pins was hit in the first role?
Please Select your first role.
0
1
2
3
4
5
6
7
8
9
10
How many pins was hit in the second role.
How many pins was hit in the second role.
Submit
Please Select the award role.
0
1
2
3
4
5
6
7
8
9
10
Submit
Please Select the award role.
0
1
2
3
4
5
6
7
8
9
10
Please Select the award role.
0
1
2
3
4
5
6
7
8
9
10
Submit
The final score is
ZERO


[ aws . elasticbeanstalk ]
Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new configuration template, or updates select configuration option values in the running environment.
Attempting to update both the release and configuration is not allowed and AWS Elastic Beanstalk returns an InvalidParameterCombination error.
When updating the configuration settings to a new template or individual settings, a draft configuration is created and describe-configuration-settings for this environment returns two setting descriptions with different DeploymentStatus values.
See also: AWS API Documentation
update-environment
[--application-name <value>]
[--environment-id <value>]
[--environment-name <value>]
[--group-name <value>]
[--description <value>]
[--tier <value>]
[--version-label <value>]
[--template-name <value>]
[--solution-stack-name <value>]
[--platform-arn <value>]
[--option-settings <value>]
[--options-to-remove <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
The name of the application with which the environment is associated.
The ID of the environment to update.
If no environment with this ID exists, AWS Elastic Beanstalk returns an InvalidParameterValue error.
Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error.
The name of the environment to update. If no environment with this name exists, AWS Elastic Beanstalk returns an InvalidParameterValue error.
Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error.
The name of the group to which the target environment belongs. Specify a group name only if the environment's name is specified in an environment manifest and not with the environment name or environment ID parameters. See Environment Manifest (env.yaml) for details.
If this parameter is specified, AWS Elastic Beanstalk updates the description of this environment.
This specifies the tier to use to update the environment.
Condition: At this time, if you change the tier version, name, or type, AWS Elastic Beanstalk returns InvalidParameterValue error.
Shorthand Syntax:
Name=string,Type=string,Version=string
JSON Syntax:
{
"Name": "string",
"Type": "string",
"Version": "string"
}
If this parameter is specified, AWS Elastic Beanstalk deploys the named application version to the environment. If no such application version is found, returns an InvalidParameterValue error.
If this parameter is specified, AWS Elastic Beanstalk deploys this configuration template to the environment. If no such configuration template is found, AWS Elastic Beanstalk returns an InvalidParameterValue error.
--solution-stack-name (string)
This specifies the platform version that the environment will run after the environment is updated.
The ARN of the platform, if used.
If specified, AWS Elastic Beanstalk updates the configuration set associated with the running environment and sets the specified configuration options to the requested value.
Shorthand Syntax:
ResourceName=string,Namespace=string,OptionName=string,Value=string ...
JSON Syntax:
[
{
"ResourceName": "string",
"Namespace": "string",
"OptionName": "string",
"Value": "string"
}
...
]
A list of custom user-defined configuration options to remove from the configuration set for this environment.
Shorthand Syntax:
ResourceName=string,Namespace=string,OptionName=string ...
JSON Syntax:
[
{
"ResourceName": "string",
"Namespace": "string",
"OptionName": "string"
}
...
]
--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values.
--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.
To update an environment to a new version
The following command updates an environment named "my-env" to version "v2" of the application to which it belongs:
aws elasticbeanstalk update-environment --environment-name my-env --version-label v2
This command requires that the "my-env" environment already exists and belongs to an application that has a valid application version with the label "v2".
Output:
{
"ApplicationName": "my-app",
"EnvironmentName": "my-env",
"VersionLabel": "v2",
"Status": "Updating",
"EnvironmentId": "e-szqipays4h",
"EndpointURL": "awseb-e-i-AWSEBLoa-1RDLX6TC9VUAO-0123456789.us-west-2.elb.amazonaws.com",
"SolutionStackName": "64bit Amazon Linux running Tomcat 7",
"CNAME": "my-env.elasticbeanstalk.com",
"Health": "Grey",
"Tier": {
"Version": " ",
"Type": "Standard",
"Name": "WebServer"
},
"DateUpdated": "2015-02-03T23:12:29.119Z",
"DateCreated": "2015-02-03T23:04:54.453Z"
}
To set an environment variable
The following command sets the value of the "PARAM1" variable in the "my-env" environment to "ParamValue":
aws elasticbeanstalk update-environment --environment-name my-env --option-settings Namespace=aws:elasticbeanstalk:application:environment,OptionName=PARAM1,Value=ParamValue
The option-settings parameter takes a namespace in addition to the name and value of the variable. Elastic Beanstalk supports several namespaces for options in addition to environment variables.
To configure option settings from a file
The following command configures several options in the aws:elb:loadbalancer namespace from a file:
aws elasticbeanstalk update-environment --environment-name my-env --option-settings file://options.json
options.json is a JSON object defining several settings:
[
{
"Namespace": "aws:elb:healthcheck",
"OptionName": "Interval",
"Value": "15"
},
{
"Namespace": "aws:elb:healthcheck",
"OptionName": "Timeout",
"Value": "8"
},
{
"Namespace": "aws:elb:healthcheck",
"OptionName": "HealthyThreshold",
"Value": "2"
},
{
"Namespace": "aws:elb:healthcheck",
"OptionName": "UnhealthyThreshold",
"Value": "3"
}
]
Output:
{
"ApplicationName": "my-app",
"EnvironmentName": "my-env",
"VersionLabel": "7f58-stage-150812_025409",
"Status": "Updating",
"EnvironmentId": "e-wtp2rpqsej",
"EndpointURL": "awseb-e-w-AWSEBLoa-14XB83101Q4L-104QXY80921.sa-east-1.elb.amazonaws.com",
"SolutionStackName": "64bit Amazon Linux 2015.03 v2.0.0 running Tomcat 8 Java 8",
"CNAME": "my-env.elasticbeanstalk.com",
"Health": "Grey",
"AbortableOperationInProgress": true,
"Tier": {
"Version": " ",
"Type": "Standard",
"Name": "WebServer"
},
"DateUpdated": "2015-08-12T18:15:23.804Z",
"DateCreated": "2015-08-07T20:48:49.599Z"
}
For more information about namespaces and supported options, see Option Values in the AWS Elastic Beanstalk Developer Guide.
EnvironmentName -> (string)
The name of this environment.
EnvironmentId -> (string)
The ID of this environment.
ApplicationName -> (string)
The name of the application associated with this environment.
VersionLabel -> (string)
The application version deployed in this environment.
SolutionStackName -> (string)
The name of the SolutionStack deployed with this environment.
PlatformArn -> (string)
The ARN of the custom platform.
TemplateName -> (string)
The name of the configuration template used to originally launch this environment.
Description -> (string)
Describes this environment.
EndpointURL -> (string)
For load-balanced, autoscaling environments, the URL to the LoadBalancer. For single-instance environments, the IP address of the instance.
CNAME -> (string)
The URL to the CNAME for this environment.
DateCreated -> (timestamp)
The creation date for this environment.
DateUpdated -> (timestamp)
The last modified date for this environment.
Status -> (string)
The current operational status of the environment:
- Launching : Environment is in the process of initial deployment.
- Updating : Environment is in the process of updating its configuration settings or application version.
- Ready : Environment is available to have an action performed on it, such as update or terminate.
- Terminating : Environment is in the shut-down process.
- Terminated : Environment is not running.
AbortableOperationInProgress -> (boolean)
Indicates if there is an in-progress environment configuration update or application version deployment that you can cancel.
true: There is an update in progress.
false: There are no updates currently in progress.
Health -> (string)
Describes the health status of the environment. AWS Elastic Beanstalk indicates the failure levels for a running environment:
- Red : Indicates the environment is not responsive. Occurs when three or more consecutive failures occur for an environment.
- Yellow : Indicates that something is wrong. Occurs when two consecutive failures occur for an environment.
- Green : Indicates the environment is healthy and fully functional.
- Grey : Default health for a new environment. The environment is not fully launched and health checks have not started or health checks are suspended during an update-environment or RestartEnvironement request.
Default: Grey
HealthStatus -> (string)
Returns the health status of the application running in your environment. For more information, see Health Colors and Statuses .
Resources -> (structure)
The description of the AWS resources used by this environment.
LoadBalancer -> (structure)
Describes the LoadBalancer.
LoadBalancerName -> (string)
The name of the LoadBalancer.Domain -> (string)
The domain name of the LoadBalancer.Listeners -> (list)
A list of Listeners used by the LoadBalancer.
(structure)
Describes the properties of a Listener for the LoadBalancer.
Protocol -> (string)
The protocol that is used by the Listener.Port -> (integer)
The port that is used by the Listener.
Tier -> (structure)
Describes the current tier of this environment.
Name -> (string)
The name of this environment tier.Type -> (string)
The type of this environment tier.Version -> (string)
The version of this environment tier.
EnvironmentLinks -> (list)
A list of links to other environments in the same group.
(structure)
A link to another environment, defined in the environment's manifest. Links provide connection information in system properties that can be used to connect to another environment in the same group. See Environment Manifest (env.yaml) for details.
LinkName -> (string)
The name of the link.EnvironmentName -> (string)
The name of the linked environment (the dependency).


| Exported Interfaces - Summary |
| ::com::sun::star::lang::XInitialization |
A Package can be initialised with one of the following:
1. A file URL referring to a package.
2. An XInputStream referring to a package (it must also
support an XSeekable interface).
3. An XStream referring to a package. The XInputStream must support
an XSeekable interface, and the XOutputStream must support an
XTruncate interface.
It will throw a css::uno::Exception if initialised with bad data or
if the package has an invalid format (for example, a corrupt central d
irectory record if the file is a ZIP file).
|
| ::com::sun::star::container::XHierarchicalNameAccess |
This interface is used to get access to any entry within the package
For example:
getByHierarchicalName ("folder/subfolder/file1.txt");
This will return a PackageStream which refers to the specified stream.
This is also used to get access to a particular folder within the
Package. For example:
getByHierarchicalName ("folder/subfolder/");
This will return a PackageFolder which describes the contents of the specified
folder.
Calls to methods of XHierarchicalNameAccess must NOT have a leading slash.
|
| ::com::sun::star::lang::XSingleServiceFactory |
This interface is used to create new PackageStream or PackageFolder
implementation objects for addition to the Package.
createInstance - creates a new stream implementation object (when first
created, the new object is not part of the Package). It must be added
to the PackageFolder in which it will reside using the methods in the
PackageFolder service.
createInstanceWithArguments - This accepts one boolean value as an
argument. If it set to true, a PackageFolder implementation is created,
if it is set to false, a PackageStream implementation is created.
Creating and inserting a new stream would be done as follows:
1. xNewStream = package->createInstanceWithArguments( false );
2. xDataStream = new MyStreamImpl(). (wherever the data comes from)
3. xNewStream->setInputStream( xDataStream );
4. parentFolder->insertByName( "image.png", xNewStream );
Replacing an existing stream would be very similar, except that the
call ->insertByName would be replaced by ->replaceByName.
|
| ::com::sun::star::util::XChangesBatch |
This interface is used to commit any changes to the Package. A new
Package file will be written with any new or changed streams/folders and
omitting any PackageStream or PackageFolder that has been removed.
|
| Exported Interfaces - Details |
::com::sun::star::lang::XInitialization
- Description
- A Package can be initialised with one of the following:
1. A file URL referring to a package.
2. An XInputStream referring to a package (it must also
support an XSeekable interface).
3. An XStream referring to a package. The XInputStream must support
an XSeekable interface, and the XOutputStream must support an
XTruncate interface.
It will throw a css::uno::Exception if initialised with bad data or
if the package has an invalid format (for example, a corrupt central d
irectory record if the file is a ZIP file).
|
|
::com::sun::star::container::XHierarchicalNameAccess
- Description
- This interface is used to get access to any entry within the package
For example:
getByHierarchicalName ("folder/subfolder/file1.txt");
This will return a PackageStream which refers to the specified stream.
This is also used to get access to a particular folder within the
Package. For example:
getByHierarchicalName ("folder/subfolder/");
This will return a PackageFolder which describes the contents of the specified
folder.
Calls to methods of XHierarchicalNameAccess must NOT have a leading slash.
|
|
::com::sun::star::lang::XSingleServiceFactory
- Description
- This interface is used to create new PackageStream or PackageFolder
implementation objects for addition to the Package.
createInstance - creates a new stream implementation object (when first
created, the new object is not part of the Package). It must be added
to the PackageFolder in which it will reside using the methods in the
PackageFolder service.
createInstanceWithArguments - This accepts one boolean value as an
argument. If it set to true, a PackageFolder implementation is created,
if it is set to false, a PackageStream implementation is created.
Creating and inserting a new stream would be done as follows:
1. xNewStream = package->createInstanceWithArguments( false );
2. xDataStream = new MyStreamImpl(). (wherever the data comes from)
3. xNewStream->setInputStream( xDataStream );
4. parentFolder->insertByName( "image.png", xNewStream );
Replacing an existing stream would be very similar, except that the
call ->insertByName would be replaced by ->replaceByName.
|
|
::com::sun::star::util::XChangesBatch
- Description
- This interface is used to commit any changes to the Package. A new
Package file will be written with any new or changed streams/folders and
omitting any PackageStream or PackageFolder that has been removed.
|
|
Copyright © 2013, The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.


To add a dynamic form to your Wicket application simply create an object of type FormModel and configure it by adding input fields, validators, hint texts and so on in pure Java. Just follow these steps:
You define the structure and contents of your form dynamically at runtime by creating an object of type FormModel. Follow the links in the navigation menu for examples. Each example provides a "Show Java Code" Button that diplays the source code. The following example creates a form with a section containing a single text field:
FormModel myForm = new FormModel("Form Title"); myForm.add(new SectionModel("Section Title") .add(new TextFieldModel<String>("Text Field Label", String.class)));
To include the form in you page, add a div (or any other container tag) to your HTML markup and provide a wicket:id. If you know Wicket, this is nothing new.
<div wicket:id="myForm"/>
Wicked Forms provides the FormPanel class that can be added to the Java class of a Wicket page like this (again, if you know Wicket, this should be familiar):
add(new FormPanel("myForm", myForm));
That's it.
Forms are useless if you cannot process the user's input. Thus, each form element can be bound to an arbitrary java object that stores the user's input. This concept is very similar to (and inspired by) Wicket's model concept, so if you know Wicket you will feel at home.
The Binding interface is a simple interface that allows to get and set a value of a certain type. Very similar to Wicket's IModel interface. All form elements have a constructor that expects a Binding implementation as parameter. That Binding connects the user input to the Java object that backs the Binding.
The simplest possible implementation of the Binding interface is SimpleBinding. It is used implicitly if no Binding implementation is passed to a form element. You won't really need to use it.
A PropertyBinding binds the user input of a form element to an instance variable of a Java object. The following code binds the input of a text field to the "name" property of a Person object:
Person person = new Person(); person.setName("Tom"); Binding binding = new PropertyBinding(person, "name"); StringTextFieldModel textField = new StringTextFieldModel("Label", binding)));
You are free to create your own implementations of the Binding interface that suite your project's needs. If you come up with implementations that may be of benefit to others, let us know and we will incorporate them into Wicket Forms :).


--- layout: post title: Bitten a lot by a bitlybot date: 2010-06-22 00:29:14.000000000 +01:00 type: post published: true status: publish categories: - web tags: - bad coding - bitly - bitlybot meta: _topsy_cache_timestamp: '1299686050' _syntaxhighlighter_encoded: '1' _topsy_long_url: /2010/06/22/bitten-a-lot-by-a-bitlybot/ topsy_short_url: http://bit.ly/a81ZZF _wp_old_slug: ouch-website-bitten-a-lot-by-a-bitlybot _oembed_eb07d48f32e64e669856aa7509ae3865: "{{unknown}}" _oembed_ac3af0ae3eb1860cb3f8595c09a9e697: "{{unknown}}" _oembed_eaecdc692d1553534827c913833c4943: "{{unknown}}" _edit_last: '1' _oembed_4d0de38eb038d2d5f2ef1fc3a03fbdcc: "{{unknown}}" _oembed_4bbc088aaaecbece70f0cbb1846aec5e: "{{unknown}}" _oembed_a50ebd2eee6c596933a7b5777e7189ec: "{{unknown}}" tmac_last_id: '618797392976973824' _oembed_5696d3db9bc5f33d1fdd8aff5867da6b: "{{unknown}}" _oembed_474619960e7a198bf99fa437b63e4177: "{{unknown}}" _oembed_c403d5a23c7bbda223dde8a4af207740: "{{unknown}}" _oembed_9a804cf1659c110bd53670fc28728f12: "{{unknown}}" _oembed_361384338013630f4c98684058614fb6: "{{unknown}}" _oembed_1ac7d492e2d2d16c9a190e3800ecd6ba: "{{unknown}}" author: David Simpson excerpt_separator: ---
This website and one or two others I run recently experienced what appeared to be a denial-of-service attack.
Looking at the access logs, I could see several tens of thousands of requests all originating from a range of amazonaws.com IP addresses. All with the useragent "bitlybot".
This post is a quick postmortem of what went wrong and why.
I've been happily using the excellent bit.ly URL shortening API on the Readability Test Tool website for over a year with no problems at all. Whenever a user checks the readability of a web page using the Readability Test Tool, a convenient "tweet this" link is provided for the results page.
My bit.ly link also innocently appended a query string — &utm_source=twitter&utm_medium=retweet — so that I can track click-throughs from Twitter in Google Analytics.
Looking back at this, it wasn't that clever a thing to do, but it only took a couple of minutes to implement, so was very little effort for a nice bit of analytics/measurement return.
All was good for a year. Google Analytics tracking worked well. There were no problems. Indeed looking back at the access logs, the bitlybot user agent had not so much as sniffed the website once in that time.
One day, something changed. Overnight bitlybot started crawling my website for all the links it had created over the year. Unfortunately for every link it crawl, it also created another link appending more parameters to the query string.
Which it then crawled. Creating another link with more appended query parameters. Ouch.
e.g.
http://www.read-able.com/check.php?uri=http%3A%2F%2Fwww.example.com%2F&utm_source=twitter&utm_medium=retweet
http://www.read-able.com/check.php?uri=http%3A%2F%2Fwww.example.com%2F&utm_source=twitter&utm_medium=retweet&utm_source=twitter&utm_medium=retweet
http://www.read-able.com/check.php?uri=http%3A%2F%2Fwww.example.com%2F&utm_source=twitter&utm_medium=retweet&utm_source=twitter&utm_medium=retweet&utm_source=twitter&utm_medium=retweet
And so on.
Initially I ranted on Twitter.
Then I removed the "tweet this" link to prevent further bit.ly URLs from being created. This wouldn't stop things for while, but would at least prevent the problem from getting any worse.
Then I edited robots.txt:
# Tell "bitlybot" not to come here at all
User-agent: bitlybot
Disallow: /
This did not work - bitlybot only checks robots.txt once a day, so this would not improve matters instantly.
Then I redirected the traffic to bit.ly:
language="php"]
if ($_SERVER['HTTP_USER_AGENT'] == 'bitlybot')
{
header('Location: http://bit.ly/', true, 301);
}
That slowed it a bit. Admittedly, I was still blaming them at this point.
Then I reached out to @bitly.
They were very responsive. I sent them a detailed email with a section of access logs and they fixed it. Quickly.
They disabled my account, preventing me from causing any further mischief. They stopped bitlybot from it's crawling activity and reported the progress back to me.
Each contact with bit.ly via twitter or email resulted in a positive response — they were very quick to respond and my websites were soon back to their usual somewhat diminutive volume of traffic.


About
Currently learning Web Development at Codefellows.org - Coding 201 and 301.
Follow me on twitter.
check out my projects on github
Github Repositories
- Coding Projects Go Here
Projects
Skills
- HTML5
- CSS3
- ECMAScript
- jQuery
- Firebase
- Chart.js
Experience
- Microsoft, Seattle, WA
- Codefellows 201
- Codefellows 301


{% extends "common/templates/email/base.html" %} {% load format %} {% block body %}
{{owner_full_name}} ({{owner_ref.display_nick}}) is now following your {{POST_NAME|plural}} on {{SITE_NAME}}!
You may also follow the {{POST_NAME|plural}} of ({{owner_ref.display_nick}}) by clicking on the "follow" button on their profile {{email_url}}
{% endblock %}


Aphid
A lightweight MQTT 3.1.1 client written in pure Swift 3
Features:
- [x] MQTT 3.1
- [x] MQTT 3.1.1
- [x] LWT
- [x] SSL/TLS
- [ ] Message Persistence
- [ ] Automatic Reconnect
- [ ] Offline Buffering
- [ ] WebSocket Support
- [x] Standard TCP Support
- [x] Non-Blocking API
- [ ] Blocking API
- [ ] High Availability
Installing and using on the Raspberry Pi 3:
Unfortunately there are some issues with the Swift Package Manager and Dispatch library that requires a lot of manual steps for your application to build. For a working set of steps, please refer to:
Compiling an Aphid application on the Raspberry Pi 3
Setup your project to use Aphid
Requires
swift-DEVELOPMENT-SNAPSHOT-2016-09-03-a toolchain
(Minimum REQUIRED for latest release)
- Install OpenSSL:
- macOS: `brew install openssl`
- Ubuntu Linux: `sudo apt-get install openssl`
In Package.swift, add Aphid as a dependency for your project.
import PackageDescription
let package = Package(
name: "ProjectName",
dependencies: [
.Package(url: "https://github.com/IBM-Swift/Aphid.git", majorVersion: 0, minor: 2)
])
Create XCode project to build library (Optional)
$ swift package generate-xcodeproj \
-Xswiftc -I/usr/local/opt/openssl/include \
-Xlinker -L/usr/local/opt/openssl/lib
In Sources/main.swift, import the Aphid module.
import Aphid
Note
build locally with:
- macOS: `swift build -Xcc -I/usr/local/opt/openssl/include -Xlinker -L/usr/local/opt/openssl/lib`
- Linux: `swift build -Xcc -fblocks`
Examples
Example usage can be found in our AphidClient Repository
MQTT brokers
There are several MQTT brokers you can use remotely such as the IBM IoT Foundation on Bluemix.
If testing locally, we recommend the Mosquitto broker:
- macOS: `brew install mosquitto`
- Ubuntu Linux: `apt-get install mosquitto`
License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.


Are we using the buggy imlib_image_draw_pixel() work-around?
Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.
Examples:
puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround? puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?
Are we using the buggy imlib_image_draw_pixel() work-around?
Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.
Examples:
puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround? puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?
Returns a new Imlib2::Image with the specified width and height.
Examples:
width, height = 640, 480 image = Imlib2::Image.new width, height width, height = 320, 240 image = Imlib2::Image.create width, height
Returns a new Imlib2::Image initialized with the specified data.
Examples:
other_image = Imlib2::Image.load 'sample_file.png' width, height = other_image.width, other_image.height data = other_image.data image = Imlib2::Image.create_using_copied_data width, height, data
Returns a new Imlib2::Image initialized with the specified data.
Examples:
other_image = Imlib2::Image.load 'sample_file.png' width, height = other_image.width, other_image.height data = other_image.data_for_reading_only image = Imlib2::Image.create_using_data width, height, data
Are we using the buggy imlib_image_draw_pixel() work-around?
Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.
Examples:
puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround? puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?
Are we using the buggy imlib_image_draw_pixel() work-around?
Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. This method allows you to check whether the work-around behavior is enabled.
Examples:
puts 'work-around is enabled' if Imlib2::Image::draw_pixel_workaround? puts 'work-around is enabled' if Imlib2::Image::bypass_draw_pixel?
Load an Imlib2::Image from a file (throws exceptions).
Examples:
image = Imlib2::Image.load 'sample_file.png' begin image = Imlib2::Image.load 'sample_file.png' rescue Imlib2::FileError $stderr.puts 'Couldn't load file: ' + $! end
Load an Imlib2::Image from a file (no exceptions or error).
Imlib2::Image::load_image() provides access to the low-level imlib_load_image() function. You probably want to use Imlib2::Image::load() instead of Imlib2::Image::load_image().
Examples:
image = Imlib2::Image.load_image 'sample_file.png'
Load an Imlib2::Image from a file (no exceptions or error).
Imlib2::Image::load_immediately() provides access to the low-level imlib_load_image_immediately() function. You probably want to use Imlib2::Image::load() instead of this function.
Examples:
image = Imlib2::Image.load_immediately 'sample_file.png'
Load an Imlib2::Image from a file (no caching, deferred loading, exceptions, or errors).
Imlib2::Image::load_immediately_without_cache() provides access to the low-level imlib_load_image_immediately_without_cache() function. You probably want to use Imlib2::Image::load() instead of this function.
Examples:
image = Imlib2::Image.load_immediately_without_cache 'sample_file.png'
Load an Imlib2::Image from a file with a hash of the error value and the image.
Imlib2::Image::load_with_error_return() provides access to the low-level imlib_load_image_with_error_return() function. You probably want to use Imlib2::Image::load() instead of this function.
Examples:
hash = Imlib2::Image.load_with_error_return 'sample_file.png' if hash['error'] == 0 # 0 is no error image = hash['image'] end
Load an Imlib2::Image from a file (no caching, exception, or error).
Imlib2::Image::load_without_cache() provides access to the low-level imlib_load_image_without_cache() function. You probably want to use Imlib2::Image::load() instead of this function.
Examples:
image = Imlib2::Image.load_without_cache 'sample_file.png'
Returns a new Imlib2::Image with the specified width and height.
Examples:
width, height = 640, 480 image = Imlib2::Image.new width, height width, height = 320, 240 image = Imlib2::Image.create width, height
Get an integer value attached to an Imlib2::Image.
Examples:
qual = image.get_attached_value('quality') qual = image['quality']
Attach an integer value to an Imlib2::Image.
Examples:
image.attach_value('quality', 90) image['quality'] = 90
Apply an Imlib2::ColorModifier to the image
Examples:
# modify the contrast of the entire image cmod = Imlib2::ColorModifier.new cmod.contrast = 1.5 image.apply_cmod color_mod # adjust the gamma of the given rect cmod = Imlib2::ColorModifier.new cmod.gamma = 0.5 rect = [10, 10, 20, 40] image.apply_color_modifier cmod, rect
Apply an Imlib2::ColorModifier to the image
Examples:
# modify the contrast of the entire image cmod = Imlib2::ColorModifier.new cmod.contrast = 1.5 image.apply_cmod color_mod # adjust the gamma of the given rect cmod = Imlib2::ColorModifier.new cmod.gamma = 0.5 rect = [10, 10, 20, 40] image.apply_color_modifier cmod, rect
Apply an Imlib2::ColorModifier to the image
Examples:
# modify the contrast of the entire image cmod = Imlib2::ColorModifier.new cmod.contrast = 1.5 image.apply_cmod color_mod # adjust the gamma of the given rect cmod = Imlib2::ColorModifier.new cmod.gamma = 0.5 rect = [10, 10, 20, 40] image.apply_color_modifier cmod, rect
Apply a scripted filter or a static (eg Imlib2::Filter) filter
Example:
# apply a static filter filter = Imlib2::Filter.new 20 filter.set 2, 2, Imlib2::Color::GREEN image.filter filter # apply a scripted filter x, y = 20, 10 filter_string = "tint( x=#{x}, y=#{y}, red=255, alpha=55 );" image.filter filter_string
Attach an integer value to an Imlib2::Image.
Examples:
image.attach_value('quality', 90) image['quality'] = 90
Return a copy of the image with the a portion of the source image blended at the specified rectangle.
Examples:
src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend source_image, src_rect, dst_rect, merge_alpha src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend_image source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend_image source_image, src_rect, dst_rect, merge_alpha
Blend a source image onto the image
Examples:
src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend! source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend! source_image, src_rect, dst_rect, merge_alpha src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend_image! source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend_image! source_image, src_rect, dst_rect, merge_alpha
Return a copy of the image with the a portion of the source image blended at the specified rectangle.
Examples:
src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend source_image, src_rect, dst_rect, merge_alpha src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend_image source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend_image source_image, src_rect, dst_rect, merge_alpha
Blend a source image onto the image
Examples:
src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend! source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend! source_image, src_rect, dst_rect, merge_alpha src_x, src_y, src_w, src_h = 10, 10, 100, 100 dst_x, dst_y, dst_w, dst_h = 10, 10, 50, 50 image.blend_image! source_image, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h src_rect = [50, 50, 5, 5] dst_rect = [0, 0, image.width, image.height] merge_alpha = false image.blend_image! source_image, src_rect, dst_rect, merge_alpha
Return a blurred copy of an image
Examples:
radius = 20 # radius of blur, in pixels new_image = old_image.blur radius
Get the Imlib2::Border of an Imlib2::Image
Examples:
border = image.get_border border = image.border
Fill a rectangle with the given Imlib2::Gradient at a given angle
Examples:
x, y, w, h = 10, 10, image.width - 20, image.height - 20 angle = 45.2 image.fill_gradient gradient, x, y, w, h, angle rect = [5, 5, 500, 20] image.gradient gradient, rect, 36.8
Copy the alpha channel from the source image to the specified coordinates
Examples:
image.copy_alpha source_image, 10, 10 image.copy_alpha source_image, [10, 10]
Copy the alpha channel from a rectangle of the source image to the specified coordinates
Examples:
x, y, w, h = 10, 20, 100, 200 dest_x, dest_y = 5, 10 image.copy_alpha_rect source_image, x, y, w, h, dest_x, dest_y source_rect = [10, 20, 100, 200] dest_coords = [5, 10] image.copy_alpha_rect source_image, source_rect, dest_coords values = [10, 20, 100, 200, 5, 10] image.copy_alpha_rect source_image, values
Copy a rectangle to the specified coordinates
Examples:
x, y, w, h = 10, 20, 100, 200 dest_x, dest_y = 5, 10 image.copy_rect x, y, w, h, dest_x, dest_y source_rect = [10, 20, 100, 200] dest_coords = [5, 10] image.copy_rect source_rect, dest_coords values = [10, 20, 100, 200, 5, 10] image.copy_rect values
Return a cropped copy of the image
Examples:
x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10 new_image = old_image.crop x, y, w, h rect = [10, 10, old_image.width - 10, old_image.height - 10] new_image = old_image.crop rect x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10 new_image = old_image.create_cropped x, y, w, h rect = [10, 10, old_image.width - 10, old_image.height - 10] new_image = old_image.create_cropped rect
Crop an image
Examples:
x, y, w, h = 10, 10, image.width - 10, image.height - 10 image.crop! x, y, w, h rect = [10, 10, image.width - 10, image.height - 10] image.crop! rect x, y, w, h = 10, 10, image.width - 10, image.height - 10 image.create_cropped! x, y, w, h rect = [10, 10, image.width - 10, image.height - 10] image.create_cropped! rect
Create a cropped and scaled copy of an image
Examples:
iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 new_image = old_image.crop_scaled x, y, w, h, new_w, new_h iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] new_image = old_image.crop_scaled values iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 new_image = old_image.create_crop_scaled x, y, w, h, new_w, new_h iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] new_image = old_image.create_crop_scaled values
Crop and scale an image
Examples:
iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 image.crop_scaled! x, y, w, h, new_w, new_h iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] image.crop_scaled! values iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 image.create_crop_scaled! x, y, w, h, new_w, new_h iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] image.create_crop_scaled! values
Return a cropped copy of the image
Examples:
x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10 new_image = old_image.crop x, y, w, h rect = [10, 10, old_image.width - 10, old_image.height - 10] new_image = old_image.crop rect x, y, w, h = 10, 10, old_image.width - 10, old_image.height - 10 new_image = old_image.create_cropped x, y, w, h rect = [10, 10, old_image.width - 10, old_image.height - 10] new_image = old_image.create_cropped rect
Crop an image
Examples:
x, y, w, h = 10, 10, image.width - 10, image.height - 10 image.crop! x, y, w, h rect = [10, 10, image.width - 10, image.height - 10] image.crop! rect x, y, w, h = 10, 10, image.width - 10, image.height - 10 image.create_cropped! x, y, w, h rect = [10, 10, image.width - 10, image.height - 10] image.create_cropped! rect
Create a cropped and scaled copy of an image
Examples:
iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 new_image = old_image.crop_scaled x, y, w, h, new_w, new_h iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] new_image = old_image.crop_scaled values iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 new_image = old_image.create_crop_scaled x, y, w, h, new_w, new_h iw, ih = old_image.width, old_image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] new_image = old_image.create_crop_scaled values
Crop and scale an image
Examples:
iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 image.crop_scaled! x, y, w, h, new_w, new_h iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] image.crop_scaled! values iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 x, y, w, h = 10, 10, iw - 10, ih - 10 image.create_crop_scaled! x, y, w, h, new_w, new_h iw, ih = image.width, image.height new_w, new_h = iw - 20, ih - 20 values = [10, 10, iw - 10, iw - 10, new_w, new_h] image.create_crop_scaled! values
Return a read-only reference to an image’s raw 32-bit data.
Examples:
RAW_DATA = image.data_for_reading_only RAW_DATA = image.data!
Fill an image using raw 32-bit data.
Note: The new data buffer must be the same size (in bytes) as the original data buffer.
Examples:
RAW_DATA = other_image.data! image.put_data RAW_DATA RAW_DATA = other_image.data! image.data = RAW_DATA
Return a read-only reference to an image’s raw 32-bit data.
Examples:
RAW_DATA = image.data_for_reading_only RAW_DATA = image.data!
Free an Imlib2::Image object, and (optionally) de-cache it as well.
Note: Any future operations on this image will raise an exception.
Examples:
# free image im.delete! # free image, and de-cache it too im.delete!(true)
Draw an ellipse at the specified coordinates with the given color
Examples:
# draw an ellipse in the center of the image using the context color xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2 image.draw_oval xc, yc, w, h # draw a violet circle in the center of the image rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2] color = Imlib2::Color::VIOLET image.draw_ellipse rect, color
Draw a line at the specified coordinates.
Examples:
# draw line from 10, 10 to 20, 20 using context color im.draw_line 10, 10, 20, 20 # draw magenta line from 5, 10 to 15, 20 im.draw_line 5, 10, 15, 20, Imlib2::Color::MAGENTA # draw line from 10, 15 to 20, 25 using context color im.draw_pixel [10, 15], [20, 25] # draw line from 1000, 2000 to 2100, 4200 with funky color my_color = Imlib2::Color::CmykColor.new 100, 255, 0, 128 im.draw_line [1000, 2000], [2100, 4200], my_color
Draw an ellipse at the specified coordinates with the given color
Examples:
# draw an ellipse in the center of the image using the context color xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2 image.draw_oval xc, yc, w, h # draw a violet circle in the center of the image rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2] color = Imlib2::Color::VIOLET image.draw_ellipse rect, color
Draw a pixel at the specified coordinates.
Note: Versions of Imlib2 up to and including 1.0.5 had a broken imlib_image_draw_pixel() call. Imlib2-Ruby has a work-around, which simulates drawing a pixel with a 1x1 rectangle. To disable this behavior, see the Imlib2::Image::draw_pixel_workaround= method.
Examples:
im.draw_pixel 10, 10 # draw using context color im.draw_pixel 10, 10, Imlib2::Color::BLUE # draw blue pixel im.draw_pixel [10, 10], Imlib2::Color::RED # draw red pixel
Draw an Imlib2::Polygon with the specified color
Examples:
# create a simple blue right triangle triangle = Imlib2::Polygon.new [10, 10], [20, 20], [10, 20] image.draw_polygon triangle, Imlib2::Color::BLUE # create an open red square polygon square = Imlib2.Polygon.new [10, 10], [20, 10], [20, 20], [10, 20] image.draw_poly square, false, Imlib2::Color::RED
Draw an Imlib2::Polygon with the specified color
Examples:
# create a simple blue right triangle triangle = Imlib2::Polygon.new [10, 10], [20, 20], [10, 20] image.draw_polygon triangle, Imlib2::Color::BLUE # create an open red square polygon square = Imlib2.Polygon.new [10, 10], [20, 10], [20, 20], [10, 20] image.draw_poly square, false, Imlib2::Color::RED
Draw a rectangle outline at the specified coordinates.
Examples:
# draw rectangle around edge of image using context color rect = [1, 1, im.width - 2, im.height - 2] im.draw_rect rect # draw magenta rectangle outline in top-left corner of image color = Imlib2::Color::MAGENTA im.draw_rect [0, 0], [im.width / 2, im.height / 2], color # draw square from 10, 10 to 30, 30 using context color im.draw_rect [10, 10, 20, 20]
Draw a rectangle outline at the specified coordinates.
Examples:
# draw rectangle around edge of image using context color rect = [1, 1, im.width - 2, im.height - 2] im.draw_rect rect # draw magenta rectangle outline in top-left corner of image color = Imlib2::Color::MAGENTA im.draw_rect [0, 0], [im.width / 2, im.height / 2], color # draw square from 10, 10 to 30, 30 using context color im.draw_rect [10, 10, 20, 20]
Draw a string with the given Imlib2::Font at the specified coordinates
Examples:
font = Imlib2::Font.new 'helvetica/12' string = 'the blue crow flies at midnight' image.draw_text font, string, 10, 10 # draw text in a specified color font = Imlib2::Font.new 'helvetica/12' string = 'the blue crow flies at midnight' color = Imlib2::Color::AQUA image.draw_text font, string, 10, 10, color # draw text in a specified direction font = Imlib2::Font.new 'verdana/24' string = 'the blue crow flies at midnight' color = Imlib2::Color::YELLOW direction = Imlib2::Direction::DOWN image.draw_text font, string, 10, 10, color, direction # draw text with return metrics font = Imlib2::Font.new 'arial/36' string = 'the blue crow flies at midnight' color = Imlib2::Color::PURPLE direction = Imlib2::Direction::LEFT metrics = image.draw_text font, string, 10, 10, color, direction ['width', 'height', 'horiz_advance', 'vert_advance'].each_index { |i, v| puts v << ' = ' << metrics[i] }
Fill a rectangle with the given Imlib2::Gradient at a given angle
Examples:
x, y, w, h = 10, 10, image.width - 20, image.height - 20 angle = 45.2 image.fill_gradient gradient, x, y, w, h, angle rect = [5, 5, 500, 20] image.gradient gradient, rect, 36.8
Fill an ellipse at the specified coordinates with the given color
Examples:
# fill an ellipse in the center of the image using the context color xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2 image.draw_oval xc, yc, w, h # fill a violet circle in the center of the image rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2] color = Imlib2::Color::VIOLET image.draw_ellipse rect, color
Fill a rectangle with the given Imlib2::Gradient at a given angle
Examples:
x, y, w, h = 10, 10, image.width - 20, image.height - 20 angle = 45.2 image.fill_gradient gradient, x, y, w, h, angle rect = [5, 5, 500, 20] image.gradient gradient, rect, 36.8
Fill an ellipse at the specified coordinates with the given color
Examples:
# fill an ellipse in the center of the image using the context color xc, yc, w, h = image.w / 2, image.h / 2, image.w / 2, image.h / 2 image.draw_oval xc, yc, w, h # fill a violet circle in the center of the image rect = [image.w / 2, image.h / 2, image.w / 2, image.w / 2] color = Imlib2::Color::VIOLET image.draw_ellipse rect, color
Fill an Imlib2::Polygon with the specified color
Examples:
# create an filled green diamond polygon square = Imlib2.Polygon.new [50, 10], [70, 30], [50, 50], [30, 30] image.fill_poly square, false, Imlib2::Color::GREEN
Fill an Imlib2::Polygon with the specified color
Examples:
# create an filled green diamond polygon square = Imlib2.Polygon.new [50, 10], [70, 30], [50, 50], [30, 30] image.fill_poly square, false, Imlib2::Color::GREEN
Fill a rectangle at the specified coordinates.
Examples:
# fill image using context color rect = [0, 0, im.width, im.height] im.fill_rect rect # fill top-left quarter of image with green color = Imlib2::Color::GREEN im.fill_rect [0, 0], [im.width / 2, im.height / 2], color # fill square from 10, 10 to 30, 30 using context color im.fill_rect [10, 10, 20, 20]
Fill a rectangle at the specified coordinates.
Examples:
# fill image using context color rect = [0, 0, im.width, im.height] im.fill_rect rect # fill top-left quarter of image with green color = Imlib2::Color::GREEN im.fill_rect [0, 0], [im.width / 2, im.height / 2], color # fill square from 10, 10 to 30, 30 using context color im.fill_rect [10, 10, 20, 20]
Apply a scripted filter or a static (eg Imlib2::Filter) filter
Example:
# apply a static filter filter = Imlib2::Filter.new 20 filter.set 2, 2, Imlib2::Color::GREEN image.filter filter # apply a scripted filter x, y = 20, 10 filter_string = "tint( x=#{x}, y=#{y}, red=255, alpha=55 );" image.filter filter_string
Create a copy of an image flipped along it’s diagonal axis
Examples:
new_image = old_image.flip_diagonal
Create a horizontally-flipped copy of an image
Examples:
backwards_image = old_image.flip_horizontal
Get the on-disk format of an Imlib2::Image
Examples:
format = image.get_format format = image.format
Get an integer value attached to an Imlib2::Image.
Examples:
qual = image.get_attached_value('quality') qual = image['quality']
Get the Imlib2::Border of an Imlib2::Image
Examples:
border = image.get_border border = image.border
Get the on-disk format of an Imlib2::Image
Examples:
format = image.get_format format = image.format
Fill a rectangle with the given Imlib2::Gradient at a given angle
Examples:
x, y, w, h = 10, 10, image.width - 20, image.height - 20 angle = 45.2 image.fill_gradient gradient, x, y, w, h, angle rect = [5, 5, 500, 20] image.gradient gradient, rect, 36.8
Does this image have transparent or translucent regions?
Examples:
if image.has_alpha? puts 'this image has alpha' end
Does this image have transparent or translucent regions?
Examples:
if image.has_alpha? puts 'this image has alpha' end
Set the irrelevant_alpha flag of an Imlib2::Image
Examples:
image.set_irrelevant_alpha true image.irrelevant_alpha = true
Set the irrelevant_border flag of an Imlib2::Image
Examples:
image.set_irrelevant_border true image.irrelevant_border = true
Set the irrelevant_format flag of an Imlib2::Image
Examples:
image.set_irrelevant_format true image.irrelevant_format = true
Return a copy of an image rotated in 90 degree increments
Examples:
increments = 3 # 90 * 3 degrees (eg 270 degrees) new_image = old_image.orientate increments
Rotate an image in 90 degree increments
Examples:
increments = 3 # 90 * 3 degrees (eg 270 degrees) image.orientate! increments
Get the Imlib2::Color::RgbaColor value of the pixel at x, y
Examples:
color = image.query_pixel 320, 240 color = image.pixel 320, 240
Get the Imlib2::Color::CmyaColor value of the pixel at x, y
Examples:
color = image.query_pixel_cmya 320, 240 color = image.pixel_cmya 320, 240
Get the Imlib2::Color::HlsaColor value of the pixel at x, y
Examples:
color = image.query_pixel_hlsa 320, 240 color = image.pixel_hlsa 320, 240
Get the Imlib2::Color::HsvaColor value of the pixel at x, y
Examples:
color = image.query_pixel_hsva 320, 240 color = image.pixel_hsva 320, 240
Get the Imlib2::Color::RgbaColor value of the pixel at x, y
Examples:
color = image.query_pixel 320, 240 color = image.pixel 320, 240
Fill an image using raw 32-bit data.
Note: The new data buffer must be the same size (in bytes) as the original data buffer.
Examples:
RAW_DATA = other_image.data! image.put_data RAW_DATA RAW_DATA = other_image.data! image.data = RAW_DATA
Get the Imlib2::Color::RgbaColor value of the pixel at x, y
Examples:
color = image.query_pixel 320, 240 color = image.pixel 320, 240
Get the Imlib2::Color::CmyaColor value of the pixel at x, y
Examples:
color = image.query_pixel_cmya 320, 240 color = image.pixel_cmya 320, 240
Get the Imlib2::Color::HlsaColor value of the pixel at x, y
Examples:
color = image.query_pixel_hlsa 320, 240 color = image.pixel_hlsa 320, 240
Get the Imlib2::Color::HsvaColor value of the pixel at x, y
Examples:
color = image.query_pixel_hsva 320, 240 color = image.pixel_hsva 320, 240
Get the Imlib2::Color::RgbaColor value of the pixel at x, y
Examples:
color = image.query_pixel 320, 240 color = image.pixel 320, 240
Remove an integer value attached to an Imlib2::Image.
Examples:
image.remove_attached_value('quality')
Save an Imlib2::Image to a file (throws an exception on error).
Examples:
image.save 'output_file.png' filename = 'output_file.jpg' begin image.save filename rescue Imlib2::FileError $stderr.puts "Couldn't save file \"#{filename}\": " + $! end
Save an Imlib2::Image to a file (no exception or error).
Provides access to the low-level imlib_save_image() call. You probably want to use Imlib2::Image::save() instead.
Examples:
image.save_image 'output_file.png'
Save an Imlib2::Image to a file (error returned as number).
Provides access to the low-level imlib_save_image_with_error_return() call. You probably want to use Imlib2::Image::save() instead.
Examples:
error = image.save_with_error_return 'output_file.png' puts 'an error occurred' unless error == 0
Apply a scripted filter
You should probably using Imlib2::Image#filter() instead, since it is polymorphic (eg, it can handle both static and scripted filters).
Example:
x, y = 20, 10 filter_string = "tint( x=#{x}, y=#{y}, red=255, alpha=55 );" image.script_filter filter_string
Scroll a rectangle to the specified coordinates
Examples:
x, y, w, h = 10, 20, 100, 200 dest_x, dest_y = 5, 10 image.scroll_rect x, y, w, h, dest_x, dest_y source_rect = [10, 20, 100, 200] dest_coords = [5, 10] image.scroll_rect source_rect, dest_coords values = [10, 20, 100, 200, 5, 10] image.scroll_rect values
Set the irrelevant_alpha flag of an Imlib2::Image
Examples:
image.set_irrelevant_alpha true image.irrelevant_alpha = true
Set the irrelevant_border flag of an Imlib2::Image
Examples:
image.set_irrelevant_border true image.irrelevant_border = true
Set the irrelevant_format flag of an Imlib2::Image
Examples:
image.set_irrelevant_format true image.irrelevant_format = true
Return a sharpened copy of an image
Examples:
radius = 15 # radius of sharpen, in pixels new_image = old_image.sharpen radius
Apply an Imlib2::Filter (eg a static filter)
You should probably using Imlib2::Image#filter() instead, since it is polymorphic (eg, it can handle both static and scripted filters).
Example:
filter = Imlib2::Filter.new 20 filter.set 2, 2, Imlib2::Color::GREEN image.static_filter filter
Return a copy of an image suitable for seamless horizontal tiling
Examples:
horiz_tile = old_image.tile_horizontal
Return a copy of an image suitable for seamless vertical tiling
Examples:
vert_tile = old_image.tile_vertical


How to get familiar with a new codebase
Most of us, quite often, are in need to familiarize with a new code base. You might be an avid open source guy/girl who wants to contribute to another project, or you just started a new job, and you want to familiarize with the platform that will be a big part of your life, during the next months/years…or just for fun, because who’s watching comedies nowadays?
Familiarizing with a new code base is a keystone skill, every software engineer should acquire on this beautiful planet.
Quite a few people have shared their techniques over the years. But I believe that repetition and collaboration are absolutely essential when it comes to master a skill.
The approach below, focuses on solving the problem on your own and not “relying” on another human being for mentoring, like an architect in your company.
RTFM first
Read any documentation the software might be associated with, first thing. This might be things like wiki pages built for the project or documentation build from code comments like doxy or Javadoc.
If the software is too large then you might prefer focusing on specific areas. For example, If you want to get familiar with the entire Facebook platform, you could start by reading about how news feed is being populated or how the data are structured in the database layer. Flow diagrams, class diagrams etc that were used as requirements reference are always handy.
Build it, break it, shake it(no pun intended Savage Garden)
The natural tendency, after you have acquired the some basic knowledge about the system you are examining, will be to build it. If it cannot be built, maybe it’s not worth reading it.
But, if for any reason you dont care, understanding how the build is done (build process) is crucial for your end target. Knowing the build process is important, because you get to know the dependencies and how the built code is deployed. And knowing that dependencies means, you know what the f*** might have broken your system.
After you build it, start using it as an end-user would do, but don’t just follow the happy path. Try to break the interface and see how the system reacts.
At the same time, observe the logs produced. This might reveal some sequence in the process, and ideally, it will point you to an entry point to start looking at the code.
For example, if you want to examine the login process of the system, log in as a user would do. But maybe try and see how it reacts to a couple of ‘form attacks’ like SQL injection and XSS.
If the logs imply that the handler handle_user_login
is called as part of the interaction, this is totally a good entry point to start reading the logic.
Read the automation tests
When I say automation tests, I don’t only mean unit tests but other types too, like behavioral tests(Cucumber anyone?). Here a few reasons for that:
- The tests, given they are written correctly, provide a great demonstration of how the app is expected to work, in terms of flow. For example:
In order to get the user logged in, I have to involve those 5 functions, that are mocked in the test, so let’s check them more deeply.
- The unit tests are a great source of documentation.If you read the unit test(s) that emulate the login success of a login you have a good example of the involved functions and their return values. What does function
create_hashed_password
return? Is it a boolean or the hash itself? You can now verify. - The behavioral tests are a living requirements capture mechanism. If you are not familiar with the concept of behavioral tests, this is a great article to have a quick but good grasp.
Start reading and drawing things
Now that you know where to start, start reading the involved pieces of code. In the example we have discussed so far, try to understand how the login handler parses the request. How the parsed password is converted to a hashed version and how it is compared to the one that we have stored in our database.
Don’t be afraid to dive deeper and get a better grasp on the low-level implementation. But, make sure you discipline yourself and you know when to stop. Otherwise, you might end up planning how to make flushing data to the database 2 pico-seconds faster(unless thats your end target of course).
Try to understand, why the developer implemented a specific piece of logic in a certain way and how would you do it. Start drawing logic diagrams that will help you visualize the flow.
Note keeping, as well, is more than desirable. Especially, if it is in terms of inline comments, which will help revisit the code later, less painfully this time. In such case, my preference is to prefix them with my initials, to filter them easily later.
And what’s the best way to verify your understanding? Modify the code and write unit tests. If the code you added, is invoked, you are certain you are on the correct track. Similarly with the unit tests. You cannot write non-trivial tests if you don’t have a decent understanding of the logic of the feature you examine.
Trace the full process in detail
Now that you know, that you are focusing on the correct piece of code, you may move further and into more details. One good approach would be to add breakpoints throughout the code invoked. Maybe start the debugger and start verifying what is going on, in terms of variables and values.
Are any of those, initialized in a different place comparing to where you expect them to? Do they have the correct format or are being coerced somehow later? What does this variable with the ugly unclear name supposed to do?
What preparation is being made from functions called before the handler under examination? What are some assumptions, being made for each call, and how we are verifying them?
Rinse and repeat
Now that you have a good understanding of what is going on for a certain slice of the functionality, you can pick another one. Learning is never-ending and always exciting.
(Optional) Try adding a new feature or solve a bug
This is mostly applicable to open source projects but not forbidden with ‘plain’ enterprise software. Once you feel confident with the software you are examining(or at least with the area you are mostly focused on), try adding some piece of functionality, whether this is a bug fix or a small new feature.
This will increase your confidence regarding the system, for sure, and is always rewarding adding new code to an existing system.
Books to read
Summary
Thank for reaching the end of this article. Please let me know if you agree/disagree with any of the steps above and as implied in the introduction, feel free to add your own methodology. Do you have any quality books to suggest, on that area?
Below is a summary of the steps I usually follow to familiarise with a new codebase:
- Read the documentation available, the first thing
- Build the software and use it as an end user would do
- Read the automation tests to get a first dive
- Read the actual business logic and make diagrams out of your understanding
- Trace the full process of each slice in detail
- Move to another slice of functionality, once confident
- Add some value to the system, by contributing to it with a bug fix or a new small feature


* The 'PureDom' tests are written as a minimal abstract utility API to accomplish these tasks, and are included as a baseline measurement of the compared libraries. It currently is not a library available for download or use.
copyright © 2010 baidu rigel fe with modifications from phiggins | MIT License | download from github


The JMockit Testing Toolkit Tutorial
- Introduction
- An example
- Running tests with JMockit
-
Writing behavior-based tests
-
Writing state-based tests
-
Reflection-based utilities
-
Mocking abstractions: capturing
implementations and instances on demand
-
Using mocks and stubs at the test class and test
suite levels
-
Measuring code coverage
-
Running tests incrementally


Pistons drop their fifth straight, 109-89 to Bulls
by APCHICAGO (AP) — Lauri Markkanen scored 24 points to bust out of a slump, Wendell Carter Jr. had 12 points and 15 rebounds, and the Chicago Bulls beat the Detroit Pistons 109-89 on Wednesday night.
It was Markkanen’s first 20-point game since scoring 35 points on opening night. Tomas Satoransky and Shaquille Harrison each had 15 points as the Bulls snapped a three-game losing streak.
Derrick Rose had 18 points and Blake Griffin — in just his third game of the season — added 16 as the Pistons dropped their fifth straight.
The Bulls won the first meeting between the teams 112-106 on Nov. 1, also at the United Center.
Detroit’s Andre Drummond finished with six points and 14 rebounds before fouling out with six minutes to go. Drummond had 25 points and 24 rebounds against the Bulls three weeks ago.
Markkanen, who entered the game shooting just 36.2% from the field, had 15 first-half points on 5-for-8 shooting (including 2 for 2 on 3-pointers) as Chicago took a 59-55 halftime lead.
That included an incredible six points on one possession late in the second quarter. Markkanen hit a 3-pointer while being fouled by Drummond, who was assessed a flagrant foul after review. Markkanen hit the free throw to complete the four-point play and then scored on a driving layup after the Bulls inbounded the ball.
That stretch snapped a tie at 51 and gave the Bulls a 57-51 lead with 1:55 left.
Chicago took an 84-71 lead after three quarters and then stretched it to 89-71 on five quick points by Thaddeus Young. The Bulls coasted from there. Markkanen hit a 3 with about 5 minutes to play for a 99-77 lead, Chicago’s biggest of the game.
TIP-INS
Pistons: G Reggie Jackson (lumbar stress reaction) missed his 12th straight game. F Tony Snell (left hip strain) and G Khyri Thomas (right foot stress reaction) also sat out.
Bulls: F Otto Porter (left foot) will be sidelined an additional two-plus weeks after a follow-up MRI taken on Tuesday revealed a bone bruise that wasn’t discovered in the initial MRI two weeks ago. Porter will be re-evaluated in two weeks . F Chandler Hutchison, who had been starting in Porter’s absence, sat out with inflammation in both shins … G Coby White played despite spraining an ankle in pregame warmups.
DENG HONORED
Luol Deng, who signed a one-day contract with the Bulls last month before retiring, was honored during the game. The 6-foot-9 forward played the first 10 of his 15 NBA seasons with the Bulls after being selected with the seventh pick of the 2004 draft.
“It’s what makes sense,” Deng said. “Chicago means a lot to me. When you look back, coming here as a young kid, a young man, 19 … there’s a lot of history here and I wanted it to end the right way.”
A video tribute was played during a timeout in the second quarter and several of Deng’s former Bulls teammates — including Joakim Noah and Ben Gordon — attended the game. Deng said he picked this game because he wanted Rose to be present as well.
UP NEXT
Pistons: Host the Atlanta Hawks on Friday night following a winless three-game road trip.
Bulls: Host the Miami Heat on Friday night to conclude a four-game homestand.


Disney+ faces glitches on launch day
Consumers complained about glitches in Walt Disney Co's streaming service on Twitter, just hours after its highly anticipated launch.
REUTERS: Consumers complained about glitches in Walt Disney Co's streaming service on Twitter, just hours after its highly anticipated launch.
While trying to access the service, users were greeted by an image of "Mickey Mouse" on a blue screen, with a message asking them to exit the app and try again.
Disney did not immediately respond to Reuters' request for comment. It was not immediately known how many users were affected by the outage.
"Not too surprised but @disneyplus looks like it's already falling over. On FireTV Stick can't load main page (Unable to connect to Disney+) and couldn't play The Mandalorian (some account issue)," user @pmhesse tweeted.
"Hopefully it's worked out by tomorrow's treadmill time."
"The Mandalorian," next adventure in the "Star Wars" movie and TV franchise, is an eight-episode live-action series which stars "Game of Thrones" actor Pedro Pascal as a helmeted bounty hunter.
Users who were able to access the service, however, gave rave reviews.
"Today is the perfect day to just stay home all day on my couch in my PJ's binging all of my favorite Disney movies on #DisneyPlus," tweeted @JulieDwoskin.
Disney's streaming service will offer a slate of new and classic TV shows and movies and feature programming from the Marvel superhero universe, the "Star Wars" galaxy, "Toy Story" creator Pixar Animation and the National Geographic.
The service is a direct challenge to market leader Netflix Inc as well as Apple Inc's newly launched Apple TV+.
Shares of Disney were up nearly 1 percent before the bell.
(Reporting by Akanksha Rana in Bengaluru; Editing by Anil D'Silva)


Barcode Scanner+ stores a history of barcodes you have scanned. This includes the contents, time, format, and other related information. You can access the history by pressing the Menu button, and then selecting History.
You will see a list of previous scans. Press one to recall the details of the scan on the screen, and act on it just as if it had been scanned again. Long press to clear one item. You can clear the history by pressing Menu and then selecting "Clear history".
You can export the data in your scan history, so that it can be read and processed by an external application. The data is exported in comma-separated value format (CSV). The output colums, in order, are:
Press Menu and choose "Send history". You will be able to choose from
applications on your device that are able to send the data somewhere, such as an e-mail application with which
you can send the CSV data to your e-mail address. Note that after sending the data, it will also be saved on
your SD card under a directory called "BarcodeScanner/History
".
By default, the contents of each scan are copied to the clipboard also. To disable this, deselect "Copy to clipboard" in Settings.
Some users need to scan many barcodes, in order to store and later export the scan history. To make this easier, enable "Bulk scan mode" under Settings. After each successful scan, the application will prepare to read another barcode, instead of displaying the result screen.
By default, if a barcode is scanned several times, the history will only record the most recent scan of that barcode. This can be changed by enabling "Remember duplicates" in Settings. This will cause the history to record all scans.


 Get a chance to learn and build world class projects
START NOW


Last time, I discussed some of the challenges of rendering code in a modern-looking webpage, using helpful features like syntax highlighting. The most immediately available solution, a JavaScript library from Google, yielded good-looking code, but it required a server call to Google and some JavaScript execution for a result that we know will be the same every time - and that would therefore be more efficient just to bake into the page HTML, if we can. As implemented, it also required us to put our code snippets in the HTML page itself, making it difficult to develop and test the code.
This, it turns out, is symptomatic of a broader issue: there is a lot of "work" that is generally useful to be able to do automatically on HTML. Formatting code is just one example: it's also really useful to have things like page templating, so that much-reused components like headers and navigation bars don't have to be repeatedly copied and pasted.
This task of programmatically modifying HTML is usually what JavaScript is for. But using JavaScript for these tasks means performing them every single time a user loads your page. If your page is viewed n times, then pre-formatting the HTML beforehand is an O(1) algorithm, where formatting the page using JavaScript is O(n). The n executions just happen on other people's computers.
So, I've just finished reorganizing my website to use Jinja for automatic template compiling, and to perform some other automatic formatting (namely, syntax highlighting) through Python in the process. Jinja is a templating engine that dynamically generates HTML. It is most commonly used from within the web framework Flask, to generate HTML for dynamic websites. But that doesn't mean it can't be used for static websites too! In this case, I just use the Flask app to get a context, in which I can save the results of Flask's render_template() function to a file:
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | with app.app_context():
# Render syntax highlighting template
f = open("highlighting.css", 'w')
f.write(HtmlFormatter().get_style_defs('.highlight'))
f.close()
# Render individual pages (but not the base template)
for filename in os.listdir('templates'):
if '.html' in filename and filename != 'base.html':
print("Compiling template {}...".format(filename))
# Link back home (for pages other than index.html)
link_home = filename != 'index.html'
rendered_html = render_template(
filename, link_home=link_home)
f = open(filename, 'w')
f.write(rendered_html)
f.close()
|
Using Python to bake the HTML beforehand also has the side benefit of letting you load text from external files into your HTML - a task which is harder than one might think to do at runtime, basically requiring either PHP or AJAX. Here, we can simply load it using Python and bake it right into the rendered HTML:
9 10 11 12 13 14 15 16 17 18 19 20 21 | def code_snippet(snippet_filename, n_start=1, n_end=0):
# Open the code snippet and trim it to the desired lines
f = open('templates/code_snippets/' + snippet_filename, 'r')
lines = f.read().split('\n')
n_end = len(lines) if n_end == 0 else n_end
text = '\n'.join(lines[n_start-1:n_end])
# Produce the highlight-formatted HTML
hl_fmt = HtmlFormatter(linenos="table", linenostart=n_start)
highlit_text = highlight(text,
get_lexer_for_filename(snippet_filename),
hl_fmt)
return "
\n" + highlit_text + "\n
"
|
With that defined, including external code in the template is as simple as:
1 | {{ code_snippet('compile.py', 9, 22) | safe }}
|
Below is the full script that performs the templating.
All of the page templates
are stored in the library templates
. They all
extend a single template, base.html
. Syntax highlighting is
then performed using the Python library
Pygments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import os
from flask import Flask, render_template
from pygments import highlight
from pygments.lexers import get_lexer_for_filename
from pygments.formatters import HtmlFormatter
app = Flask(__name__)
def code_snippet(snippet_filename, n_start=1, n_end=0):
# Open the code snippet and trim it to the desired lines
f = open('templates/code_snippets/' + snippet_filename, 'r')
lines = f.read().split('\n')
n_end = len(lines) if n_end == 0 else n_end
text = '\n'.join(lines[n_start-1:n_end])
# Produce the highlight-formatted HTML
hl_fmt = HtmlFormatter(linenos="table", linenostart=n_start)
highlit_text = highlight(text,
get_lexer_for_filename(snippet_filename),
hl_fmt)
return "
\n" + highlit_text + "\n
"
# Add code_snippet() to Jinja2's globals
# so it can be called from templates
app.jinja_env.globals.update(code_snippet=code_snippet)
with app.app_context():
# Render syntax highlighting template
f = open("highlighting.css", 'w')
f.write(HtmlFormatter().get_style_defs('.highlight'))
f.close()
# Render individual pages (but not the base template)
for filename in os.listdir('templates'):
if '.html' in filename and filename != 'base.html':
print("Compiling template {}...".format(filename))
# Link back home (for pages other than index.html)
link_home = filename != 'index.html'
rendered_html = render_template(
filename, link_home=link_home)
f = open(filename, 'w')
f.write(rendered_html)
f.close()
|
Writing and hands-on development are done on the templates; then,
a call to python3 compile.py
puts together the "real" HTML
files. I run this script manually, but I envision it could easily be
worked into a CI workflow and done automatically.
Fun fact: as of right now, the templates are still accessible on this
site. This page, for example, is made from two templates:
base.html
(for the
formatting and objects common to all the pages on this site) and
pagerendering.html
(for the content specific to this page.)
But they are unrendered templates - so don't expect anything pretty!
Overall, the result is quite maintainable, while still allowing a huge degree of freedom (you can still just specify a page's HTML completely from scratch with no templating and just pass it through, if you want to), and it performs all of the "busy work" just once - instead of delegating it to JavaScript on the reader's side, on every single page load. This idea isn't necessarily specific to purely static websites either; it could be used to lessen the redundant work done by a web server, or simply to help reduce load times by trimming some JavaScript fat.
I hope this is helpful! I made it in part because I didn't see a solution out there for avoiding some of the busy work of static website composition while still staying close to simple, clean HTML. (That second part disqualified full-fledged CMS's like WordPress and Medium.) But if there is such a solution I missed, please drop me a line - I'd love to know about it, and I'd still be happy to have gotten the experience putting this together.
Edit: After I posted this, a reader named Vitaly Potyarkin reached out to tell me about Pelican, a more full-featured static site generator written in Python. Pelican does everything my solution above does and more: it can take in input in reStructuredText or Markdown in addition to HTML, it can perform syntax highlighting through Pygments, it handles metadata and localization (topics I didn't even touch on here), and its architecture is open enough that you can easily extend its functionality to handle anything it doesn't natively cover. I'd likely recommend it over what I showed above - unless you are extremely interested in rolling a minimal solution yourself.


Router API: Tutorials
|
| Introduction | Remote intenting | Group communication | Device connection | Java API | Tutorials | Architecture | Contact |
This sample connector using Router's ConnectionService intenting api to discover and connect to peer devices. It communicates thru external wifi router or WifiDirect network setup among a group of WifiDirect enabled devices.
It includes Router project as a library project. So it will instantiate a router service directly, running in a separate process.
The README file at github project web site provides more detailed description.
This sample connector using Router's ConnectionService aidl api to discover and connect to peer devices. It communicates thru external wifi router or WifiDirect network setup among a group of WifiDirect enabled devices.
It doesn't embed router directly, instead invokes an external router's APIs embedded in another app such as Connector_wifi_intent.
This sample connector using Router's ConnectionService aidl api to discover and connect to peer devices. It uses android WifiP2pManager to create a p2p group with the current device as the group owner. This essentially creates a hotspot that can accept connections from legacy wifi devices as well as other p2p devices.
It doesn't embed router directly, instead invokes an external router's APIs embedded in another app such as Connector_wifi_intent.
The README file at github project web site provides more detailed description.
This app demonstrates how to use PeerDeviceNet group communication APIs to implement a simple chat app which connect peer chatters directly without going thru a central server.
PeerDeviceNet provides three kinds of APIs and this app has a separate chat implementation for each API:
ChatActivity.java defines a main menu to allow you choose a specific chat implementation; and allow you start PeerDeviceNet connection manager to connect your devices.
- Intenting API: ChatByIntentingActivity.java
- Messenger API: ChatByMessengerActivity.java
- IDL API: ChatByAidlActivity.java
All three chat implementations will talk to each other.
The README file at github project web site provides more detailed description.
This sample is a slight change of android SDK example TouchRotateActivity. The original TouchRotateActivity allows you rotate a 3D cube thru touch screen. This sample add PeerDeviceNet group communication to allow several android devices rotate the cube together, a simple demo of multi-player GUI applications.
Group communication is used here to sync the state of this app at connected peer devices. There are two syncing here:
Users can be actively rotating cubes at multiple devices simultaneously and apps will broadcast rotation values to each other continuously so all apps/devices will keep synced up.
- when a device joins the group, it will send a message requesting the rotation "state" of peers already in the group; after receiving responses, it will start its rotation from that state.
- when the user of a device rotates the cube, the app will broadcast the rotation changes to all connected peers and peers will change its cube's orientation accordingly.
The README file at github project web site provides more detailed description.


ThreeFourFive beavers are making paragliding.
A beaver can fly higher than the other beavers.
A beaver may also be in front of other beavers.
Beavers transmit radio information about their position in the sky.
- Castor A : « I am in front of two beavers. »
- Castor B : « There is no beaver higher than me ; and there is a beaver behind me. »
- Castor C : « One beaver is higher than me and another one is lower than me. »
- Castor A : « There are 2 beavers higher than me and 1 lower than me. »
- Castor B : « There is no beaver in front of me. »
- Castor C : « There are 3 beavers lower than me: 1 in front of me and 2 behind me.. »
- Castor D : « There are 3 beavers in front of me and no beaver lower than me. »
- Beaver A : « There are 3 beavers higher than me : 1 in front of me, and 2 behind me. »
- Beaver B : « There are 4 beavers higher than me : 3 in front of me, and 1 behind me. »
- Beaver C : « There is only one beaver higher than me, and it is before me. »
- Beaver D : « There is no beaver higher than me. »
- Beaver E : « There are only 2 beavers higher than me, and the two are in front of me. »
Can you find the position of the beavers in the sky ?


Author
Home
A Day To Remember
Albums
Beartooth
Albums
Weezer
Albums
MUSIC NAVIGATOR
This website will help to easily navigate to songs from artists albums
A Day To Remember
Beartooth
Weezer
>


Choose your duration then click the topic
hours of study
Resources:
- Gov BC: IDS Rules
- Javascript: w3schools Javascript
- PHP: w3schools PHP
- Electronics for Robotics: Particle.io Photon
- Machine Learning: Tensorflowjs
- Fraser Valley GearBots: http://www.gearbots.org/
- 3D Printing: http://fvmakers.com/
General Safety Considerations:
- As this is an independent study, safety and sensible decisions is paramount. A high level of safe decisions is needed to remain doing the IDS course.
- No use of liquids without a knowledgeable adult present
- No assignments using (flying) drones
-
-
-
-


:: com :: sun :: star :: chart ::
|
| interface XComplexDescriptionAccess |
- Base Interfaces
XComplexDescriptionAccess
┗ XChartDataArray
┗ XChartData
| XChartDataArray |
- (referenced interface's summary:)
- gives access to data represented as an array of rows.
|
|
- Description
- Offers access to complex column and row descriptions.
Can be obtained from interface XChartDocument via method getData().
- Since
- OOo 3.3
|
| Methods' Details |
getComplexRowDescriptions
| sequence< sequence< string > > |
| getComplexRowDescriptions(); |
- Description
- retrieves the description texts for all rows.
- Returns
- a sequence of sequences of strings representing the descriptions
of all rows. The outer index represents different rows.
The inner index represents the different levels (usually there is only one).
|
|
setComplexRowDescriptions
| void |
| setComplexRowDescriptions( |
[in] sequence< sequence< string > > |
rRowDescriptions ); |
- Description
- sets the description texts for all rows.
- Parameter rRowDescriptions
- a sequence of sequences of strings representing the descriptions of all
rows. The outer index represents different rows.
The inner index represents the different levels (usually there is only one).
|
|
getComplexColumnDescriptions
| sequence< sequence< string > > |
| getComplexColumnDescriptions(); |
- Description
- retrieves the description texts for all columns.
- Returns
- a sequence of sequences of strings representing the descriptions
of all columns. The outer index represents different columns.
The inner index represents the different levels (usually there is only one).
|
|
setComplexColumnDescriptions
| void |
| setComplexColumnDescriptions( |
[in] sequence< sequence< string > > |
rColumnDescriptions ); |
- Description
- sets the description texts for all columns.
- Parameter rColumnDescriptions
- a sequence of sequences of strings which represent the descriptions of
all columns. The outer index represents different columns.
The inner index represents the different levels (usually there is only one).
|
|
Top of Page
Copyright © 2013, The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.


Get the excellent Samsung Galaxy Watch Active for $150 ($50 off)
by Rita El KhouryAndroid-compatible smartwatches are a dime a dozen, but good ones with a good balance of features, responsive UX, and battery life are hard to come by. Among these rarities are Samsung's Tizen smartwatches, and today you can get the fantastic Galaxy Watch Active for $150, an all-time low price.
The Watch Active was announced along the Galaxy S10, so it's not even a year old yet. The Watch Active2 was released after it and cost $80 more, which is why the first model remains an appealing choice, especially since most issues we found with it during our initial review have now been ironed: it has received an update that enables a rotating bezel and adds more watchfaces, and it's also got better swim tracking if you care about that.
With the $50 discount, the Watch Active becomes an excellent value and $30 less than the last time we saw a deal for it.
For more deals, be sure to check out our Black Friday roundup.


Bill Oliver, 54, founder of Whojr, Inc., is a life long technologist with a career that has spanned more than 25 years in software development.
He founded his first business, Owl Den Technologies Inc., in 1988 and produced a construction management system called Owl Den One. Owl Den One provided small to medium sized construction contractors with the ability to estimate, budget, bill, and report on jobs entered. He successfully sold more than 100 systems during the six year life span of the company.
In 1994, he transitioned from an entrepreneur into a corporate position developing Unix / Windows installs. This lead him to accept subsequent positions in build / release management and ultimately as an IBM Rational Clearcase specialist.
By 2002, Bill was ready to start his next company, Whojr Inc., as a software consultant supporting the IBM Rational suite of tools. For the next twelve years he worked as a contractor installing, configuring, and molding the business / development processes to effectively utilize the Rational Suite of tools using his vast skill set.
Today, Bill has transitioned Whojr Inc. into web development company allowing him to utilize his creativity and technical skills to feed his passion to design, create, and develop fun ways to convey information.
University of Massachusetts Boston Campus (MA)
Project Management Certification Learningtree (MA)
Leadership Mastery CourseDale Carnegie (MD)
| Used it | Functional With it | Expert |
Unix Kernel Internals seminarMarshall Mckusick (MA)
Mastering Active Directory (seminar)Mark Manasi (WA)


ROCK STAR SALARY NEGOTIATION CALCULATOR
Current Salary
New Negotiated Salary
Difference
Annual Cost of Living (CoL) Increase
Years remaining before retirement
BY TIME OF RETIREMENT:
Annual Salary at retirement
(based on current salary)
Annual Salary at retirement
(based on new negotiated salary)
Difference in Annual Income
31
Years Later
(due to compound effect of CoL Increase)
Total additional income over remaining career


Gateway
BOT
17-Oct-18 02:26 AM
[dscrdeql] <Jonathan-Admin> Nice, javascript?
[dscrdeql] <Jellysmash> What's EMP? Electro magnetic pulse?
[dscrdeql] <PigBenis> Electronic monitoring program?
[dscrdeql] <PigBenis> Elephant mouse parade?
[dscrdeql] <CowboyCrypto- Founder> Equaliser Market Place
[dscrdeql] <PigBenis> Ahhh makes much more sense
[dscrdeql] <CowboyCrypto- Founder> gonna start with javascript then move into C
[dscrdeql] <CowboyCrypto- Founder> C#
[dscrdeql] <CowboyCrypto- Founder> I bought C# classes earlier this year
[dscrdeql] <CowboyCrypto- Founder> and Python classes as well
[dscrdeql] <Jonathan-Admin> Cool, I'm in between there with C++
[dscrdeql] <Jonathan-Admin> Python is fun
[dscrdeql] <CowboyCrypto- Founder> Im going to try to learn all I can
[dscrdeql] <PigBenis> I started teaching myself python earlier this year and life happened and never got back to it


{% extends "layout_unbranded.html" %} {% block page_title %} sportplaces.uk {% endblock %} {% block content %} {% include "includes/header_sports_places.html" %} Back Card details Contact details Card number Expiry date Expiry date Month Year Name on card Card security code Payment summary: 2 courts for 1 hour Ammount to pay: £20 {% endblock %}
Card details
Expiry date
Payment summary:
2 courts for 1 hour
Ammount to pay: £20


When analyzing intestinal samples you might want to prefer to use a dedicated database which includes a curated set of microbes that are known to be present in the intestines. This database is provided by HITdb. The potential advantages are:
The obvious disadvantage is that HITdb only works for intestinal samples.
If you use the mbtools
HITdb is included as an extra file. You can get the file path with
hitdb <- system.file("extdata", "hitdb_v1.00.fa.gz", package = "mbtools")
If you are not using the package it can be obtained from Zenodo with the DOI 10.5281/zenodo.159205.
We will load the sequence table we created in the mock example.
seqtab <- readRDS("svs.rds")
Now we assign the taxonomy using HITdb
library(dada2)
taxa <- assignTaxonomy(seqtab, hitdb)
colnames(taxa) <- c("Phylum", "Class", "Order", "Family", "Genus", "Species")
Don’t forget to assign the column names as we did here since Dada2 will assign incorrect ones by default.
And we are done :)
rownames(taxa) <- NULL # drop the sequences for now
head(taxa)
## Phylum Class Order
## [1,] "Firmicutes" "Bacilli" "Bacillales"
## [2,] "Firmicutes" "Bacilli" "Lactobacillales"
## [3,] "Proteobacteria" "Gammaproteobacteria" "Pseudomonadales"
## [4,] "Deinococcus-Thermus" "Deinococci" "Deinococcales"
## [5,] "Proteobacteria" "Gammaproteobacteria" "Pseudomonadales"
## [6,] "Proteobacteria" "Alphaproteobacteria" "Rhodobacterales"
## Family Genus Species
## [1,] "Staphylococcaceae" "Staphylococcus" NA
## [2,] "Streptococcaceae" "Streptococcus" "Streptococcus_mutans"
## [3,] "Moraxellaceae" "Acinetobacter" NA
## [4,] "Deinococcaceae" "Deinococcus" "Deinococcus_aquaticus"
## [5,] "Pseudomonadaceae" "Pseudomonas" NA
## [6,] "Rhodobacteraceae" "Paracoccus" NA


How many unique visitors did my site have yesterday?
Accurate but slow solutions vs fast but based on probability


Johnny's BookStore
Ordering
Home
About
Announcement
Business
Aspiration
Publish
Services
Enquiry
Ordering
Contact Us
Register
Login
View My Cart
All Categories
Books
Recordings
Compact Disc
Video Material
Publications
#
Title
Price($)
Quantity
Total:
$0.0


Drag a column header and drop it here to group by that column
ProductID
Product name
Unit price
Quantity per unit
Units in stock
Discontinued
1
Chai
$18.00
10 boxes x 20 bags
39
2
Chang
$19.00
24 - 12 oz bottles
17
3
Aniseed Syrup
$10.00
12 - 550 ml bottles
13
4
Chef Anton's Cajun Seasoning
$22.00
48 - 6 oz jars
53
5
Chef Anton's Gumbo Mix
$21.35
36 boxes
0
6
Grandma's Boysenberry Spread
$25.00
12 - 8 oz jars
120
7
Uncle Bob's Organic Dried Pears
$30.00
12 - 1 lb pkgs.
15
8
Northwoods Cranberry Sauce
$40.00
12 - 12 oz jars
6
9
Mishi Kobe Niku
$97.00
18 - 500 pkgs.
29
10
Ikura
$31.00
12 - 200 ml jars
31
1 2 3 4 5 6 7 8 9 10 ...
Page size:
5
6
7
8
9
10
11
12
13
335104 items in 33511 pages