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: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
@DavidYKay
DavidYKay / AT Commands
Created September 5, 2012 01:18
Autopylot Flight Log - 2000, 9/4/2012
AT*ZAP=1,0
AT*PMODE=2,2
AT*MISC=3,2,20,2000,3000
AT*CONFIG_IDS=4,"71ca1641","00000000","1da978de"
AT*CONFIG=5,"custom:session_id","-all"
AT*PCMD_MAG=6,0,0,0,0,0,0,0
AT*REF=7,290717696
AT*PCMD_MAG=8,0,0,0,0,0,0,0
AT*REF=9,290717696
AT*PCMD_MAG=10,0,0,0,0,0,0,0
@DavidYKay
DavidYKay / command.c
Created September 7, 2012 03:08
ARDrone 1.8 -> 2.0 SDK Fixes
// This is the code from the updated navigation example, ardrone_ini.c:189
ardrone_tool_set_progressive_cmd(
enable,
/*roll*/(float)(stick1LR-center_x1)/32767.0f,
/*pitch*/(float)(stick1UD-center_y1)/32767.0f,
/*gaz*/-(float)(stick2UD-center_x2)/32767.0f,
/*yaw*/(float)(stick2LR-center_y2)/32767.0f,
/*psi*/0.0,
/*psi_accuracy*/0.0);
@DavidYKay
DavidYKay / git-sub.sh
Created September 7, 2012 16:20
Git search and replace
#!/bin/bash
#~/.scripts/git-sub
#Author: Khaja Minhajuddin <minhajuddin@cosmicvent.com>
#script which does a global search and replace in the git repository
#it takes two arguments
#e.g. git sub OLD NEW
old=$1
new=$2
@DavidYKay
DavidYKay / compile.log
Created September 9, 2012 02:52
AR Drone compiler output
gcc -Wall -g -O0 -v -da -Q -DUSE_LINUX=yes -I/home/dk/Tools/ardrone/sdk/ARDrone_SDK_2_0/ARDroneLib -I/home/dk/Tools/ardrone/sdk/ARDrone_SDK_2_0/ARDroneLib/VP_SDK -I/home/dk/Tools/ardrone/sdk/ARDrone_SDK_2_0/ARDroneLib/VP_SDK/VP_Os/linux -I/home/dk/Tools/ardrone/sdk/ARDrone_SDK_2_0/ARDroneLib/Soft/Lib -I/home/dk/Tools/ardrone/sdk/ARDrone_SDK_2_0/ARDroneLib/Soft/Common -c autopilot.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libst