Skip to content

Instantly share code, notes, and snippets.

View routes.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="router" class="your.domain.routing.FirstAvailableMatchRouter">
<property name="routes">
<list>
<bean
View prototype_example.js
function genericErrorHandling() {
alert('do generic error handling here');
}
Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(function(p, options) {
p(options);
this.options.onFailure = this.options.onFailure || genericErrorHandling;
});
new Ajax.Request('somepage', {
View gist:15541
private void addCrossHatch( Graphics graphics, int width, int height, int x, int y ) {
graphics.setColor( Color.BLACK );
graphics.drawLine( x, y, x + width, y + height );
graphics.drawLine( x + ( width / 2 ), y, x + width, y + ( height / 2 ) );
graphics.drawLine( x, y + ( height / 2 ), x + ( width / 2 ), y + height );
graphics.drawLine( x, y + (int) ( height * .6 ), x + (int) ( width * .6 ), y );
graphics.drawLine( x + (int) ( width * .4 ), y + height, x + width, y + (int) ( height * .4 ) );
graphics.drawRect( x, y, width, height );
}
View gist:17498
Math.calculateViewerLength = function(start, end, xPixelRatio, yPixelRatio, minimumX, minimumY) {
var x1 = (start.x * xPixelRatio) + minimumX
var y1 = (start.y * yPixelRatio) + minimumY
var x2 = (end.x * xPixelRatio) + minimumX
var y2 = (end.y * yPixelRatio) + minimumY
var majorAxis = 6378137
var minorAxis = 6356752.3142
//Determines the true angle of the point with respect to the earth
View crazy_shit.java
private void parseWebPage() {
String line = "";
String url = "";
String proto[] = { "http://", "https://" };
try {
RandomAccessFile f = new RandomAccessFile(getAction(), "r");
while ((line = f.readLine()) != null) {
for (int protocounter = 0; protocounter < proto.length; protocounter++)
if (line.contains(proto[protocounter])) {
try {
View release.sh
git checkout master
git pull
if test -z "`git tag -l last-build`" -o -n "`git diff last-build HEAD`"; then
mvn --batch-mode release:prepare release:perform
git tag -f last-build
else
echo "no changes since last build, skipping release"
fi
View mvn-main.java
/**
* @noinspection ConfusingMainMethod
*/
public static int main( String[] args, ClassWorld classWorld )
{
// ----------------------------------------------------------------------
// Setup the command line parser
// ----------------------------------------------------------------------
CLIManager cliManager = new CLIManager();
View cuke4duke-debug.txt
+ Error stacktraces are turned on.
Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500)
Java version: 1.6.0_15
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x" version: "10.6" arch: "x86_64" Family: "mac"
[DEBUG] Building Maven user-level plugin registry from: '/Users/dholst/.m2/plugin-registry.xml'
[DEBUG] Building Maven global-level plugin registry from: '/usr/local/maven/conf/plugin-registry.xml'
[INFO] Scanning for projects...
[DEBUG] cuke4duke-maven-plugin: resolved to version 0.1.2 from local repository
View StuffSteps.java
@When("I add a table")
public void iAddATable(Table table) {
List<List<String>> diffList = new ArrayList<List<String>>();
diffList.add(Arrays.asList("a", "b"));
diffList.add(Arrays.asList("1", "2"));
table.diffLists(diffList);
List<Map<String, String>> hashes = new ArrayList<Map<String, String>>(table.hashes());
Map<String, String> newRow = hashes.get(0);
hashes.add(newRow);
View gist:185399
[~]> irb
irb(main):001:0> {'a' => 1, 'b' => 2}
=> {"a"=>1, "b"=>2}
irb(main):002:0> {'b' => 2, 'a' => 1}
=> {"a"=>1, "b"=>2}
[~]> jirb
irb(main):001:0> {'a' => 1, 'b' => 2}
=> {"a"=>1, "b"=>2}
irb(main):002:0> {'b' => 2, 'a' => 1}