This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'rexml/document' | |
states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"] | |
map_key = "#{YOUR GOOGLE MAP API KEY}" | |
Position = Struct.new(:address, :latitude, :longitude) | |
western_most = Position.new("", 0.0, 180.0) | |
eastern_most = Position.new("", 0.0, -180.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Switch { | |
public String switchTest(String input) { | |
String result = null; | |
switch(input) { | |
case "foo": result = "foo1"; break; | |
case "bar": result = "bar1"; break; | |
case "foo:bar": result = "foo1:bar1"; break; | |
default: result = "no match"; break; | |
} | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public java.lang.String switchTest(java.lang.String); | |
Code: | |
0: aconst_null | |
1: astore_2 | |
2: aload_1 | |
3: astore_3 | |
4: iconst_m1 | |
5: istore 4 | |
7: aload_3 | |
8: invokevirtual #2 // Method java/lang/String.hashCode:()I |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rails', '3.2.11' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
platform :jruby do | |
gem 'activerecord-jdbcsqlite3-adapter' | |
gem 'jruby-openssl' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export TORQUEBOX_HOME=/opt/torquebox-2.x.incremental.1334 | |
export JAVA_OPTS="-Xmx2048m -XX:MaxPermSize=400m" | |
export JBOSS_HOME=$TORQUEBOX_HOME/jboss | |
export JRUBY_HOME=$TORQUEBOX_HOME/jruby | |
export PATH=$JRUBY_HOME/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* If the length of an array to be sorted is less than this | |
* constant, Quicksort is used in preference to merge sort. | |
*/ | |
private static final int QUICKSORT_THRESHOLD = 286; | |
/** | |
* If the length of an array to be sorted is less than this | |
* constant, insertion sort is used in preference to Quicksort. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Hash { | |
public static void main(String[] args) { | |
String str = "Java Programming Language"; | |
System.out.println(str + " hashCode(): " | |
+ str.hashCode() | |
+ " new Java 7 hashCode used by collections: " | |
+ sun.misc.Hashing.stringHash32(str)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class StringHashCollisionGenerator { | |
public static void main(String[] args) { | |
if (args.length != 1) { | |
printUsage(); | |
System.exit(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Scanner; | |
public class HashMapVictim { | |
final static Object PRESENT = new Object(); | |
public static void main(String[] args) { | |
Map<String, Object> map = new HashMap<String, Object>(); | |
Scanner sc = new Scanner(System.in); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.Map; | |
import java.util.Scanner; | |
import java.util.Set; | |
public class Anagrams { | |
public static void main(String[] args) { | |
Map<String, Set<String>> anagrams = new HashMap<String, Set<String>>(); |