Skip to content

Instantly share code, notes, and snippets.

View robotmay's full-sized avatar

Robert May robotmay

View GitHub Profile
@robotmay
robotmay / HTML - How to call it
Created December 15, 2009 11:29
Use jQuery to allow showing/hiding a page element.
<script type="text/javascript" src="functions.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// Fill this array with ids for the elements you want to hide
var revealables = ["partner_details"];
prep(revealables);
// Fill this array with select boxes to watch for changes
var watchables = ["marital_status"];
watch(watchables);
for name in params[:post][:categories].split(",")
post.categories.find_or_create_by_name(name)
end
# In config/routes.rb:
map.namespace :admin do |admin|
admin.root :controller => :photographs
admin.resources :albums
admin.resources :categories
admin.resources :photographs
admin.resources :posts
end
@robotmay
robotmay / Custom link styles in Wordpress
Created February 3, 2010 12:56
Custom wordpress link styles
@font-face {
font-family: 'Museo300';
src: url('../fonts/Museo300-Regular.eot');
src: local('Museo'), local('Museo-300'), url('../fonts/Museo300-Regular.woff') format('woff'), url('../fonts/Museo300-Regular.ttf') format('truetype'); }
body #wrapper header nav ul li h3 a {
text-decoration: none;
color: #fff4d5;
mysqlimport --fields-optionally-enclosed-by='"' --fields-terminated-by=',' --lines-terminated-by='\r\n' --user=******* --password=******* --verbose --local database_name /path/to/file.csv
#!/bin/bash
# run with: curl -s http://gist.github.com/265272.txt | bash
set -e
localdir=$HOME/.mongodb
datadir=$localdir/data
conf=$localdir/mongod.conf
agentdir=$HOME/Library/LaunchAgents
agent=$agentdir/org.mongodb.mongod.plist
# using rvm with ruby-1.8.7-p249
# latest version 2.7.7 2010-06-17
sudo brew install libxml2
# installing libxslt from source code
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -xzvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
@robotmay
robotmay / delayed_devise_mailer.rb
Created November 2, 2010 11:34
A quick hack to make Devise send its confirmation/password reset/unlock emails via delayed_job. Chuck the following in a file under config/initializers
module Devise
module Models
module Confirmable
handle_asynchronously :send_confirmation_instructions
end
module Recoverable
handle_asynchronously :send_reset_password_instructions
end
@robotmay
robotmay / .cinderella.profile.custom
Created November 2, 2010 14:38
My preferred command line directory/git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\w\$(parse_git_branch) $ "