Skip to content

Instantly share code, notes, and snippets.

@ches
ches / tags_input.rb
Created January 16, 2011 18:08
simple_form input builder for use with my mongoid_taggable fork
# Example simple_form input builder to render tags from an Array field,
# for use with my fork of mongoid_taggable:
#
# https://github.com/ches/mongoid_taggable
#
# Once you've configured your app to load this, use it in forms thusly:
#
# <%= f.input :tags, :as => :tags %>
#
module SimpleForm
@ches
ches / post-checkout
Created February 7, 2011 13:17
post-checkout git hook to intelligently run `bundle` if Gemfile was changed
#!/bin/sh
# Via http://tbaggery.com/2011/02/07/bundle-while-you-git.html
# Save as http://.git/hooks/post-checkout in your project and `chmod +x`
# See the post for how to tell Git you want this in new/newly cloned repos
if [ $1 = 0000000000000000000000000000000000000000 ]; then
# Special case for initial clone: compare to empty directory.
old=4b825dc642cb6eb9a060e54bf8d69288fbee4904
else
@ches
ches / gist:836095
Created February 20, 2011 16:52
Get Started with Ruby Hacking using RVM
# Getting Started with Ruby Development Using RVM
#
# You may need to first install curl and git -- on Ubuntu:
#
# sudo apt-get install curl git-core
#
# On OS X curl should already be present. You can install Git from a binary
# installer, or using Homebrew, for the enlightened.
#
# The output of RVM installation will give you some useful information, such
@ches
ches / multi_parameter_attributes.rb
Created March 3, 2011 19:05
Monkey patch Mongoid multi-parameter attribute handling for validates_timeliness
# This monkey patches Mongoid's multi-parameter attribute handling in the same
# way that the enable_multiparameter_extension! option of validates_timeliness
# does for ActiveRecord -- to enable it to gracefully return errors to the user
# when they enter a date like February 30th.
#
# This is not thoroughly tested yet, but appears to work for Date fields at
# least. Last tested with (I think) Mongoid 2.0.0.beta20
module Mongoid #:nodoc:
module MultiParameterAttributes #:nodoc:
@ches
ches / pow
Created April 14, 2011 07:43
A quick script to switch between running Pow and Apache on OS X
#!/bin/sh -e
#/ Usage: pow [on|off]
#/ Toggle between running Pow (http://pow.cx) and Apache on Mac OS X.
# Show Usage
function usage {
grep '^#/' "$0" | cut -c4-
exit 2
}
[ -z "$1" -o "$1" = "--help" ] && usage
@ches
ches / configure
Created April 15, 2011 07:37
attempt to install duo_unix-1.5 on Ubuntu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
diff --git a/Library/Formula/pms.rb b/Library/Formula/pms.rb
index f5d8d13..66a748c 100644
--- a/Library/Formula/pms.rb
+++ b/Library/Formula/pms.rb
@@ -5,12 +5,18 @@ class Pms <Formula
homepage 'http://pms.sourceforge.net'
md5 '8ebd65c5e6e33cd0ca79817a5e823805'
+ depends_on 'pkg-config' => :build
depends_on 'glib'
@ches
ches / knife
Created May 7, 2011 20:15
bash completion for Chef's knife command (not yet updated for 0.10)
# vim: ft=sh:ts=4:sw=4:autoindent:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
# We need to specify GNU sed for OS X, BSDs, etc.
if [[ "$(uname -s)" == "Darwin" ]]; then
SED=gsed
else
SED=sed
fi
@ches
ches / gist:1054215
Created June 29, 2011 16:19
PySide homebrew formula build failure
[ches@lupin]$ brew install pyside
Also installing dependencies: qt, apiextractor, generatorrunner, shiboken
==> Downloading https://downloads.sourceforge.net/project/machomebrew/Bottles/qt-4.7.3-bottle.tar.gz
######################################################################## 100.0%
==> Pouring qt-4.7.3.tar.gz
==> Caveats
We agreed to the Qt opensource license for you.
If this is unacceptable you should uninstall.
==> Summary
/usr/local/Cellar/qt/4.7.3: 2561 files, 292M
@ches
ches / assets.rake
Created August 14, 2011 07:29
Reusing Guard tasks via Rake
# There are a couple minor quirks (see https://github.com/guard/guard/issues/118),
# but mostly this is delightfully straightforward:
require 'guard'
namespace :assets do
desc 'Generate CSS from all source LESS files'
task :less do
Guard.setup
Guard::Dsl.evaluate_guardfile(:guardfile => 'Guardfile', :group => ['frontend'])