Skip to content

Instantly share code, notes, and snippets.

"Other developers are just like us - weird"

"If you ever need to deploy Django, you're good. If you know Capistrano and Unicorn they've got rip-offs of all that stuff."

"I think we should all admit we're horrible coders and move on" "We're all drug addicts - we're fighting methods..."

"It's easy to learn to play the guitar and be able to play Bob Dylan and Weezer and never get better."

"This is basically a talk that was given 30 years ago. We just have to keep giving it every few years because young guys come along and forget it."

An Unordered and Incomplete List of Things You Should Probably Never Use/Do in Ruby

(thanks to Zach Drayer and Ben Stiglitz for their feedback)

  1. Don't use the implicit $_ style parameters where any reasonably sane person might expect a parameter, like #puts.
  2. Don't use the string-manipulation methods included in Kernel, like chomp, chop, sub, and gsub. Call them on String instances instead. If you use these methods in combination with $_ style parameters, you are why we can't have nice things.
  3. Don't use callcc, because it's inefficient, leaks like a sieve, and isn't included in most implementations.
  4. Don't call Array#pack or String#unpack to store data. YAML/Marshal are more powerful and miles saner.
  5. Don't use Kernel#test. Come on, this isn't Perl. Compare the fields of File.stat instead.
  6. Don't use Kernel#syscall or IO#syscall. You shouldn't even do this in C.
/* Evil script for exporting LinkedIn contacts along with their locations.
Navigate to http://www.linkedin.com/connections?trk=hb_tab_cnts and
click on the "Locations" accordion button, then paste the following
script in to the Google Chrome JavaScript console (untested in anything
else). After quite a while a popup with some JSON will appear. */
function fakeClick(el) {
var e = document.createEvent('MouseEvents');
e.initEvent('click', true, true);
el.dispatchEvent(e);
@dreamcat4
dreamcat4 / install_rvm.rb
Created August 21, 2010 19:33
Install RVM to /usr/local - as admin group
#!/usr/bin/env ruby
#
# One-liner
# curl -fsS https://gist.github.com/raw/542746/install_rvm.rb | ruby -e '$script=STDIN.read;eval $script'
#
# This script installs to /usr/local only. It assumes theres an
# admin group on your system - either "wheel", "admin", or "staff"
#
# Sudo is used a few times during the initial install. But anyone
# in admin group can manage rvm (regardless of sudo privelidges)
@edwardgeorge
edwardgeorge / gist:544112
Created August 22, 2010 18:34
fix for macfuse installation on snow leopard if you're encountering Input/Output errors.
--- /usr/local/lib/pkgconfig/fuse.pc
+++ /usr/local/lib/pkgconfig/fuse.pc
@@ -6,5 +6,5 @@
Name: fuse
Description: File System in User Space (MacFUSE)
Version: 2.7.3
-Libs: -L${libdir} -lfuse -pthread -liconv
+Libs: -L${libdir} -lfuse_ino64 -pthread -liconv
Cflags: -I${includedir}/fuse -D__FreeBSD__=10 -D_FILE_OFFSET_BITS=64
# compl1.rb - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
require 'rubygems'
require 'redis'
r = Redis.new
# Create the completion sorted set
if !r.exists(:compl)
require 'formula'
class Cpansearch <Formula
head 'http://github.com/c9s/cpansearch.git', :using => :git
homepage 'http://github.com/c9s/cpansearch'
# Don't take +x off these files
skip_clean 'bin'
# uses libcurl (system)
# Apache conf (/etc/apache2/apache2.conf)
#
# Based on http://github.com/jacobian/django-deployment-workshop/
# blob/master/apache/apache2.conf by Jacob Kaplan-Moss
# Basic server setup
#
ServerRoot "/etc/apache2"
PidFile ${APACHE_PID_FILE}
User ${APACHE_RUN_USER}
@stephenmcd
stephenmcd / nonblocking.py
Created December 31, 2010 23:29
Threaded function decorator
import functools
import thread
def nonblocking(func):
"""
Decorator that runs the given func in a separate thread
when called, eg::
@nonblocking
def some_blocking_func():
@stevestreza
stevestreza / MWMacros.h
Created April 17, 2011 16:42
Some convenience macros for common types of objects in ObjC
#define MWDict(...) ((NSDictionary *)[NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil])
#define MWArray(...) ((NSArray *)[NSArray arrayWithObjects:__VA_ARGS__, nil])
#define MWSet(...) ((NSSet *)[NSSet setWithObjects:__VA_ARGS__, nil])
#define MWURL(str, ...) ((NSURL *)[NSURL URLWithString:[NSString stringWithFormat:(str), ##__VA_ARGS__]])
#define MWString(str, ...) ((NSString *)[NSString stringWithFormat:(str), ##__VA_ARGS__])