Skip to content

Instantly share code, notes, and snippets.

View DavidYKay's full-sized avatar

David Young-Chan Kay DavidYKay

View GitHub Profile
@DavidYKay
DavidYKay / gist:912765
Created April 10, 2011 21:52
"Can Code Be Like Literature" - Jeremy Ashkenas
Jeremy
Absolutely brilliant
both technically
and oratorically
He wrote CoffeeScript
1st place 5k
21 min, 3 seconds
<7min mile
Big picture
@DavidYKay
DavidYKay / gist:1034571
Created June 19, 2011 18:35
App Engine Get Tutorial
class ContactsHandler(webapp.RequestHandler):
def get(self):
# Get user ID from URL
user_id = ...
# Make query to Datastore
data = query(user_id, ...)
# Encode to JSON
jsonObject = jsonEncode(data)
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(jsonObject)
@DavidYKay
DavidYKay / RestKit Persistence
Created January 9, 2012 23:29
RestKit Persistence Snippet
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"LastUpdatedAt"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"Loaded statuses: %@", objects);
[self loadObjectsFromDataStore];
[_tableView reloadData];
}
- (void)loadObjectsFromDataStore {
[_statuses release];
@DavidYKay
DavidYKay / conversations.json
Created January 16, 2012 19:16
CoHatch/Teambox Example JSON
{
"type": "List",
"per_page": 30,
"objects": [
{
"Conversation": {
"name": "More Professional? Maybe...maybe not...",
"simple": false,
"recent_comment_ids": [
@DavidYKay
DavidYKay / gist:2440776
Created April 22, 2012 01:56
Example JSON for Ceres Project
[
{
"department": "Managua",
"reports" : [
{
"crop": "cassava",
"price": 100,
},
{
"crop": "mango",
@DavidYKay
DavidYKay / gist:2492268
Created April 25, 2012 18:57
Basic Django Login Form
{% extends 'base.html' %}
{% block content %}
<div class="six columns centered signupbox">
<h1>Login</h1>
<form method="post" action="">
{% if form.errors.authenticate %}<div class="alert-box error">{{ form.errors.authenticate }}</div>{% endif %}
{% csrf_token %}
{{ form.as_p }}
<input type="submit" class="nice large radius blue button" value="Login" /><br/>
</form>
@DavidYKay
DavidYKay / gist:2691603
Created May 14, 2012 03:26
Gondor Deploy Error
>> gondor deploy primary master
Archiving code from master... [ok]
Building tarball... [ok]
Pushing tarball to Gondor...
[##################################100%#####################################]
Deploying... [failed]
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
@DavidYKay
DavidYKay / gist:2837029
Created May 30, 2012 15:28
Heroku Fail to Push
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 514 bytes, done.
Total 6 (delta 5), reused 0 (delta 0)
-----> Heroku receiving push
-----> Python/Django app detected
-----> Preparing Python interpreter (2.7.2)
-----> Creating Virtualenv version 1.7
@DavidYKay
DavidYKay / settings.py
Created May 30, 2012 16:55
Solution to removal of Heroku DB Injection
try:
if 'DATABASES' not in locals():
DATABASES = {}
if 'DATABASE_URL' in os.environ:
url = urlparse.urlparse(os.environ['DATABASE_URL'])
# Ensure default database exists.
DATABASES['default'] = DATABASES.get('default', {})
@DavidYKay
DavidYKay / gist:2839034
Created May 30, 2012 21:21
Gondor Redis Settings
try:
from local_settings import *
BROKER_TRANSPORT = "redis"
BROKER_HOST = GONDOR_REDIS_HOST
BROKER_PORT = GONDOR_REDIS_PORT
BROKER_VHOST = "0"
BROKER_PASSWORD = GONDOR_REDIS_PASSWORD
CELERY_RESULT_BACKEND = "redis"
CELERY_REDIS_HOST = GONDOR_REDIS_HOST