Skip to content

Instantly share code, notes, and snippets.

View scottjbarr's full-sized avatar

Scott Barr scottjbarr

View GitHub Profile
@scottjbarr
scottjbarr / gmail_imap_search.rb
Created October 7, 2009 14:50
Search Gmail Inbox
#
# Search gmail via imap
# Author : Scott Barr
#
require 'rubygems'
require 'net/imap'
puts "Authenticating..."
imap = Net::IMAP.new('imap.gmail.com', '993', true)
@scottjbarr
scottjbarr / mongoid_nil_save.rb
Created November 2, 2009 01:27
Mongoid error on save
require 'mongoid'
class Person < Mongoid::Document
field :title
field :name
field :age
has_many :addresses
end
@scottjbarr
scottjbarr / facebook_user.rb
Created November 16, 2009 03:53
Get Facebook user details
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'base64'
class FacebookUser
USER_AGENT = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9"
attr_reader :id, :name, :profile_pic
@scottjbarr
scottjbarr / start-memcached
Created December 14, 2009 05:56
Memcached startup script for Debian
#!/usr/bin/perl -w
# start-memcached
# 2003/2004 - Jay Bonci <[email protected]>
# This script handles the parsing of the /etc/memcached.conf file
# and was originally created for the Debian distribution.
# Anyone may use this little script under the same terms as
# memcached itself.
use strict;
@scottjbarr
scottjbarr / memcached
Created December 14, 2009 05:59
Memcached startup script for Debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: memcached
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: memcached - Memory caching daemon
@scottjbarr
scottjbarr / memcached.conf
Created December 14, 2009 06:01
memcached default config file
# memcached default config file
# 2003 - Jay Bonci <[email protected]>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.
# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d
@scottjbarr
scottjbarr / install_memcached.sh
Created December 14, 2009 07:26
Install memcached and libevent from source on Debian Etch or Lenny
#!/bin/bash
#
# Download and install libevent and memcached from source on Debian Etch or
# Debian Lenny.
#
# Assumptions
# - libevent and memcached have not been installed from apt repositories
# - memcached is not already running
# - it is ok to clobber scripts at
# /etc/memcached.conf
@scottjbarr
scottjbarr / install_ruby19_from_source.sh
Created January 7, 2010 05:00
Install Ruby 1.9 from source
#!/bin/bash
#
# Install Ruby 1.9 from source
#
# Author : Scott Barr
# Date : 7 Jan 2010
VERSION=ruby-1.9.1-p378
cd /usr/local/src
@scottjbarr
scottjbarr / install_ruby18_from_source.sh
Created January 7, 2010 05:01
Install Ruby 1.8 and Rubygems from source
#!/bin/bash
#
# Install Ruby 1.8 from source
#
# Author : Scott Barr
# Date : 7 Jan 2010
RUBY_VERSION=1.8.7-p249
RUBYGEMS_VERSION=1.3.5
@scottjbarr
scottjbarr / install_ruby18_on_debian.sh
Created January 7, 2010 05:51
Install Ruby 1.8 and Rubygems on Debian
#!/bin/bash
#
# Install Ruby 1.8 and Rubygems on Debian.
#
# Author : Scott Barr
# Date : 7 Jan 2010
#
# make sure some required packages are installed
sudo apt-get install build-essential make zlibc zlib1g zlib1g-dev libssl-dev