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
include Math | |
class FrequencyDistribution | |
attr :samples, :data | |
def initialize samples=[] | |
@data = {} | |
samples.each(&method(:add)) | |
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
import bitstring | |
from sys import argv | |
class SegmentsFile(object): | |
def __init__(self, path): | |
self.stream = bitstring.ConstBitStream(filename=path) | |
def read_32(self): | |
return self.stream.read('uint:32') |
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 re | |
import sys | |
import csv | |
import logging | |
import json | |
from nlg.textplanning import message as msg | |
from nlg.knowledgebase import properties as prop | |
from nlg.knowledgebase import get_entity | |
from nlg.knowledgebase import education as edu |
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
# WEEK ONE ASSIGNMENT TEMPLATE | |
beatles = ["John", "Paul", "George", "Ringo"] | |
names = "FRANK, Thomas" | |
foo = 3 | |
bar = 1 | |
an_array_of_numbers = [3,2,1,2] |
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
# this feels weird, but there's some magic here. Ruby knows where 'rubygems' is without you having to explain it with an exact path. | |
require 'rubygems' | |
# now you can you just flat-out require ANY gem you have installed! like | |
require 'pony' | |
# all of the sudden you have this really cool ruby library called 'pony' in your application's object space! And you can do shit like this: | |
Pony.mail({ | |
:to => 'matt@cutt.com', |
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
# just assuming that 'file_one.rb' is in your desktop directory. | |
# when you require a file, sometimes you have to specify the exact path of the file you want | |
require '/Users/jen/Desktop/file_one.rb' | |
# Now, all of that shit that was in file_one.rb, is in this file's object space. | |
# So i can do things like. | |
people.each do |person| | |
puts "#{person.first_name} is #{person.youth} years old" |
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 Person | |
attr_accessor :youth, :last_name, :first_name | |
def initialize(first, last, age) | |
@youth = age | |
@first_name = first | |
@last_name = last | |
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
from json import dumps | |
from gdata.spreadsheet.service import SpreadsheetsService, DocumentQuery | |
from optparse import OptionParser | |
usage = "usage: python doc2json.py --email=EMAIL --pass=PASS title=TITLE --output=OUTFILE" | |
parser = OptionParser(usage=usage) | |
parser.add_option("-e", "--email", | |
metavar="EMAIL", help="email address for doc service") | |
parser.add_option("-p", "--password", | |
metavar="PASS", help="account password") |
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 DeclarativeMessage(Message): | |
__metaclass__ = _DeclarativeMeta | |
query = None | |
query_rows = 1 # most common case | |
role = None | |
processor = None | |
domain = None | |
range = None |
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
#!/usr/bin/env ruby | |
path = Dir["#{ENV['rvm_path']}/gems/#{ENV['RUBY_VERSION']}/gems/#{ARGV[0]}*"].sort.last | |
`subl #{path}` |
OlderNewer