Skip to content

Instantly share code, notes, and snippets.

View solebared's full-sized avatar
💭
onboarding

lasitha solebared

💭
onboarding
View GitHub Profile

Keybase proof

I hereby claim:

  • I am exbinary on github.
  • I am exbinary (https://keybase.io/exbinary) on keybase.
  • I have a public key ASBPAzoGUMfqjKund4SDNG57Qx-NiuW80viKbMd33DB_qAo

To claim this, I am signing this object:

@solebared
solebared / gist:a18e8015c732d9a1921d
Last active August 29, 2015 14:23
diff of manifests (with mtimes removed)
--- tmp/one 2015-06-19 17:29:38.000000000 -0400
+++ tmp/two 2015-06-19 17:29:50.000000000 -0400
@@ -984,11 +984,11 @@
"size": 181796,
"digest": "49a82524d458cdf875e54fdb41333625"
},
- "application2\/application-b7902869433757fd8fdd9424c55b2898.js": {
+ "application2\/application-00d3c79b5dd733de23c89a12745cf577.js": {
"logical_path": "application2\/application.js",
@solebared
solebared / delegate_to_class.rb
Last active August 29, 2015 14:05
Simple class delegation using Forwardable.
require 'forwardable'
module Delegate
def self.to_class(klass, *methods)
klass.extend(Forwardable)
klass.instance_eval do
def_delegators 'self.class', *methods
end
end
end
require 'singleton'
class Loner
include Singleton
def foo bar
bar
end
def self.method_missing name, *args
# for ruby-talk PM with El_Matador.
require 'nokogiri'
doc = Nokogiri::HTML.parse(<<-HTML_END)
"<html>
<body>
<p id='para-1'>A</p>
<div class='block' id='X1'>
<h1>Foo</h1>
@solebared
solebared / gist:74495
Created March 5, 2009 18:58
Procs as closures
class One
def create_proc
Proc.new { puts self.class }
end
end
p = One.new.create_proc
p.call # => One
class Two
@solebared
solebared / gist:74249
Created March 5, 2009 07:39
Benchmarking ways to insert a separator at every 80 characters of a string
# Benchmarking ways to insert a separator at every 80 characters of a string
#
# Original question asked here:
# http://www.nabble.com/Cut-a-string-each-80-character-td22343923.html
#
# This version based on improvements suggested by Robert Klemme
require 'benchmark'
S = ('0123456789' * (80 * 100)).freeze
# Note: this script has to be sourced, just running it won't help
if [ '1.8' == $(ruby -e 'puts RUBY_VERSION[0,3]') ]; then
export PATH=/usr/local/ruby1.9/bin:$PATH
else
export PATH=$(echo $PATH | sed -e 's@/usr/local/ruby1.9/bin:@@')
fi
echo $(ruby -v)