Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Mears chrisjm

View GitHub Profile
@jystewart
jystewart / jangomail-sync.php
Created Jun 9, 2010
A slightly saner interface for JangoMail Sync than the one they supply
View jangomail-sync.php
<?php
/**
* A slightly saner interface for JangoMail Sync than the one they supply
*
* This is a demonstration of how to produce a more security-aware interface for JangoMail's
* web database synchronisation system. It is not guaranteed in any way and is not meant
* to be seen as an example of best practice on any level. It does, however, demonstrate how
* the flaws in that system can be worked around to build a reasonable JSON-based interface
* when working with recent versions of PHP.
@Thorsson
Thorsson / gist:2015725
Created Mar 11, 2012 — forked from juliamae/gist:753311
Deploying a Rails 3 App with EC2 + S3 + Ubuntu + Capistrano + Passenger
View gist:2015725
Deploying a Rails 3 App with EC2 + S3 + Ubuntu + Capistrano + Passenger
=======================================================================
EC2 Setup
---------
1 Launch New ec2 instance - ami-1634de7f
2 Create elastic IP [ELASTIC_IP] and associate it with instance
3 go to domain registrar DNS settings, @ and www to ELASTIC_IP
4 set the `:host` in `config/deploy.rb` to ELASTIC_IP
@kedarmhaswade
kedarmhaswade / rails-3.2-show-exceptions
Created May 10, 2012
The new way of showing/rendering all exceptions in Rails 3.2+
View rails-3.2-show-exceptions
# put this in an initializer
# a Rails 3.2 addendum for: http://accuser.cc/posts/1-rails-3-0-exception-handling
class MyShowExceptions
def initialize()
@@rescue_responses = Hash.new(:internal_server_error)
@@rescue_responses.update({
'ActionController::RoutingError' => :not_found,
'AbstractController::ActionNotFound' => :not_found,
'ActiveRecord::RecordNotFound' => :not_found,
@cam-stitt
cam-stitt / withRequests.js
Created Aug 13, 2013
A simple request mixin for Flight
View withRequests.js
/*
this.ajax({
xhr: {
url: 'some/thing'
},
events: {
done: 'somethingDone',
fail: { node: document, event: 'ajaxError' }
}
@bdunagan
bdunagan / s3-delete-bucket.rb
Created Nov 21, 2011
s3-delete-bucket.rb: quickly delete large AWS S3 buckets using fog
View s3-delete-bucket.rb
#!/usr/bin/env ruby
# s3-delete-bucket.rb
# Fog-based script for deleting large Amazon AWS S3 buckets (~100 files/second)
# Forked from this excellent script: https://github.com/SFEley/s3nuke
require 'rubygems'
require 'thread'
require 'fog'
@rodneyrehm
rodneyrehm / urlify.php
Created Apr 8, 2011
Reduce (UTF-8) strings to alphanumeric
View urlify.php
<?php
/*
consider decomposing the characters to "capture" more "obscure" characters such as ṩ
- http://www.php.net/manual/en/normalizer.normalize.php#92592
*/
/**
* Normalize a string to only contain alphanumeric characters and dashes.
*
@paullewis
paullewis / gist:1981455
Created Mar 5, 2012
Quicksort in JavaScript
View gist:1981455
/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));
@paullewis
paullewis / gist:1982121
Created Mar 5, 2012
Mergesort in JavaScript
View gist:1982121
/**
* An implementation for Mergesort. Less efficient
* than Quicksort. Again, you'd just use Array.sort
* but if you found yourself unable to use that
* there's always this option.
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
@stuliston
stuliston / artists_releases_spec.rb
Created Sep 10, 2011
Testing HABTM with rspec and factory girl
View artists_releases_spec.rb
require 'spec_helper'
describe "Artists to releases relationship" do
before(:all) do
@kanye = FactoryGirl.create(:artist, :name => 'Kanye West')
@jz = FactoryGirl.create(:artist, :name => 'Jay Z')
@watch_the_throne = FactoryGirl.create(:release, :name => 'Watch the Throne')
@dropout = FactoryGirl.create(:release, :name => 'The College Dropout')
end
@mxcl
mxcl / rsync+watcher.rb
Created Jul 18, 2009
rsync whenever the directory the script is in changes using the OS X FSEvents API
View rsync+watcher.rb
#!/usr/bin/ruby
require 'osx/foundation'
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
include OSX
$d=File.basename Dir.pwd
Dir.chdir '..'
fsevents_cb = proc do |stream, ctx, numEvents, paths, marks, eventIDs|
system "rsync --delete -rt --rsh=ssh '#{$d}' 'methylblue.com:public_html/'"