Skip to content

Instantly share code, notes, and snippets.

View maliabadi's full-sized avatar

Matt Aliabadi maliabadi

  • None
  • Seattle, WA
View GitHub Profile
@maliabadi
maliabadi / htail.rb
Created January 17, 2014 23:04
script to tail robut log files. e.g 'ruby htail.rb http://minizord.corp.avvo.com/deploy_log/cloud_deploy_bugfix_11_15.log'
require 'open-uri'
printed = 0
begin
open(ARGV[0]) do |file|
`clear`
index = 0
file.each_line do |line|
if index > printed
print line
@maliabadi
maliabadi / desktop_scraper.rb
Created January 9, 2014 02:29
Want a bunch of harmless looking desktop backgrounds?
require 'rubygems'
require 'mechanize'
class DesktopScraper
BASE = "http://simpledesktops.com"
def destination_folder
File.dirname(__FILE__) + "/desktops"
end
@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}`
class DeclarativeMessage(Message):
__metaclass__ = _DeclarativeMeta
query = None
query_rows = 1 # most common case
role = None
processor = None
domain = None
range = None
@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")
@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 / 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_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 / 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 / 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