Skip to content

Instantly share code, notes, and snippets.

View midas's full-sized avatar

Jason Harrelson midas

View GitHub Profile
#http://github.com/ahoward/open4 is an alternative that handles pid and exit status
#http://github.com/ahoward/session a more fleshed our shell utility
require 'open3'
Open3.popen3("dc") do |stdin, stdout, stderr|
t = Thread.new(stderr) do |terr|
while (line = terr.gets)
puts "stderr: #{line}"
end
end
@mxcl
mxcl / install_homebrew.markdown
Created March 6, 2010 15:14
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
@mikehale
mikehale / deploy.rb
Created May 14, 2010 19:10
Example deploy.rb for use with Engine Yard Cloud
task :production do
set :rails_env, "production"
role :app, "example.com", :master => true
role(:app) { |opts| compute_ec2_addresses(:app, opts) }
role(:db, :master => true) { |opts| compute_ec2_addresses(:db, opts) }
end
task :staging do
set :rails_env, "staging"
role :app, "staging.example.com", :master => true
@dawsontoth
dawsontoth / InfiniteScrollableView.js
Created February 3, 2011 20:54
Infinite scrollable list.
/**
* We're going to create an infinite scrollable list. In this case, we're going to show a date. When you swipe left,
* you'll see yesterday. Then the day before yesterday, and so on. Swiping right shows you tomorrow, and so on.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Track where we are in the infinite scrollable views, and define how large of a step goes between each view.
*/
var currentDate = new Date(), msIntervalBetweenViews = 1000/*ms*/ * 60/*s*/ * 60/*m*/ * 24/*h*/;
@tcocca
tcocca / delayed_job.monitrc
Created March 17, 2011 13:30
Monit script for multiple delayed_job workers
check process sequoia_dj2_delayed_job_0
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.0.pid
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 0"
as uid deploy and gid deploy
stop program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh stop production 0"
as uid deploy and gid deploy
check process sequoia_dj2_delayed_job_1
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.1.pid
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 1"
@jpurcell
jpurcell / pull-to-refresh(android).js
Created April 5, 2011 15:58
Tweetie-like pull to refresh and pull to load more. Note that it requries set heights for everything.
// This is the Android version of the Tweetie-like pull to refresh table:
// http://developer.appcelerator.com/blog/2010/05/how-to-create-a-tweetie-like-pull-to-refresh-table.html
var win = Ti.UI.currentWindow;
var alertDialog = Titanium.UI.createAlertDialog({
title: 'System Message',
buttonNames: ['OK']
});
var scrollView = Ti.UI.createScrollView({
@njonsson
njonsson / git-rebase-tags.rb
Created April 7, 2011 18:29
UPDATE: Use the `--tag-name-filter` option of `git-filter-branch`. http://blog.nilsjonsson.com/post/4421450571/rebasing-tags-in-git-repositories
#! /usr/bin/env ruby
def pluralize(word, count=2, plural_word=nil)
plural_word ||= "#{word}s"
"#{count} #{(count == 1) ? word : plural_word}"
end
unless (ARGV.length == 1) &&
(good_revision = system("git log -1 #{ARGV.first} 2>/dev/null"))
puts "Unknown revision '#{ARGV.first}'" unless good_revision
@jordansissel
jordansissel / netty-example.rb
Created April 11, 2011 06:22
Netty in JRuby
require "java"
require "netty-3.2.4.Final.jar"
# HELLO JAVA. I MISSED U.
java_import java.net.InetSocketAddress
java_import java.util.concurrent.Executors
java_import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory
java_import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory
java_import org.jboss.netty.channel.ChannelFactory
java_import org.jboss.netty.channel.ChannelPipelineFactory
@rmoriz
rmoriz / Gemfile
Last active September 23, 2024 03:00
UUID primary keys in Rails 3
# Gemfile
gem 'uuidtools'
@danielmarbach
danielmarbach / SafeObservableCollection
Created May 17, 2011 18:18
Thread safe observable collection
[DebuggerDisplay("Count = {Count}")]
[ComVisible(false)]
public class SafeObservableCollection<T> : ObservableCollection<T>
{
private readonly Dispatcher dispatcher;
public SafeObservableCollection()
: this(Enumerable.Empty<T>())
{
}