Skip to content

Instantly share code, notes, and snippets.

" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
#!/usr/bin/env ruby
require 'gosu' # gem install gosu --no-document
include Gosu
$dimension, $splits = 200, 20
$size = $dimension.to_f / $splits.to_f
class Worm
attr_writer :dir
def initialize() reset end
from redis import Redis
import simplejson
class Resque(object):
"""Dirt simple Resque client in Python. Can be used to create jobs."""
redis_server = 'localhost:6379'
def __init__(self):
host, port = self.redis_server.split(':')
self.redis = Redis(host=host, port=int(port))
In celebration of Whyday: Rubyists always want to show others the beautiful code
they have created, hence the question: Has Anybody Seen My Code?
Has Anybody Seen My Code
(sung to the tune of Has Anybody Seen My Gal)
Clean and small, works for all,
Ruby is my all in all.
Has anybody seen my code?
@ismaelga
ismaelga / LICENSE
Last active August 29, 2015 14:06 — forked from ktheory/LICENSE
Copyright 2014 Kickstarter, Inc.
Released under an MIT License.

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

# Install apt-get packages:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
# Install chruby:
cd
wget https://github.com/downloads/postmodern/chruby/chruby-0.2.3.tar.gz
tar -xzvf chruby-0.2.3.tar.gz
cd chruby-0.2.3
sudo make install
@ismaelga
ismaelga / benchmark_new_set_include.rb
Last active August 29, 2015 14:13
Benchmark of Set#include? using Hash#[]
require 'benchmark/ips'
require 'set'
sizes = [10, 100, 1_000, 10_000]
accesses = %i(first last hits misses)
class NewSet < Set
def initialize(enum = nil, &block)
@hash = Hash.new(false)
super
@ismaelga
ismaelga / gist:7ce902babe356b7cae3f
Last active August 29, 2015 14:13
cargo build "no such file or directory"
~/hello_world ❯❯❯ sudo dtruss -f /usr/local/bin/cargo build
PID/THRD SYSCALL(args) = return
42307/0x231a8: thread_selfid(0x0, 0x0, 0x0) = 143784 0
42307/0x231a8: csops(0x0, 0x0, 0x7FFF58CC4248) = 0 0
42307/0x231a8: issetugid(0x0, 0x0, 0x7FFF58CC4248) = 0 0
42307/0x231a8: shared_region_check_np(0x7FFF58CC2188, 0x0, 0x7FFF58CC4248) = 0 0
42307/0x231a8: stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x7FFF58CC3318, 0x7FFF58CC4248) = 0 0
42307/0x231a8: open("/dev/dtracehelper\0", 0x2, 0x7FFF58CC4140) = 3 0
42307/0x231a8: close(0x3) = 0 0
{:ok, content} = File.read("test/example_script.lua")
defredis_script(:return_one_file, content)