Skip to content

Instantly share code, notes, and snippets.

View camsom's full-sized avatar

Cameron Lowe camsom

View GitHub Profile
DEBUG = os.getenv('DEBUG', False)
STATIC_ROOT = 'static'
STATIC_URL= '/static/'
if DEBUG==False:
STATIC_URL = 'http://{0}.s3.amazonaws.com/'.format(AWS_S3_BUCKET)
CREATE_TABLE_STATEMENTS = {
'achievement_achievement':
'''CREATE TABLE achievement_achievement
(
id int,
title varchar(255),
description text
);
''',
'task_task':
class CreateRetrieveUpdateDestroyApplication(
generics.CreateAPIView, generics.RetrieveUpdateDestroyAPIView):
def post(self, request):
serializer = CompletedAchievementCreateSerializer(data=request.DATA)
if serializer.is_valid():
achievement = Achievement.objects.get(id=serializer.data['achievement'])
stakeholder = Stakeholder.objects.get(id=serializer.data['stakeholder'])
try:
CompletedAchievement.objects.create(
achievement=achievement,
base_task = Task.objects.create(institution=None, **bullshit_data)
for institution in Institution.objects.all():
new_task = base_task
new_task.pk = None
new_task.institution = institution
new_task.save()
def __init__(self, *args, **kwargs):
for k, v in kwargs:
setattr(self, k, v)
def __init__(self, *args, **kwargs):
self.first_name = kwargs.pop('first_name', None)
self.last_name = kwargs.pop('last_name', None)
self.email = kwargs.pop('email', None)
def __init__(self, first_name=None, last_name=None, email=None):
@camsom
camsom / gist:2acdf544da4bdf6c9fb0
Created September 25, 2014 18:38
upstart for a knucklehead
#!/bin/sh
start on (filesystem)
stop on runlevel [016]
script
. /var/lib/cloud/instance/user-data.txt
chdir /home/ubuntu/NextTier-Achievement-Worker
. /home/ubuntu/venv/bin/activate
exec python /home/ubuntu/NextTier-Achievement-Worker/worker.py
SELECT * FROM date_table WHERE rankscore();
CREATE FUNCTION rank_score() RETURNS decimal as $$
BEGIN
return date_table.birthday + interval '50 days'
END; $$
@camsom
camsom / gist:3f9052fae8f75963bb07
Created October 16, 2014 17:55
Dockerfile for my dump go project
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y curl git bzr
RUN curl -s https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz
ENV PATH /usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
ENV GOPATH /go
ENV GOROOT /usr/local/go
# build
sudo docker build -t pokerap .
# run
sudo docker run -v /dev/log:/dev/log pokerap /go/bin/gokerap
# check syslog
sudo tail /var/log/syslog
# here are the cool lines I like