Skip to content

Instantly share code, notes, and snippets.

View softprops's full-sized avatar
®️
Rustling

Doug Tangren softprops

®️
Rustling
View GitHub Profile
# rb singletons
# idea from http://ozmm.org/posts/singin_singletons.html
# using the 'extend self' technique to treat a
# module like a singleton class. note:
# module now behaves like a class but
# since it is not a class you cannot create a new
# instance
module SelfTest
extend self
# how to I tell if an array includes all elements of another array?
[1,2,3].include? [1,2,3] => false # expects single element
[[1,2,3]].include? [1,2,3] => true # works if ordered and includes all
[[1,3,2]].include? [1,2,3] => false # fails if unordered
[[1,3,2].sort].include? [1,2,3].sort => true # passes if ordered
(function(){try{var isTwitter=window.location.host.match(/(twitter.com)?/);if(isTwitter){var d=window.document;if(typeof google=='undefined'){var s=d.createElement('script');s.type='text/javascript';s.src='http://www.google.com/jsapi';d.getElementsByTagName('head')[0].appendChild(s);}
if(typeof jQuery=='undefined'){google.load("jquery","1.3.2");}
var elClass=".entry-content";var msg="tweet tweet さえずる";function resolveLang(){return jQuery('html').attr('lang');}
var lang=resolveLang();jQuery.fn.extend({linkUrl:function(){var returning=[];var regexp=/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;this.each(function(){returning.push(this.replace(regexp,"<a href=\"$1\">$1</a>"));});return jQuery(returning);},linkUser:function(){var returning=[];var regexp=/[\@]+([A-Za-z0-9-_]+)/gi;this.each(function(){returning.push(this.replace(regexp,"@<a href=\"http://twitter.com/$1\">$1</a>"));});return jQuery(returning);}});function flash(){var id='t-flash';var el=d.createElement('div'
CmdUtils.CreateCommand({
name: "isithotinhere?",
author: {name: "Doug Tangren", homepage: "http://lessis.me/"},
license: "MIT",
description: "is it hot in here or is it just me?",
takes: {"city and state": noun_arb_text},
_hotnessUrl: function(loc) {
var baseUrl = "http://isithotinhereorisitjust.me/check/hotness/";
return baseUrl + loc;
},
a:active, a:focus { outline:none; }
button::-moz-focus-inner, input::-moz-focus-inner { border: 0; outline:none; }
<(`Д`<)
(>’-')>
<( '-' )>
(>’-')>
<( ^-^ )>
# install tokyocabinet
wget http://tokyocabinet.sourceforge.net/tokyocabinet-1.4.25.tar.gz
tar xvzf tokyocabinet-1.4.25.tar.gz
cd tokyocabinet-1.4.25
./configure
make
sudo make install
# install ruby bindings
wget http://tokyocabinet.sourceforge.net/rubypkg/tokyocabinet-ruby-1.25.tar.gz
# set process cmd
# http://pragdave.blogs.pragprog.com/pragdave/2008/11/trivial-request-logging-for-rails.html
before_filter :set_process_name_from_request
def set_process_name_from_request
$0 = request.path[0,16]
end
after_filter :unset_process_name_from_request
def unset_process_name_from_request
$0 = request.path[0,15] + "*"
class String
def to_permalink
self.downcase.strip.gsub /[^a-z0-9]+/, '-'
end
end
Array.prototype.include = function(val) {
for(var el in this) {
if(this[el] === val) {
return true;
}
}
return false;
}