Skip to content

Instantly share code, notes, and snippets.

# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
@lsmith77
lsmith77 / gist:648702
Created October 27, 2010 09:04
multiplexer to json-ify any controller as well as call multiple separate controllers via one request
<?php
namespace Application\FooBundle\Controller;
class MultiplexController
{
/**
* Request
* @var Symfony\Component\HttpFoundation\Request
*/
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@rpavlik
rpavlik / fix_homebrew.rb
Created January 6, 2011 20:32 — forked from mxcl/install_homebrew.markdown
Fix permissions on /usr/local for Homebrew
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@bryanl
bryanl / campfire-emoji.txt
Created January 27, 2011 16:34
campfire emoji
Surround these with : e.g. :calling:
+1
-1
bulb
calling
clap
cop
email
feet
@Daniel15
Daniel15 / 1_Twitter autoresponder bot.md
Last active December 6, 2021 20:37
Twitter autoresponder bot

Twitter autoresponder bot

By Daniel15 (dan.cx) This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

Questions? See my blog post - http://dan.cx/blog/2011/06/twitter-autoreply-bot-dbznappa

Modified 2013-06-13 - Twitter API 1.0 discontinued, modified to use Twitter API 1.1

@rosenfeld
rosenfeld / chef-gitorious-etc-solo.rb
Created February 28, 2011 12:29
Chef configuration files for Gitorious
file_cache_path "/root/chef-solo"
cookbook_path "/root/chef-solo/cookbooks"
json_attribs "/root/chef-solo/node.json"
@kennethreitz
kennethreitz / .zlogin
Created April 14, 2011 19:46
Server ZSH Setup (I use oh-my-zsh locally)
git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
echo "[%{$fg_bold[green]%}${ref#refs/heads/}%{$reset_color%}]"
fi
}
# makes color constants available
autoload -U colors
colors
@malclocke
malclocke / gist:943565
Created April 27, 2011 01:31 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
awk -F'/' '/^ *origin/{if(!match($0, /(>|master)/)){print $2}}' |
xargs git push origin --delete
# add your user to www-data and vise versa
sudo usermod -a -G www-data myusername
sudo usermod -a -G myusername www-data
# override umask in ~/.bashrc and /etc/init.d/apache2
umask 002
#restart