Skip to content

Instantly share code, notes, and snippets.

View trey's full-sized avatar
🏠
I'd rather be at home

Trey Piepmeier trey

🏠
I'd rather be at home
View GitHub Profile
@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)'
@chriseppstein
chriseppstein / 0_selector_hacks.scss
Created September 14, 2011 04:27
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@defunkt
defunkt / gitio
Created September 11, 2011 08:11
Turn a github.com URL into a git.io URL.
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
url = ARGV[0]
code = ARGV[1]