Skip to content

Instantly share code, notes, and snippets.

fdist = nltk.FreqDist([w.lower() for w in words])
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
# Drop-in replacement for the LiveValidations controller that ships with
# live-validations.
class ValidationPoller
def self.call(env)
if env["PATH_INFO"] =~ /^\/live_validations\/uniqueness/
params = HashWithIndifferentAccess.new(Rack::Request.new(env).params)
class String
def strip_entities
self.gsub(/&#?[A-Za-z0-9]+;/, '')
end
end
zero:~/Projects/crantastic $ heroku console
Ruby console for crantastic.heroku.com
>> puts File.read(Rails.configuration.database_configuration_file)
---
production:
encoding: unicode
adapter: postgresql
username: something_random
port: 5432
host: somewhere.at.heroku
# Prefix the previous line with "sudo " then execute it
rerun-with-sudo () {
LBUFFER="sudo !!"
zle accept-line
}
zle -N rerun-with-sudo
bindkey '\C-x\C-x' rerun-with-sudo
@anbn = Automaton.setup(:pda) do
initial_state :q0 do
transition ['a', EMPTY], [:q0, 'A']
transition ['b', 'A'], [:q1, EMPTY]
end
state :q1 do
transition ['b', 'A'], [:q1, EMPTY]
end
# Extract & Delete
ed() {
case ${1##*.} in
tar)
tar -xvf $1
;;
tgz|gz|Z)
tar -zxvf $1
;;
tbz|tbz2|bz2)
?- 'bergen' = L.
L = bergen.
?- "bergen" = L.
L = [98, 101, 114, 103, 101, 110].
?- atom('bergen').
true.
?- is_list("bergen").
{
:q0 => {"R" => :q1},
:q1 => {"u" => :q2},
:q2 => {"u" => :q2, "b" => :q3},
:q3 => {"y" => :q4}
}
Echoe.new(PROJECT) do |p|
# ...
p.ignore_pattern = FileList[".gitignore"]
# ...
end