Skip to content

Instantly share code, notes, and snippets.

View mguterl's full-sized avatar

Mike Guterl mguterl

View GitHub Profile
@rab
rab / .git-completion.sh
Created January 12, 2011 15:31
Colorful bash prompt with rvm and git goodness
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
@ahoward
ahoward / countdown.js
Created January 18, 2011 15:56
capturing deferred state with a closure
// a solution to http://blog.abhiomkar.in/2010/07/03/javascript-code-challenge-by-dropbox-team/
//
var countdown = function(num){
for (var i = 0; i <= num; i += 1) {
(function(i){ setTimeout(function(){ alert(num - i); }, i * 1000); })(i);
}
}
countdown(5);
@mbbx6spp
mbbx6spp / Vagrantfile.rb
Created February 5, 2011 05:36
Riak cluster Vagrantfile to offer an alternative to Basho Chef+Vagrant blog post suggestion and receive feedback at http://blog.basho.com/2011/02/04/creating-a-local-riak-cluster-with-vagrant-and-chef/
# Offering alternative Chef + Vagrant Riak cluster setup to the following blog post at basho:
# http://blog.basho.com/2011/02/04/creating-a-local-riak-cluster-with-vagrant-and-chef/
# Assumes Vagrant 0.7.0+ and VirtualBox 4.0+
# Now you should be able to launch your X (where X=4 in this case) vagrant VMs with the following:
# % vagrant up db1
# % vagrant up db2
# % vagrant up db3
# % vagrant up db4
@bleything
bleything / passwords.rake
Created February 9, 2011 21:48
A Rakefile for managing an encrypted password file
########################################################################
### Rakefile for encrypted passwords
########################################################################
#
# Here's a little Rakefile to manage your encrypted password file! It's
# really easy to use:
#
# 1) put the email addresses of the keys you want in AUTHORIZED_USERS
# 2) create a passwords.txt (and ignore it in your SCM)
# 3) run `rake passwords:encrypt`
@thbar
thbar / schema.xml
Created February 28, 2011 01:01
Searching for C++ or C# + allowing synonyms in Sunspot
<fieldType name="text" class="solr.TextField" omitNorms="false">
<analyzer>
<!-- <tokenizer class="solr.StandardTokenizerFactory"/> -->
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<!-- own attempt to use synonyms -->
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
</analyzer>
</fieldType>
# This is a fragment of code from action_controller/request.rb that handles sessions.
# (this is Rails 2.3.11 if that matters).
# It is obvious from the first method that a session is expected to be a hash.
def session
@env['rack.session'] ||= {}
end
def session=(session) #:nodoc:
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//
if(!window.jq && window.jQuery){
var jq = jQuery;
};
if(!window.App){
window.App = {};
diff --git a/lib/middleware/visitor.rb b/lib/middleware/visitor.rb
new file mode 100644
index 0000000..fdfb96d
--- /dev/null
+++ b/lib/middleware/visitor.rb
@@ -0,0 +1,100 @@
+module Middleware
+ class Visitor
+ class Node < Struct.new(:id, :name)
+ end
@collegeman
collegeman / setup-statsd.sh
Created March 9, 2011 16:12
Turn an Ubuntu 10.04 linode into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
# a daemon method that blocks until the grandchild is ready
#
# sending the pid up a pipe (grandchild -> child -> parent)
#
def daemon(options = {}, &block)
# setup
#
raise(ArgumentError, 'no block!') unless block
chdir = options[:chdir] || options['chdir'] || '.'