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/bash | |
# Record work @ current time with message | |
if [ ! -n "$1" ] | |
then | |
echo "give a message!" | |
exit | |
fi |
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
# Terminal color definitions | |
class fg: | |
BLACK = '\033[30m' | |
RED = '\033[31m' | |
GREEN = '\033[32m' | |
YELLOW = '\033[33m' | |
BLUE = '\033[34m' | |
MAGENTA = '\033[35m' | |
CYAN = '\033[36m' |
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
from django import http | |
from mainsite import settings | |
class MaintenanceMiddleware(object): | |
"""Serve a temporary redirect to a maintenance url in maintenance mode""" | |
def process_request(self, request): | |
if getattr(settings, 'MAINTENANCE_MODE', False) == True and hasattr(settings, 'MAINTENANCE_URL'): | |
return http.HttpResponseRedirect(settings.MAINTENANCE_URL) | |
return None |
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
# in case branchA is not our current branch | |
git checkout branchA | |
# make merge commit but without conflicts!! | |
# the contents of 'ours' will be discarded later | |
git merge -s ours branchB | |
# make temporary branch to merged commit | |
git branch branchTEMP |
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
def rotate(seq, n): | |
return seq[n:] + seq[:n] | |
diatonic = [2, 2, 1, 2, 2, 2, 1] | |
ionian = rotate(diatonic, 0) | |
dorian = rotate(diatonic, 1) | |
phrygian = rotate(diatonic, 2) | |
lydian = rotate(diatonic, 3) | |
mixolydian = rotate(diatonic, 4) |
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
editor.on('paste', function(e) { | |
if (e.editor.getData() == "") | |
e.editor.setData(e.data.html) | |
}) |
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
-- Fast functions for working with binary data | |
return { | |
decode_uint8 = function(str, ofs) | |
ofs = ofs or 0 | |
return string.byte(str, ofs + 1) | |
end, | |
decode_uint16 = function(str, ofs) | |
ofs = ofs or 0 | |
local a, b = string.byte(str, ofs + 1, ofs + 2) |
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
local binary = require 'shared.binary' | |
-- Datagram format | |
-- | |
-- uint32 seq Sequence number of the packet | |
-- uint32 ack Last acknowledged sequence number of remote channel | |
-- uint16 fragment_ofs Offset of fragment | |
-- uint16 fragment_len Length of fragment, zero if single message | |
-- uint8 cmd Command (see command.lua) | |
--- binary data Arbitrary data |
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 NestedLazyModelField(serializers.ModelSerializer): | |
""" | |
Use this class for defining a nested relationship based on a funciton | |
instead of an attribute. | |
For example, 'get_profile' method of user | |
""" | |
def field_to_native(self, obj, field_name): | |
obj = getattr(obj, self.source or field_name) |
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 BaseModelResource(ModelResource): | |
@classmethod | |
def get_fields(cls, fields=None, excludes=None): | |
""" | |
Unfortunately we must override this method because tastypie ignores 'blank' attribute | |
on model fields. | |
Here we invoke an insane workaround hack due to metaclass inheritance issues: | |
http://stackoverflow.com/questions/12757468/invoking-super-in-classmethod-called-from-metaclass-new | |
""" |
OlderNewer