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
func TestIsBad(t *testing.T) { | |
v := MakeBitSet(64) | |
defer recover() | |
v.SetBit(100) | |
t.Fail() | |
} |
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
static void Main(string[] args) | |
{ | |
string line; | |
while ((line = Console.ReadLine()) != null) | |
{ | |
line = line.Trim(); | |
Process(line); | |
} | |
} |
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
egrep -io "rt +@\w+" nsports.tsv | perl -pe "s/ +/ /g" | cut -f2 -d\ | sort | uniq -c | sort -rn | head |
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 'rubygems' | |
require 'tweetstream' | |
require 'date' | |
TweetStream.configure do |config| | |
config.consumer_key = '<your key>' | |
config.consumer_secret = '<your secret>' | |
config.oauth_token = '<your token>' | |
config.oauth_token_secret = '<your token secret>' | |
config.auth_method = :oauth |
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
scala> new BasicDBObject().get("missing") => java.lang.Object = null | |
scala> new BasicDBObject().getBoolean("missing") => Boolean = false | |
scala> new BasicDBObject().getDouble("missing") throws java.lang.NullPointerException | |
scala> new BasicDBObject().getInt("missing") throws java.lang.NullPointerException | |
scala> new BasicDBObject().getLong("missing") throws java.lang.NullPointerException | |
scala> new BasicDBObject().getString("missing") => java.lang.String = null | |
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
/** | |
* From a file that contains | |
* doc_id w1 w2 w3 ... lines, separated by tabs | |
* return an inverted index Map of w -> Set(doc_id) | |
* | |
* @param filename well isn't it obvious | |
* @return Map[String,Set[String]] | |
*/ | |
import scala.collection.immutable.Map |
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 Array | |
# split array into groups up to n items, randomly choosing the size. | |
def split_random(n) | |
size == 0 ? self : (size == 1 ? [self] : self[1..-1].reduce([[self[0]]]){|ll, elt| (rand(n)==(n-1) || ll[-1].size==n) ? ll + [[elt]] : ll[0..-2] + [ll[-1] +[elt]]}) | |
end | |
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
require 'net/http' | |
def resolve(uri_str,limit=5) | |
$stderr.puts("Resolving #{uri_str}") | |
limit.times do |i| | |
uri = URI.parse(uri_str) | |
raise "No host given #{uri_str}" unless uri.host | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Head.new(uri.request_uri) | |
response = http.request(request) |
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
"@0xabad1dea I love the term \"Cutie Twitter\"" | |
"@AccuRayno I love the term \"not as brutal\". I wonder what color it would be if the forecast was \"brutal\"?" | |
"@Ashton5SOS @Smallzy I love the word wallop!!" | |
"@CL_Hellisen @MindTheCurvesZA gorgeous! i love the expression, the pose!" | |
"@DannyNoriega danny i have like a major problem...i hate the word fag and my neighbor calls me\" gay spic fag boy\" what do i do? ps. i love u" | |
"@Gwenelope love the word Luddite. Almost as much as I love the words palimpsest and velvet #randomtweet" | |
"@JMamuds I love the term “organic mass”" | |
"@JamesTharpy24 I love the term meddler in the middle for TP. It more accurately described what we really do in our classroom." | |
"@Mikah_Clark Hello. Nerd. Also, I love the word abysmal and have been wanting to use it in a convo for like three days now. Deal." | |
"@NinBendo1 I hate the term, Christian. I am a follower of Christ. And He says to love EVERYONE. So, that is how I choose to live." |
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 FizzBuzz | |
private | |
@@pairs = [ | |
[3, "fizz"], | |
[5, "buzz"] | |
] | |
def self.strings_for(n) |