This file contains hidden or 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
$LOAD_PATH.unshift File.dirname(__FILE__) + "/lib" | |
require 'chatterbot/dsl' | |
require 'pokerthing' | |
exclude "http://" # block spam tweet | |
blacklist "jerkface, assbutt" # block jerks or self | |
#debug_mode true |
This file contains hidden or 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
# we are going to intentionally use the vanilla mongo driver | |
require 'mongo' | |
require 'nokogiri' | |
require 'open-uri' | |
require 'active_support/core_ext' # from rails | |
include Mongo | |
pages = Connection.new('localhost', 27017).db('loadtest').collection('pages') | |
wikipedia_page = "http://en.wikipedia.org/wiki/Special:Export/Ford_Motor" |
This file contains hidden or 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
$LOAD_PATH.unshift File.dirname(__FILE__) + "/lib" | |
require 'chatterbot/dsl' | |
require 'pokerthing' | |
exclude "http://" # block spam tweet | |
blacklist "jerkface, assbutt" # block jerks or self | |
#debug_mode true |
This file contains hidden or 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
# not exactly a pure cache, implements the lookup or expensive operation too | |
# probably needs to be decoupled | |
class Cache | |
def initialize | |
@cache = {} | |
end | |
def cache(name, values = {}) | |
if values = {} |
This file contains hidden or 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
# sstephenson's prompt from rbenv | |
# - Set your Terminal.app theme to Basic | |
# - Set your Terminal.app font to 13pt Inconsolata | |
# - Set your ANSI Color for Normal White(7) to Tin (Crayons tab in color picker) | |
# - Put this at the end of your .profile | |
# - Help me figure out what his exact font is because it's not Inconsolata. | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null \ |
This file contains hidden or 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
!!!!!!!!0[0].+(2)[0][2e2].^(6).%(4)#| <('-'<) Kirby loves trolling? | |
# => true |
This file contains hidden or 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 'tempfile' | |
require 'open-uri' | |
url = "http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.1" | |
tmp = Tempfile.new('foo') | |
# while this is running in irb, check out /tmp/foo* | |
open(url) do |f| | |
f.each_line {|line| tmp.write line} | |
end |
This file contains hidden or 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
a = [10, 20, 30, 40, 50] | |
# each stage along the way: | |
# >> a.each_with_index.collect {|value,index| {index => value <= 30} } | |
# => [{0=>true}, {1=>true}, {2=>true}, {3=>false}, {4=>false}] | |
# | |
# .select {|h| h.invert.has_key?(false) } | |
# => [{3=>false}, {4=>false}] | |
# | |
# .collect {|h| h.keys}.flatten |
This file contains hidden or 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
# need jruby | |
# need stanford-corenlp in a directory somewhere | |
# untar it, cd into it | |
# irb innvocation for more memory happy: | |
# jruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m -J-server -S irb | |
require 'java' | |
require 'stanford-corenlp-2011-09-16.jar' | |
require 'stanford-corenlp-2011-09-14-models.jar' |
This file contains hidden or 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
# Instructions for OSX likely to be brew install based, have not tried | |
# $ sudo apt-get install libtool | |
# $ sudo aptitude install liblink-grammar4-dev | |
# runs on regular ruby not jruby-1.6.5 (tested) | |
# $ gem install linkparser | |
# set putty or whatever to width of 128 | |
dict = LinkParser::Dictionary.new( :screen_width => 128 ) | |
sent = dict.parse( "People use your mom for all kinds of nifty things." ) |