Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
mostly moved to gitlab

Sam Thompson georgedorn

💭
mostly moved to gitlab
View GitHub Profile
@georgedorn
georgedorn / therm.py
Created Aug 23, 2017 — forked from ghostbitmeta/therm.py
Python script to control Honeywell Thermostat's through My Total Connect
View therm.py
#!/usr/bin/python
# By Brad Goodman
# http://www.bradgoodman.com/
# brad@bradgoodman.com
####################### Fill in settings below #######################
USERNAME="your@emailaddress.com"
PASSWORD="your_total_comfort_password"
@georgedorn
georgedorn / opencv_OSX.sh
Created Oct 31, 2016 — forked from chintak/opencv_OSX.sh
OpenCV with a Virtualenv
View opencv_OSX.sh
# Installing OpenCV python libs on mac to work with virtualenv
# OpenCV 2.4.3
# Python 2.7.3 installed with brew
# assuming you have virtualenv, pip, and python installed via brew
# assuming $WORKON_HOME is set to something like ~/.virtualenvs
# using homebrew - make sure we're current
brew update
@georgedorn
georgedorn / get_event_types.py
Last active Oct 19, 2016
Parses a python codebase to find all event_types along with event_name subtypes where appropriate.
View get_event_types.py
import json
import random
import re
import sys
from pprint import pprint
from subprocess import check_output
from collections import defaultdict
View TastypieFieldsOrder.py
import json
from collections import OrderedDict
from tastypie.serializers import Serializer
from tastypie import fields
from tastypie.resources import Resource
from django.core.serializers.json import DjangoJSONEncoder
class OrderedSerializer(Serializer):
def to_json(self, data, options=None):
options = options or {}
@georgedorn
georgedorn / stat_analysis.py
Created Nov 28, 2012
Analysis of Random vs Point-Buy for Rolemaster Playtest
View stat_analysis.py
"""
Rolls up a huge number of rolemaster characters,
calculates the equivalent values using point-buy,
aggregates the results.
"""
number_of_rolls_per_stat = 3
minimum_stat_roll = 11
number_of_characters = 100000 #pretty consistant at this number, use more if you feel like it
View autodj.bookmarklet.js
javascript:(function(g,d,f){if(f)d.info("Session found:",f);else return d.warn("No session found!");var h={check:10,wait:500},b=g.autodj={api:g[f],available:function(a){return b.api.taken_dj_map[a]<0},spot:function(){return b.api.become_dj.data("spot")},become:function(a){b.api.callback("become_dj",a)},waiter:function(a){return function(){return b.available(a)?(b.become(a),a):(-1)}},seated:function(a){return b.api.djs[a]&&b.api.djs[a][0]===b.api.myuserid},wait:function(a,c){var e=c!==void 0,
a=a||h.check,c=c||b.spot();b.seated(c)?d.warn("Spot",c,"taken!"):(e&&d.error("Spot",c,"missed. Restarting..."),d.info("Polling @",a,"ms"),b.check(a,b.waiter(c)))},check:function(a,c){setTimeout(function(){var e=c.call(b);e>0?(d.warn("Spot",e,"open..."),setTimeout(function(){b.wait(a,e)},h.wait)):b.check(a,c)},a)}}})(window,console,function(g,d,f,h,b,a,c,e,i,j,k){try{return g(d)[f](h)[b][a][c][e]()[i](j)[k]}catch(l){return null}}(jQuery,".invite_dj","data","events","click",0,"handler","toString","match",
/\{\s*(.+)\./,1));
@georgedorn
georgedorn / gist:1240964
Created Sep 25, 2011
UpdateView that handles "create" as well
View gist:1240964
from myapp.models import MyModel, RelatedModel
from django.views.generic import UpdateView
class ModelCreateUpdateView(UpdateView):
model = MyModel
def get_object(self, *args, **kwargs):
related_id = self.kwargs.get('related_id')
related_model = RelatedModel.objects.get(pk=related_id)
@georgedorn
georgedorn / snatchdj.js
Created Sep 25, 2011
Fast grab of DJ slot on Turntable.fm
View snatchdj.js
var is_dj = false;
var timeout_handler = 0;
function get_slot(){
if(is_dj){
if (timeout_handler){
clearInterval(timeout_handler);
}
return;
}
View gist:1085640
index 146ac15..647a826 100644
--- a/tests/core/tests/resources.py
+++ b/tests/core/tests/resources.py
@@ -1404,6 +1404,24 @@ class ModelResourceTestCase(TestCase):
self.assertTrue("resource_uri" in data)
self.assertTrue("title" in data)
self.assertTrue("is_active" in data)
+
+ def test_post_list_duplicate(self):
+ self.assertEqual(Note.objects.count(), 6)
You can’t perform that action at this time.