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
| fdist = nltk.FreqDist([w.lower() for w in words]) |
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
| # 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) |
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
| class String | |
| def strip_entities | |
| self.gsub(/&#?[A-Za-z0-9]+;/, '') | |
| end | |
| 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
| 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 |
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
| # 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 |
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
| @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 |
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
| # Extract & Delete | |
| ed() { | |
| case ${1##*.} in | |
| tar) | |
| tar -xvf $1 | |
| ;; | |
| tgz|gz|Z) | |
| tar -zxvf $1 | |
| ;; | |
| tbz|tbz2|bz2) |
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
| ?- 'bergen' = L. | |
| L = bergen. | |
| ?- "bergen" = L. | |
| L = [98, 101, 114, 103, 101, 110]. | |
| ?- atom('bergen'). | |
| true. | |
| ?- is_list("bergen"). |
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
| { | |
| :q0 => {"R" => :q1}, | |
| :q1 => {"u" => :q2}, | |
| :q2 => {"u" => :q2, "b" => :q3}, | |
| :q3 => {"y" => :q4} | |
| } |
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
| Echoe.new(PROJECT) do |p| | |
| # ... | |
| p.ignore_pattern = FileList[".gitignore"] | |
| # ... | |
| end |