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 CachedChoiceFieldOptionsMixin(object): | |
""" | |
This class speeds up performance of inline foreign-key pickers so we don't have to re-query the options for each item in the list | |
""" | |
cached_choice_fields = [] | |
def formfield_for_dbfield(self, db_field, **kwargs): | |
request = kwargs['request'] | |
formfield = super(CachedChoiceFieldOptionsMixin, |
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 | |
# Inputs: | |
# $1 = cluster | |
# $2 = node | |
# $3 = service | |
# $4 = tags | |
# $5 = uuid | |
# $6 = heartbeat_frequency_seconds |
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 | |
# Example Usage: | |
# test.sh 'cluster-id' 'node-id' 'my-fancy-app' 'tag-a,tag-b' 'cluster-id-node-id-my-fancy-app-unit-test-a' 'false' 'Unit Test A is failing because of X' | |
# test.sh 'cluster-id' 'node-id' 'my-fancy-app' 'tag-a,tag-b' 'cluster-id-node-id-my-fancy-app-unit-test-a' 'true' 'Unit Test A is passing' | |
# Example Usage - same service but different UUID tests: | |
# test.sh 'cluster-id' 'node-id' 'nginx' 'tag-a,tag-b' 'cluster-id-node-id-nginx-https-test' 'false' 'HTTPS not working on NGINX' | |
# test.sh 'cluster-id' 'node-id' 'nginx' 'tag-a,tag-b' 'cluster-id-node-id-nginx-port-test' 'false' 'NGINX is not running on port 80' | |
# test.sh 'cluster-id' 'node-id' 'nginx' 'tag-a,tag-b' 'cluster-id-node-id-nginx-memory' 'false' 'NGINX is using too much memory' |
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
/* | |
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
#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 |