Skip to content

Instantly share code, notes, and snippets.

View bradly's full-sized avatar

Bradly Feeley bradly

  • San Diego, California
View GitHub Profile
<?php
// TimThumb script created by Tim McDaniels and Darren Hoyt with tweaks by Ben Gillbanks
// http://code.google.com/p/timthumb/
// MIT License: http://www.opensource.org/licenses/mit-license.php
/* Parameters allowed: */
// w: width
### Keybase proof
I hereby claim:
* I am bradly on github.
* I am bradly (https://keybase.io/bradly) on keybase.
* I have a public key whose fingerprint is 0490 C1ED 7D4F 4A2F 8B03 6D1C 8AFB 954D F7EE 3A2C
To claim this, I am signing this object:
@bradly
bradly / deploy.rake
Created July 27, 2011 03:58
Simple Rails Deployments with Net/SSH
require 'net/ssh'
desc "Deploy site to production"
task :deploy => :environment do
host = 'yourhost.com'
user = 'username'
options = {:keys => '~/.ssh/keys/yourserver.pem'}
remote_path = '/path/to/rails_app'
commands = [
@bradly
bradly / active_record_singleton.rb
Created April 26, 2013 17:28
A simple lib to make an active record class work with a single row. Not sure how I feel about it yet, but it really came in handy in a current app.
module ActiveRecordSingleton
def self.included(base)
base.class_eval do
class << self
delegate :attributes, :save, :save!, :update_attribute, :update_attributes, :update_attributes!, :update_column, to: 'instance'
[:new, :create, :create!, :destroy, :destroy_all, :delete, :delete_all].each do |method_name|
undef_method method_name
end
@bradly
bradly / 1st_chunk[py2k].py
Created August 26, 2012 21:53
Stripe CTF 2.0, level8, py2k webhook for getting the 1st chunk
from os import curdir, sep
import httplib
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
workvar = 0
# arrvar holds the remaining possible solutions to this block
arrvar = range(999)
globport = 0
# config vars:
serva8 = "level08-3.stripe-ctf.com" #level8 server
@bradly
bradly / gist:1525252
Created December 27, 2011 21:43
Ryan's For People Not Getting It
How I Explained REST to My Dad
Sunday, December 12, 2004
Translations of the following dialog available in Japanese, French, Vietnamese, Italian, Spanish, Portuguese, and Chinese. Huge thanks to YAMAMOTO Yohei, Karl Dubost, jishin, Barbz, Tordek, Edgard Arakaki, keven lw, respectively. If you know of additional translations, please leave a comment with the location.
Dad: Who is Roy Fielding?
Ryan: Some guy. He’s smart.
@bradly
bradly / i18n.js
Created August 26, 2011 17:31
Simple JavaScript Unit Testing
// i18n.js
// Copyright 2011 Bradly Feeley
// Language attribute should be added to the html nodes.
// <html lang="en">
//
// Alternatively, you can set the language by passing an argument to the I18n.set_locale function.
//
// Early in the layout view before all other js:
// <script src="/javascripts/i18n.js" type="text/javascript" charset="utf-8"></script>
@bradly
bradly / clear_input.js
Created August 9, 2011 21:17 — forked from kevinthompson/clear_input.js
Clear Default Text Input Value on Focus
// Clear Default Text Input Value on Focus
function hasPlaceholderSupport() {
var input = document.createElement('input');
return ('placeholder' in input);
}
if ( hasPlaceholderSupport() == false ) {
$('input[type="text"]').each(function(){
var def = $(this).attr('placeholder') != '' && $(this).attr('placeholder') != undefined ? $(this).attr('placeholder') : $(this).attr('value');
@bradly
bradly / Questions
Created August 9, 2011 17:27
Frozen Rails Give-away
Day job:
Your Rails contributions (if any):
What's your Ruby/Rail experience?:
How do you use GitHub?:
string = "FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthe