Skip to content

Instantly share code, notes, and snippets.

View stve's full-sized avatar

Steve Agalloco stve

View GitHub Profile

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@stve
stve / gist:30841
Created December 1, 2008 20:52 — forked from jsierles/gist:29838
#!/usr/bin/env ruby
#
# Find bloating passengers and kill them gracefully. Run from cron every minute.
#
MEM_LIMIT = ARGV[0] || 500
module Process
def self.running?(pid)
begin
@stve
stve / gist:31672
Created December 3, 2008 20:04 — forked from jsierles/gist:31100
#!/usr/bin/env ruby
#
# fetch hosts from amazon EC2 meta-data
#
# Based on http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns
#
%w(logger optparse rubygems right_aws resolv pp).each { |l| require l }
LOGGER = Logger.new("/var/log/fetch_hosts.log")
#!/usr/bin/env ruby
command = '/usr/bin/passenger-memory-stats'
memory_limit = 200 # megabytes
def running?(pid)
begin
return Process.getpgid(pid) != -1
rescue Errno::ESRCH
return false
RELEASE_OUTPUT_PATH = File.expand_path("~/Projects/releases/Squeemote")
TARGET_NAME = "Squeemote"
CONFIGURATION = ENV['CONFIGURATION'] || "Distribution"
SDK_VERSION = ENV['SDK'] || 'iphoneos2.2'
task :release do
puts "* Bumping build version."
`agvtool bump -all`
puts "* Building #{CONFIGURATION} release."
# by Giles Bowkett
# http://gilesbowkett.blogspot.com/2009/04/unshiftfiledirnamefile.html
# >> File.here("README.textile")
# => "/Users/dancroak/dev/ecology/README.textile"
class File
def self.here(string)
join(expand_path(dirname(__FILE__), string))
end
end
/*
* a smart poller for jquery.
* (by github)
*
* simple example:
*
* $.smartPoller(function(retry) {
* $.getJSON(url, function(data) {
* if (data) {
* doSomething(data)
# Overload Clearance's `deny_access` methods to allow authentication with HTTP-Auth for eg. API access
# Modeled after technoweenie's restful_authentication
# http://github.com/technoweenie/restful-authentication/blob/7235d9150e8beb80a819923a4c871ef4069c6759/generators/authenticated/templates/authenticated_system.rb#L74-76
#
# In lib/clearance_http_auth.rb
module Clearance
module Authentication
module InstanceMethods
# Load config/paperclip.yml settings
if paperclip_cfg = YAML.load_file("#{Rails.root}/config/paperclip.yml")[Rails.env]
paperclip_cfg.symbolize_keys!
command_path = paperclip_cfg.delete(:command_path)
# Replace Attachment defaults with configuration ones
Paperclip::Attachment.default_options.merge!(paperclip_cfg)
# Adjust ImageMagick path to work with Passenger
Paperclip.options[:command_path] = command_path
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end