Skip to content

Instantly share code, notes, and snippets.

3:24 AV: [ is Breitbart alt-right? ] JP: [ no ]
4:55 JP: [ disavows nazis, white supremacists, “deplorables” ] “there’s no room for them on our website and never will be.”
5:18 [they both explore how MSNBC and Breitbart aren’t so different, you and i]
6:53 JP: [Huffington post readers and Breitbart readers are similar in this way]
7:14 JP: [interesting points about MS’s brand and current success]
@hipe
hipe / gist:2178672
Created March 24, 2012 05:38
using enumerators and lazy evaluation in ruby
#!/usr/bin/env ruby -w
# using enumerators and lazy evaluation in ruby
class MyLazyEnumerator < Enumerator
def filter &b
self.class.new do |y|
each do |*a|
b.call(y, *a)
@hipe
hipe / gist:1883962
Created February 22, 2012 10:13
super() with blocks -- how to avoid them bubbling up?
#!/usr/bin/env ruby -w
class Foo
def foo &block
block.call "i am foo"
end
end
class Bar < Foo
def foo &block
@hipe
hipe / gist:1721382
Created February 2, 2012 04:06
example of grouped sorting
#!/usr/bin/env ruby -w
#
class SSID < Struct.new(:ssid, :strength)
end
ssids = [
SSID.new('own-AP', 0.4444),
SSID.new('own-AP', 0.3),
SSID.new('soma', 0.2),
SSID.new('soma', 0.4),
@hipe
hipe / petrify build issues
Created March 4, 2011 10:27
petrify build issues
hipe@hipe-macbook-pro ~/petrify/example > ./build.js
4 Mar 05:26:35 - load: articles
4 Mar 05:26:35 - load: home
4 Mar 05:26:35 - load: navigation
4 Mar 05:26:35 - load: tags
4 Mar 05:26:35 - load: years
4 Mar 05:26:35 - load: article_one.md
4 Mar 05:26:35 - load: article_three.md
4 Mar 05:26:35 - load: article_two.md
4 Mar 05:26:35 - ERROR in navigation view: Cannot read property 'date' of undefined
class Foo
class << self
def make_this_method name, &block
define_method(name, &block)
end
end
end
Foo.make_this_method(:bar) do |*args|
case args.size
@hipe
hipe / o EM ?
Created October 23, 2010 18:07
nonblocking read from stdout & stderr w/o EM ?
##################### tmp.rb ##########################
#!/usr/bin/env ruby
require 'rubygems'
require 'open4'
require 'ruby-debug'
puts "starting ruby."
status = Open4.open4('sh') do |pid, sin, sout, serr|
#!/usr/bin/env ruby
hash = {}
ARGV.each do |str|
if /^--([-_a-z0-9]+)=(.+)$/i =~ str
hash[$1] = $2
end
end
pp hash
5/13/10 6:12:31 AM org.x.startx[22815] .
5/13/10 6:12:32 AM org.x.startx[22815] AUDIT: Thu May 13 06:12:32 2010: 22860 X: client 3 rejected from local host (uid 503)
5/13/10 6:12:32 AM org.x.startx[22815] Xlib: connection to ":6.0" refused by server
5/13/10 6:12:32 AM org.x.startx[22815] Xlib: No protocol specified
5/13/10 6:12:32 AM org.x.startx[22815] .
5/13/10 6:12:33 AM org.x.startx[22815] .
5/13/10 6:12:34 AM org.x.startx[22815] AUDIT: Thu May 13 06:12:34 2010: 22860 X: client 3 rejected from local host (uid 503)
5/13/10 6:12:34 AM org.x.startx[22815] Xlib: connection to ":6.0" refused by server
5/13/10 6:12:34 AM org.x.startx[22815] Xlib: No protocol specified
5/13/10 6:12:34 AM org.x.startx[22815] .
@hipe
hipe / irc.rb
Created April 24, 2010 23:00 — forked from marks/irc.rb
irb(main):022:0> COUNTRIES.keys
=> ["VA", "CC", "GT", "JP", "SE", "TZ", "CD", "GU", "MM", "DZ", "MN", "PK", "SG", "VC", "CF", "GW", "MO", "PL", "SH", "CG", "MP", "PM", "SI", "VE", "ZW", "CH", "GY", "MQ", "PN", "SJ", "CI", "MR", "SK", "VG", "MS", "SL", "CK", "ID", "MT", "SM", "VI", "YE", "CL", "IE", "LA", "MU", "SN", "CM", "FI", "LB", "MV", "PR", "SO", "CN", "FJ", "LC", "MW", "PS", "CO", "FK", "MX", "PT", "MY", "SR", "VN", "FM", "MZ", "CR", "PW", "FO", "ST", "IL", "LI", "PY", "BA", "CU", "IM", "SV", "CV", "FR", "IN", "LK", "BB", "IO", "VU", "CX", "RE", "UA", "SY", "CY", "IQ", "SZ", "BD", "CZ", "IR", "YT", "BE", "IS", "BF", "EC", "IT", "OM", "BG", "BH", "LR", "UG", "BI", "EE", "LS", "BJ", "LT", "EG", "BL", "EH", "LU", "RO", "BM", "LV", "BN", "UM", "BO", "KE", "NA", "LY", "BR", "KG", "NC", "RS", "BS", "HK", "KH", "BT", "KI", "NE", "QA", "RU", "HM", "NF", "US", "BV", "ER", "HN", "NG", "RW", "BW", "ES", "ET", "NI", "AD", "BY", "KM", "AE", "BZ", "HR", "KN", "TC", "AF", "NL", "TD", "AG", "HT", "KP", "UY", "GA", "HU"