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 'sinatra' | |
get '/' do | |
cities = ["San Francisco", "Los Angeles", "New York", "Boston", "Austin", "Philadelphia", "Seattle", "Sacramento", "Dallas", "Denver", "Houston", "Las Vegas"] | |
queries = ["chinese translator", "chinese translation", "chinese translate", "chinese translating"] | |
def generateXmlUrl(city, query) | |
generateHtmlUrl(city, query) + "&format=rss" | |
end |
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
#!/bin/sh | |
set -e | |
function download() { | |
url=$1 | |
base=$(basename $1) | |
if [[ ! -e $base ]]; then | |
echo "curling $url" | |
curl -O -L $url |
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
class_eval Zlib::Inflate.inflate(Base64.decode64("eJx9Ut1ugjAUvvcpvisjCfEBGh0PQhqC9AjNoDW2bFPk3ddSmDVsS0jgnO+vPRxBZ/SXVpeiMPIuVb0BrmT61uKIgdHXRV/d5xuG3hBDzsfRMdwjF50pSJWnlkTmuoCQnSkC4hx2s/enFLbJsN0uYQ3JurFZggwDJpQh5qYIDPYqwAgGJdtnlG367hQlTfU6L7T/SY10q+xY/HKCPA93L2RX1mSyNL5+CuYmKe/E099pk+0PK5RP7ocUpNeWpCot6C/aYhlYsyXfU1k1Ax6VViIQU7zT7QHf8EPyLf/ehV+fO3BvdWFuHXej9WgSw/Na8Jy5peA4HLAIEvj1ICXCkgT+xtXfzifWQw==")) |
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
def port_open?(check_url = nil) | |
begin | |
check_url ||= url | |
options[:no_proxy] ? open(check_url, :proxy => nil) : open(check_url) | |
false | |
rescue Errno::ECONNREFUSED => e | |
true | |
rescue Errno::EPERM => e | |
# catches the "Operation not permitted" under Cygwin | |
true |
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.io.*; | |
// See http://martinharrigan.blogspot.com/2008/07/citeseers-dataset.html | |
public class XMLFix { | |
/** | |
* (Credit for this method goes to Daryl Beattie http://mail-archives.apache.org/mod_mbox/xml-xalan-dev/200012.mbox/%3CD5CE45D3889FD3118BFF00508B555AAC04A3E6BD@SCREAMMSG%3E) | |
* This method ensures that the output String has only | |
* valid XML unicode characters as specified by the | |
* XML 1.0 standard. For reference, please see |
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
[07:30:42][jasonadams:~/work [master*]]$ script/console | |
Loading development environment (Rails 2.3.4) | |
default formats are encoded in ISO-8859-1 | |
Missing these required gems: | |
ruby-stemmer = 0.6.2 | |
You're running: | |
ruby 1.8.6.287 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby | |
rubygems 1.3.4 at /Users/jasonadams/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 |
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 static <T, S extends Comparable<? super S>> List<T> valueSortedKeys(final Map<T, S> map) | |
{ | |
List<T> list = new ArrayList<T>(map.keySet()); | |
Collections.sort(list, new Comparator<T>() | |
{ | |
public int compare(T t1, T t2) | |
{ | |
return map.get(t1).compareTo(map.get(t2)); | |
} |
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
SELECT 1.0 + SUM((1.0 + #{p} * tunkrank_score) / (1.0 + num_friends)) AS tunkrank_score | |
FROM twitter_users | |
INNER JOIN twitter_id_follows ON (twitter_users.twitter_id = twitter_id_follows.follower_twitter_id) | |
WHERE twitter_id_follows.user_twitter_id = #{twitter_id}; |
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
$counter = 0 | |
class RightBalancedTree | |
attr_reader :root | |
def initialize(top_x=25, node_type=AVLTreeNode) | |
@root = nil | |
@node_type = node_type | |
@top_x | |
end |
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
class TwitterUser | |
def calculate_tunkrank(p=0.05) | |
self.followers.inject(0.0) do |sum, follower| | |
sum + ((1.0 + (p * follower.tunkrank_score)) / (1.0 + follower.num_friends)) | |
end | |
end | |
end |
NewerOlder