Skip to content

Instantly share code, notes, and snippets.

View maliabadi's full-sized avatar

Matt Aliabadi maliabadi

  • None
  • Seattle, WA
View GitHub Profile
include Math
class FrequencyDistribution
attr :samples, :data
def initialize samples=[]
@data = {}
samples.each(&method(:add))
end
@maliabadi
maliabadi / gist:5916fb8ab3ffdbc6ef58
Created September 17, 2014 02:46
solr_segment_file_parser.py
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')
@maliabadi
maliabadi / message_sql_to_json.py
Created September 18, 2012 04:21
non parameterized sql for every evaluation of every message
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
@maliabadi
maliabadi / week_one.rb
Created October 19, 2012 01:44
Week One
# WEEK ONE ASSIGNMENT TEMPLATE
beatles = ["John", "Paul", "George", "Ringo"]
names = "FRANK, Thomas"
foo = 3
bar = 1
an_array_of_numbers = [3,2,1,2]
@maliabadi
maliabadi / file_three.rb
Created October 26, 2012 07:52
requiring gems
# 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',
@maliabadi
maliabadi / file_two.rb
Created October 26, 2012 07:45
File Two
# 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"
@maliabadi
maliabadi / file_one.rb
Created October 26, 2012 07:38
File One
class Person
attr_accessor :youth, :last_name, :first_name
def initialize(first, last, age)
@youth = age
@first_name = first
@last_name = last
end
end
@maliabadi
maliabadi / doc2json.py
Last active December 10, 2015 23:58
Provides a local JSON dump of a remote Google Drive spreadsheet.
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")
class DeclarativeMessage(Message):
__metaclass__ = _DeclarativeMeta
query = None
query_rows = 1 # most common case
role = None
processor = None
domain = None
range = None
@maliabadi
maliabadi / mv
Created November 5, 2013 20:21
open gem source in sublime
#!/usr/bin/env ruby
path = Dir["#{ENV['rvm_path']}/gems/#{ENV['RUBY_VERSION']}/gems/#{ARGV[0]}*"].sort.last
`subl #{path}`