Skip to content

Instantly share code, notes, and snippets.

View cameroncox's full-sized avatar

Cameron Cox cameroncox

View GitHub Profile
<script type="text/javascript">
$(function() {
$('#click').click(function() {
// do something
// like...
alert('Hi Guys!');
});
});
</script>
@cameroncox
cameroncox / simple_desktop_scraper.rb
Created April 27, 2011 20:46
Scrape the SimpleDesktop.com Atom Feed for a random background image
require 'rubygems'
require 'nokogiri'
require 'open-uri'
FEED_URL = 'http://feeds.feedburner.com/simpledesktops'
SAVE_DIR = '~/.simple_desktop/'
SAVE_FILE = File.expand_path(File.join(SAVE_DIR, 'background.png'))
urls = [].tap do |urls|
Nokogiri::XML.parse(open(FEED_URL)).search('description').each do |desc|
@cameroncox
cameroncox / git-flow.plugins.zsh
Created April 27, 2011 04:26
Git Flow aliases
alias gfi="git flow init"
alias gff="git flow feature"
alias gfr="git flow release"
alias gfh="git flow hotfix"
alias gfs="git flow support"
## likes endpoint
{
"name": "Frank Sinatra",
"category": "Musician/band",
"id": "104029269634285",
"created_time": "2011-03-09T01:01:58+0000"
},
## music endpoint
resources :users do
collection do
get :overview
get :overview_by_school
end
end
def gateway
index = try(read_attribute(:gateway)) || 0
GATEWAY[index]
end
resources :deals do
collection do
get :current # => maps to /deals/current as "current_deals_path"
end
end
require 'httparty'
module MaxMind
class API
attr_accessor :key
end
class Request
include HTTParty
base_uri 'http://geoip3.maxmind.com/'
<Directory "/var/www/app/current/public/">
Options -Indexes -MultiViews FollowSymlinks Includes
AllowOverride All
Order deny,allow
AuthType basic
AuthName "Password Required"
AuthUserFile /var/www/app/conf/passwords
cameron:~/ $ cat wtf.php [10:04:30]
<?php
function return_bytes($val) {
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
switch($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':