Skip to content

Instantly share code, notes, and snippets.

@avdi
avdi / when.rb
Created December 5, 2011 22:17
Experimenting with Object#when in Ruby
def maybe_a_sandwich
nil
end
# Methods that might return nil are annoying. We want to write a nice
# confident chain:
result = nil
result = maybe_a_sandwich.add_horseradish.get_into_my_belly! rescue $!
result # => #<NoMethodError: undefined method `add_horseradish' for nil:NilClass>
@nicksieger
nicksieger / Send to Evernote.scpt
Created January 1, 2012 23:48 — forked from turadg/Send Chrome to OmniFocus.scpt
OmniFocus integrations
-- from http://veritrope.com/code/copy-omnifocus-item-uri-to-evernote/
tell front window of application "OmniFocus"
try
set theTrees to selected trees of content
if (count of theTrees) < 1 then
set theTrees to selected trees of sidebar
end if
if (count of theTrees) < 1 then
@sandro
sandro / pass.rb
Created February 21, 2012 20:26
Preforking spec runner - like spork.
#!/usr/bin/env ruby
# Description
# Starts the rails environment in a long running process that forks a test
# runner. The test begins running immediately as the rails environment
# has already been loaded. Useful when running a single spec over and over.
# The program will exit when a change is detected
# in the Gemfile, or the db, config, lib and vendor directories.
#
@devsigner
devsigner / rbenv-install-system-wide.sh
Created March 28, 2012 09:52 — forked from v1nc3ntlaw/rbenv-install-system-wide.sh
rbenv install ruby 1.9.3-p125 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@karledurante
karledurante / gist:2581543
Created May 2, 2012 23:18
webdriver path config
# If capybara cannot find your browser executable, you can give it a hint like so:
Selenium::WebDriver::Firefox.path='/Applications/Firefox.app/Contents/MacOS/firefox-bin'
Selenium::WebDriver::Chrome.path = "/opt/google/chrome/google-chrome"
@fogus
fogus / fixing-parseInt.js
Last active December 11, 2015 17:49
All this and more in Lemonad and in fine bookstores and libraries near you!
// ZOMG!!
['11','11','11','11'].map(parseInt)
//=> [11, NaN, 3, 4]
// Fixing JavaScript foibles with delicious curry!
['11','11','11','11'].map(curry(parseInt));
//=> [11, 11, 11, 11]
include_recipe "apt"
apt_repository "brightbox" do
uri 'http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu'
distribution node.lsb.codename
components ['main']
keyserver "keyserver.ubuntu.com"
key "C3173AA6"
action :add
end
@dunckr
dunckr / backup
Created January 26, 2014 17:41
RubyMotion Offline API Docs
#!/bin/bash
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=unix --no-parent www.rubymotion.com/developer-center/api/_index.html
@max-mapper
max-mapper / 0.md
Last active May 12, 2025 13:51
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

@kennwhite
kennwhite / vpn_psk_bingo.md
Last active August 3, 2025 05:20
Most VPN Services are Terrible

Most VPN Services are Terrible

Short version: I strongly do not recommend using any of these providers. You are, of course, free to use whatever you like. My TL;DR advice: Roll your own and use Algo or Streisand. For messaging & voice, use Signal. For increased anonymity, use Tor for desktop (though recognize that doing so may actually put you at greater risk), and Onion Browser for mobile.

This mini-rant came on the heels of an interesting twitter discussion: https://twitter.com/kennwhite/status/591074055018582016