Skip to content

Instantly share code, notes, and snippets.

View agaerig's full-sized avatar

Andrew Gaerig agaerig

  • Pitchfork
  • Chicago, IL
View GitHub Profile
@agaerig
agaerig / gist:2586440
Created May 3, 2012 15:22
Facebook callback session
def facebook_entry(request):
response = {}
response['success'] = True
form_data = json.loads(request.session['form_data'])
new_contestant = Contestant(first_name=form_data['first_name'],
last_name=form_data['last_name'],
time_entered=datetime.datetime.now(),
is_18=form_data['is_18'],
agreed_to_terms=form_data['agreed_to_terms'],
def index(request, template_name="contest/index.html"):
if request.method == 'POST':
form = ContestantForm(request.POST)
if form.is_valid():
new_contestant = form.save()
new_contestant.ticket_type = 'Register'
new_contestant.save()
response = redirect('thank-you')
response.set_cookie('p4k-emusic-register', 'true')
@agaerig
agaerig / gist:2719760
Created May 17, 2012 15:54
timestamp
<script>
var timestamp = new Date().getTime();
$('body').append('<IMG SRC="http://ad.doubleclick.net/ad/N5364.126668.PITCHFORKMEDIA/B6464942.30;sz=1x1;pc=[TPAS_ID];ord=['+timestamp+']?" BORDER=0 WIDTH=1 HEIGHT=1 ALT="Advertisement">');
$('body').append('<IMG SRC="http://ad.doubleclick.net/ad/N5364.126668.PITCHFORKMEDIA/B6464942.32;sz=1x1;pc=[TPAS_ID];ord=['+timestamp+']?" BORDER=0 WIDTH=1 HEIGHT=1 ALT="Advertisement">');
console.log('written');
</script>
@agaerig
agaerig / gist:2844686
Created May 31, 2012 16:47
font declaration style
@font-face {font-family: 'Calluna-Semibold';src: url('http://pitchfork.com/static/desktop/css/webfonts/206049_3_0.eot?#iefix') format('embedded-opentype');}
class Command(NoArgsCommand):
def handle_noargs(self, **options):
users = User.objects.all()
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment; filename=incomplete.csv'
writer = csv.writer(response)
for u in users:
if not u.first_name or not u.last_name:
def middle_part(s):
if len(s.strip()) > 6:
s = s.strip()[3:(len(s.strip())-3)]
else:
s = ''
return s
def middle_part(s):
if len(s.strip()) > 6:
new_str = s.strip()[3:(len(s.strip())-3)]
else:
new_str = ''
return new_str
@agaerig
agaerig / gist:4685982
Created January 31, 2013 20:10
Author Pages deploy instructions
1. add a tumblr column to the users_userprofile table: alter table users_userprofile add column tumblr varchar(60);
2. add display_email column to users_userprofile table: alter table users_userprofile add column display_email tinyint(1) default 0;
3. merge in author-pages branch
4. create profiles for Mark-specified old staffers. run: ./manage.py user_adjustments FILE_PATH (will email file)
5. rebuild search index
Before:
Kemp
Upton
Kipnis
C Santana
Moustakas
[one of: Hosmer / Jennings / Desmond / Rios]
Profar
[Bogaerts / Olt]
{% if now > datetime.datetime(2013, 2, 14, 22, 45, 0) and now < datetime.datetime(2013, 2, 15, 0, 45, 0) %}