Skip to content

Instantly share code, notes, and snippets.

@KL-7
KL-7 / gist:1407204
Created November 29, 2011 23:47
binding.pry inside unbound method that was removed from the classes
$ cat pry-method-name.rb
require 'rubygems'
require 'pry'
class A
def self.generate_method(name)
define_method name do
binding.pry
end
m = instance_method name
@KL-7
KL-7 / rot.rb
Created December 17, 2011 12:13
AI class NLP problem 1 solution
#!/usr/bin/env ruby
# Data is taken from Wikipedia: http://j.mp/english-letters-frequencies
LETTERS_FREQUENCIES = {
'a' => 8.167,
'b' => 1.492,
'c' => 2.782,
'd' => 4.253,
'e' => 12.702,
'f' => 2.228,
@KL-7
KL-7 / gist:1490118
Created December 17, 2011 12:37
AI class NLP problem 2 input.
|de| | f|Cl|nf|ed|au| i|ti| |ma|ha|or|nn|ou| S|on|nd|on|
|ry| |is|th|is| b|eo|as| | |f |wh| o|ic| t|, | |he|h |
|ab| |la|pr|od|ge|ob| m|an| |s |is|el|ti|ng|il|d |ua|c |
|he| |ea|of|ho| m| t|et|ha| | t|od|ds|e |ki| c|t |ng|br|
|wo|m,|to|yo|hi|ve|u | t|ob| |pr|d |s |us| s|ul|le|ol|e |
| t|ca| t|wi| M|d |th|"A|ma|l |he| p|at|ap|it|he|ti|le|er|
|ry|d |un|Th|" |io|eo|n,|is| |bl|f |pu|Co|ic| o|he|at|mm|
|hi| | |in| | | t| | | | |ye| |ar| |s | | |. |
GEM
remote: http://rubygems.org/
specs:
POpen4 (0.1.4)
Platform (>= 0.4.0)
open4
Platform (0.4.0)
actionmailer (3.1.3)
actionpack (= 3.1.3)
mail (~> 2.3.0)
@KL-7
KL-7 / updatesauceLabsresults.md
Created January 3, 2012 19:47 — forked from tarun3kumar/updatesauceLabsresults.java
Update SauceLabs Results

List:

  • foo
  • bar

This is an H1

This is an H2

@KL-7
KL-7 / one-liners.md
Created January 10, 2012 19:49
Ruby one-liners

One-liners

Reverse every line:

Input file:

$ cat foo
qwe
123

bar

@KL-7
KL-7 / active_admin_mongoid_patch.rb
Created February 12, 2012 16:30 — forked from moa3/active_admin_mongoid_patch.rb
Patches to make ActiveAdmin work with Mongoid.
# Patches to make ActiveAdmin work with Mongoid.
# For more information see https://github.com/gregbell/active_admin/issues/26 and https://gist.github.com/1809524.
require "active_admin"
require "active_admin/resource_controller"
require 'ostruct'
module ActiveAdmin
class Namespace
# Disable comments
@KL-7
KL-7 / hub.log
Created February 28, 2012 20:23
2012-02-28T20:20:15+00:00 app[hub.1]: Invalid gemspec in [vendor/bundle/ruby/1.9.1/specifications/actionmailer_inline_css-1.4.0.gemspec]: invalid date format in specification: "2011-10-10 00:00:00.000000000Z"
2012-02-28T20:20:15+00:00 app[hub.1]: Invalid gemspec in [vendor/bundle/ruby/1.9.1/specifications/octokit-0.6.5.gemspec]: invalid date format in specification: "2011-10-15 00:00:00.000000000Z"
2012-02-28T20:20:15+00:00 app[hub.1]: Invalid gemspec in [vendor/bundle/ruby/1.9.1/specifications/omniauth-oauth2-1.0.0.gemspec]: invalid date format in specification: "2011-11-02 00:00:00.000000000Z"
2012-02-28T20:20:15+00:00 app[hub.1]: Invalid gemspec in [vendor/bundle/ruby/1.9.1/specifications/omniauth-github-1.0.1.gemspec]: invalid date format in specification: "2011-12-04 00:00:00.000000000Z"
2012-02-28T20:20:15+00:00 app[hub.1]: Invalid gemspec in [vendor/bundle/ruby/1.9.1/specifications/postmark-0.9.8.gemspec]: invalid date format in specification: "2011-08-23 00:00:00.000000000Z"
2012-02-28T20:20:15+00:00
@KL-7
KL-7 / gist:1966887
Created March 3, 2012 16:26 — forked from al3xandru/gist:1156476
Open iTerm in Current Folder
on run {input, parameters}
tell application "Finder"
set sel to selection
if (count sel) > 0 then
set myTarget to item 1 of sel
else if (count window) > 0 then
set myTarget to target of window 1
else
set myTarget to path to home folder
end if
def init_var
puts 'init var...'
'var value'
end
puts 'define class A'
class A
@@var = init_var