Skip to content

Instantly share code, notes, and snippets.

View subelsky's full-sized avatar
🧘‍♂️

Mike Subelsky subelsky

🧘‍♂️
View GitHub Profile
#!/usr/bin/env ruby
require "rubygems"
require "mechanize"
require "domain_name"
m = Mechanize.new
puts "<ul>"
DATA.each_line do |line|
@subelsky
subelsky / keybase.md
Created October 11, 2014 18:46
Keybase identity assertion

Keybase proof

I hereby claim:

  • I am subelsky on github.
  • I am subelsky (https://keybase.io/subelsky) on keybase.
  • I have a public key whose fingerprint is 5DFB 121D 24D8 CA6C 0F2C B51A 3D25 9BC3 602E CC74

To claim this, I am signing this object:

require('core')
App.IframeView = SC.View.extend({
emptyElement: '<iframe></iframe>',
content: '',
noIframeText: '',
frameBorder: 0,
render: function() {
var content = this.get('content')
begin
text = JSON.generate(refresh_hash)
render :text => Iconv.iconv('utf-8','latin1',text).to_s
rescue StandardError
logger.warn("JSON generation error in refresh controller: #{$!}")
render :text => "Problem reading messages, please try again", :status => 500
end
export GIT_EDITOR="mate -w"
export LESS="-erX" # makes git diff look nicer
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '
begin
# check if memcached is running; if it is, use that instead of the default memory cache
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } }
config.cache_store = :mem_cache_store, %w(localhost:11211), { :namespace => 'OI', :timeout => 60 }
$stderr.puts "Using memcached on localhost:11211"
rescue StandardError
config.cache_store = nil
$stderr.puts "memcached not running, caching to memory"
end
# modified from http://www.mikeperham.com/2009/03/03/using-memcache-client-16x-in-rails-23
# Brain surgery to use our own version of memcache-client without having to modify activesupport directly.
# Unload any previous instance of the class
if Object.const_defined? :MemCache
Object.instance_eval { remove_const :MemCache }
end
# Ensure that the memcache-client gem path is at the front of the loadpath
$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/gems/memcache-client-1.7.4/lib')
class Tracker
def track_event(a,b,c)
@queue ||= Queue.new
start_pushing_thread
hash = { :a => a, :b =>, :c => c }
@queue << hash
end
private
@subelsky
subelsky / macvim command key mapping
Created January 18, 2011 01:10
maps the apple key plus a number to change tabs in Macvim, just like any other app
map <D-1> 1gt
map <D-2> 2gt
map <D-3> 3gt
map <D-4> 4gt
map <D-5> 5gt
map <D-6> 6gt
map <D-7> 7gt
map <D-8> 8gt
map <D-9> 9gt
@subelsky
subelsky / gist:878603
Created March 20, 2011 19:39
Possible memory leak in therubyracer
require "rubygems"
require "v8"
require "ostruct"
require "memprof"
funcs = []
3.times do
cxt = V8::Context.new
funcs << cxt.eval("f = function(arg) { return arg.a + arg.b }")