Skip to content

Instantly share code, notes, and snippets.

View joemsak's full-sized avatar

Joe Sak joemsak

View GitHub Profile
from twython import Twython
import time
twitter = Twython('consumer_key', 'consumer_secret', 'oauth_key', 'oauth_secret')
img = open('album_artwork.jpeg', 'rb')
filepath = 'tmp/replied_status_ids.txt'
while True:
mention = twitter.get_mentions_timeline()[0]
status_id = mention['id']
@joemsak
joemsak / .vimrc
Last active August 29, 2015 14:04
function! RunTests(filename)
" Write the file and run tests for the given filename
if filereadable(@%)
:wa
else
:w
endif
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
import sqlalchemy.orm
sqlalchemy.orm.ScopedSession = sqlalchemy.orm.scoped_session
from elixir import *
metadata.bind = "postgres://humanure@localhost/humanure_dev"
metadata.bind.echo = True
class Mention(Entity):
status_id = Field(Integer)
if match(a:filename, '\.feature$') != -1
exec ":!script/features " . a:filename
else
if filereadable("script/test")
exec ":!script/test " . a:filename
elseif filereadable("Gemfile")
if match(a:filename, '_test') != -1
exec ":!bundle exec rake test " . a:filename
else
exec ":!bundle exec rspec --color " . a:filename
module Eader
class Document
attr_reader :doc
def initialize(path)
file = open(path)
@doc = xml_doc_class.parse(file)
end
def series
class ShortUrl
def self.create(url)
url.shortened_hash = first_five_of_sha256(url)
url.save
end
def self.for(url)
ENV['HOSTNAME'] + url.shortened_hash
end
def config
conf = default_config
path = 'config/writer.yml'
if File.exist?(path)
config_file = File.open(path)
user_config = YAML.load(config_file)
conf = conf.merge(user_config)
end
module BaseballStats
module UI
class PlainTextMenu
attr_reader :reporters, :printer, :input_device
# dependency injection
def initialize(reporters, printer, input_device)
@reporters = reporters
@printer = printer
@input_device = input_device
require 'chronic'
describe Chronic do
def assert_parsed(input, bool = true)
(Chronic.parse(input) != nil).should == bool
end
it "doesn't seem to like timezones" do
assert_parsed('11/15/2013 11:56 PST', false)
assert_parsed('11/15/2013 11:56 -0400', false)
module Rehearsal
module ViewHelpers
def rehearsal_banner(message = nil)
return unless rehearsing_with_banner?
content_tag :div, :id => 'rehearsal-banner' do
if block_given?
yield
else
message || default_message