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
import os | |
import json | |
import urllib | |
import requests | |
from oauth2client.service_account import ServiceAccountCredentials | |
from django.core.management.base import BaseCommand, CommandError | |
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
#Formats time differences in Python | |
def timesince(self, start=None, end=None, timesuffix='ago', instant_label='Just now'): | |
if not end: | |
end = timezone.now() | |
if not start: | |
start = self.start_time | |
dt = end - start |
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
/* | |
USAGE: | |
Fullscreen mode for Django Ace doesn't work correctly because the CSS isn't quite compatible with Django Grappelli's. | |
To work around it, place this file in a static directory and include in admin like so: | |
@admin.register(MyModel) | |
class MyModelAdmin(admin.ModelAdmin): | |
class Media: | |
css = { | |
'all': ('admin/django_ace_grappelli.css',) |
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
int ledPin1 = 27; | |
int ledPin2 = 0; | |
int ledPin3 = 1; | |
int ledPin4 = 14; | |
int ledPin5 = 15; | |
int ledPin6 = 16; | |
int ledPin7 = 24; | |
int ledPin8 = 25; |
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 | |
GIT_DIR="/srv/project-name/src/" | |
#First update the repo | |
git --git-dir=$GIT_DIR.git --work-tree=$GIT_DIR fetch | |
git --git-dir=$GIT_DIR.git --work-tree=$GIT_DIR reset --hard origin/master | |
echo "Pulled latest code from origin/master" | |
#Manage virtual environment |
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 | |
GIT_DIR="/srv/project-name/src/" | |
RESTART_SCRIPT="sh /etc/project-name/deploy.sh" | |
SLACK_WEBHOOK="https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXXXXXXXX" | |
SLACK_CHANNEL="#development" | |
echo "Fetching..." | |
git --git-dir=$GIT_DIR.git --work-tree=$GIT_DIR fetch |
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
import hashlib | |
from django.db import models | |
from django.db.models.fields.files import FileDescriptor, FieldFile, ImageFieldFile, ImageFileDescriptor | |
""" | |
USAGE: | |
file = MD5FileField(md5_field='md5') | |
md5 = models.CharField(max_length=255) #NOTE - this field must come AFTER file field to be processed correctly. | |
""" |
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
/* | |
First few bars of Frolic from Curb Your Enthusiasm | |
Requires pitches.h | |
nina@ninalp.com | |
*/ | |
#include "pitches.h" | |
const int speakerPinMelody = 9; | |
const int speakerPinTweeter = 10; /* not really necessary; just for comedic effect */ |
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
/* | |
First few bars of Gymnopedia No 1 - very very roughly | |
Requires pitches.h | |
nina@ninalp.com | |
*/ | |
#include "pitches.h" | |
const int speakerPinMelody = 3; |
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
// Specifically for use with the Adafruit Feather, the pins are pre-set here! | |
// include SPI, MP3 and SD libraries | |
#include <SPI.h> | |
#include <SD.h> | |
#include <Adafruit_VS1053.h> | |
// These are the pins used | |
#define VS1053_RESET -1 // VS1053 reset pin (not used!) |