This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article(models.Model): | |
@models.permalink | |
def get_absolute_url(self): | |
return reverse('article_permalink', kwargs={ | |
'year': self.published_at.year, | |
'month': self.published_at.month, | |
'day': self.published_at.day, | |
'slug': self.slug, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'open-uri' | |
require 'nokogiri' | |
doc = Nokogiri::HTML(open('http://www.tampa-xway.com/')) | |
img_src = doc.css('img.closures').first['src'] | |
if img_src.match /West/ | |
puts 'Westbound' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef enum { | |
kAccomplishmentTitleSection = 0, | |
kAccomplishmentCategorySection, | |
kNumberOfSections | |
} NESTemplateEditTableSections; | |
static NSString * const kCellIdentifiers[] = { | |
[kAccomplishmentTitleSection] = @"AccomplishmentTitleCell", | |
[kAccomplishmentCategorySection] = @"AccomplishmentCategoryCell" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticleResource(ModelResource): | |
class Meta: | |
authentication = Authentication() | |
authorization = DjangoAuthorization() | |
queryset = Article.objects.all() | |
class CategoryResource(ModelResource): | |
articles = fields.ToManyField('locations.api.Articles', 'articles', full=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.exceptions import ValidationError | |
WEEKDAYS = ( | |
(1, 'Monday'), | |
(2, 'Tuesday'), | |
(3, 'Wednesday'), | |
(4, 'Thursday'), | |
(5, 'Friday'), | |
(6, 'Saturday'), | |
(7, 'Sunday'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in -viewDidLoad | |
self.cellOrder = [NSMutableArray arrayWithObjects:@"Address", @"Hours", @"Call", @"Get Directions", nil]; | |
if (foo) { | |
[self.cellOrder removeObject:@"Hours"]; | |
} | |
if (!self.location.phoneNumber) { | |
[self.cellOrder removeObject:@"Call"]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)currentlyOpen { | |
int weekday = [[[NSCalendar currentCalendar] components:NSWeekdayCalendarUnit fromDate:[NSDate date]] weekday]; | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(weekdayFrom <= %d OR weekdayTo >= %d) AND ANY location.resourceUri like %@", weekday, weekday, self.resourceUri]; | |
Hours *hours = [Hours findFirstWithPredicate:predicate]; | |
int currentHour = [[[NSCalendar currentCalendar] components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]] hour]; | |
if ([hours.hourFrom intValue] <= currentHour && [hours.hourTo intValue] >= currentHour) { | |
return YES; | |
} else { | |
return NO; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!upstart | |
description "uWSGI server for example.com" | |
start on startup | |
stop on shutdown | |
script | |
exec sudo -u www-data /usr/bin/uwsgi --plugins http,python \ | |
--chmod-socket --socket /tmp/example.sock \ | |
--wsgi-file /srv/www/example.com/example/config.wsgi \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'redcarpet' | |
gem 'albino' # requires pgyments | |
gem 'nokogiri' | |
def markdown(text) | |
options = [ | |
:autolink, :fenced_code, :filter_html, :gh_blockcode, :hard_wrap | |
:no_intraemphasis, :strikethrough, :tables, :xhtml | |
] |