This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
this.ajax({ | |
xhr: { | |
url: 'some/thing' | |
}, | |
events: { | |
done: 'somethingDone', | |
fail: { node: document, event: 'ajaxError' } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>Stripe Sample Form</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script> | |
<script type="text/javascript" src="https://js.stripe.com/v1/"></script> | |
<script type="text/javascript"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'aws-sdk' | |
# | |
# This script requires you to have the following environment variables set: | |
# AWS_REGION="us-west-2" | |
# AWS_ACCESS_KEY_ID="<YOUR_KEY>" | |
# AWS_SECRET_ACCESS_KEY="<YOUR_SECRET_KEY>" | |
# |
OlderNewer