Skip to content

Instantly share code, notes, and snippets.

View justincampbell's full-sized avatar
🌯
🍩

Justin Campbell justincampbell

🌯
🍩
View GitHub Profile
<?php
/*
SimpleTest + CodeIgniter
test.php
the test runner - loads all needed files,
integrates with CodeIgniter and runs the tests
by Jamie Rumbelow
http://jamierumbelow.net/

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.
@iconara
iconara / Redis questions on StackOverflow
Created January 24, 2011 16:20
How to query StackOverflow for the most recent, unanswered but upvoted, questions tagged "redis"
#!/usr/bin/env ruby
require 'zlib'
require 'open-uri'
require 'json'
io = Zlib::GzipReader.new(open("http://api.stackoverflow.com/1.0/questions?tagged=redis&sort=votes&min=1"))
obj = JSON.parse(io.read)
@snuggs
snuggs / .tmux.conf
Last active February 7, 2023 13:51
IDE & TMUX Configuration
############################################################################
# _
# | |_ _ __ ___ _ ___ __
# | __| '_ ` _ \| | | \ \/ /
# | |_| | | | | | |_| |> <
# \__|_| |_| |_|\__,_/_/\_\
#
# Cheatsheets:
# https://devhints.io/tmux
# `property not found` issue:
@catsby
catsby / gist:943028
Created April 26, 2011 20:16 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{sub(/origin\//,"");print}' |
xargs git push origin --delete
@leshill
leshill / Procfile
Created November 28, 2011 20:01
Unicorn config for cedar stack on Heroku.
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@fnichol
fnichol / README.md
Created February 26, 2012 01:23
A Common .ruby-version File For Ruby Projects

A Common .ruby-version File For Ruby Projects

Background

I've been using this technique in most of my Ruby projects lately where Ruby versions are required:

  • Create .rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far...
  • Create .rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).

Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.

@anthonyshort
anthonyshort / _media-queries.scss
Created March 13, 2012 10:37
Media Queries in Sass
// Media Queries in Sass 3.2
//
// These mixins make media queries a breeze with Sass.
// The media queries from mobile up until desktop all
// trigger at different points along the way
//
// And important point to remember is that and width
// over the portrait width is considered to be part of the
// landscape width. This allows us to capture widths of devices
// that might not fit the dimensions exactly. This means the break
@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
# table_stats User
# table_stats User, :email, :name
def table_stats(model, *fields)
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
fields = model.send :column_names if fields.empty?
model_count = model.send(:count)