Skip to content

Instantly share code, notes, and snippets.

View trey's full-sized avatar
🐢
Slow and steady

Trey Piepmeier trey

🐢
Slow and steady
View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@dan
dan / hack.sh
Created March 31, 2012 12:17 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@anderser
anderser / models.py
Created March 23, 2012 17:15
Save image locally from submitted url in field image_url in Django model
from django.core.files.temp import NamedTemporaryFile
def save_image_from_url(self):
"""
Save remote images from url to image field.
Requires python-requests
"""
r = requests.get(self.image_url)
if r.status_code == 200:
@postpostmodern
postpostmodern / seeds.rb
Created March 20, 2012 14:38
Example seeds.rb file which creates records and imports records from CSV files
Language.create!(name: 'English (US)', code: 'en', locale: 'en-US') if Language.count == 0
if Administrator.count == 0
admin = Administrator.new(
first_name: 'Super',
last_name: 'Admin',
email: 'admin@example.com',
password: 'adminpass',
password_confirmation: 'adminpass'
)
@bradmontgomery
bradmontgomery / ShortIntroToScraping.rst
Created February 21, 2012 02:00
Really short intro to scraping with Beautiful Soup and Requests
@panicsteve
panicsteve / gist:1641705
Created January 19, 2012 18:26
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
@Cale
Cale / generate_emails.php
Created January 10, 2012 22:19
Write x number of random email addresses to file
<?php
// This script generates x number of random email addresses
// and outputs them to a CSV file.
// Modified version of http://www.laughing-buddha.net/php/email
// Number of emails you'd like to generate
$count = 13575;
// Open the file we're outputing to. (This file should exist before you run the script.)
$fp = fopen('emails.csv', 'w');
@ErinCall
ErinCall / gist:1577622
Created January 8, 2012 07:45
Annotated the rvm install script https://raw.github.com/gist/323731
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
#the first thing it does is define a bunch of methods to make things easier further on.
#That makes for sorta uncomfortable reading, since sometimes you can see *what* it's doing,
#but not *why* it's doing it. If you're mystified as to the purpose of something, go look
#at how it's used and see if that illuminates matters.
#Terminals use numbered control codes to indicate colors. It is inconvenient to try
@postpostmodern
postpostmodern / gist:1343748
Created November 6, 2011 23:03
Pow Aliases
# Pow
alias startpow='curl get.pow.cx | sh'
alias stoppow='curl get.pow.cx/uninstall.sh | sh'
source ~/.rprompt.bash
export RPROMPT='$(date)'