This file contains hidden or 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
#models.py | |
class Task(models.Model): | |
title = models.CharField(max_length=255) | |
description = models.TextField() | |
def __unicode__(self): | |
return self.title | |
This file contains hidden or 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
1. Set keyboard discoverable | |
2. Get the mac address of the bluetooth device: | |
$ hcitool scan | |
3. Create new device: | |
$ sudo bluez-simple-agent hci0 [bluetooth device mac address = XX:XX:XX:XX:XX:XX] | |
which will hopefully return somthing like: | |
DisplayPasskey (/org/bluez/537/hci0/..., [PIN = 123456]) | |
else: | |
$ sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX repair | |
start over |
This file contains hidden or 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 json | |
from crispy_forms.utils import render_crispy_form | |
from django.contrib.auth.models import User | |
from django.shortcuts import render_to_response, render, get_object_or_404 | |
from django.http import HttpResponseRedirect | |
from django.views import generic | |
from django.core.urlresolvers import reverse_lazy | |
from django.http import HttpResponse | |
from django.forms.models import inlineformset_factory |
This file contains hidden or 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
#views.py | |
class TaskUpdateView(generic.UpdateView): | |
model = Task | |
form_class = TaskForm | |
@json_view | |
def dispatch(self, *args, **kwargs): | |
return super(TaskUpdateView, self).dispatch(*args, **kwargs) | |
This file contains hidden or 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
/** | |
* User: goldhand | |
* Date: 8/9/13 | |
* Time: 10:52 PM | |
*/ | |
var tcl = $('#task-category-list').find('ul').each(function(i) { console.log($(this).parent().attr('id')); console.log($(this).sortable('toArray'));}); |
This file contains hidden or 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 sys, os | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cpm.settings") | |
from django.contrib.auth.models import User | |
from projects.models import Project | |
from tasks.models import Task, TaskCategory | |
from changes.models import ChangeOrder | |
from updates.models import Update |
This file contains hidden or 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
# Things I learned dealing with recursive JSON objects | |
This is a summary of my findings while dealing with a django model, TaskCategory. | |
## Two ways for manipulating a set of trees | |
I found two different ways for manipulating objects with an uncertain amount | |
of ascendants / descendants. The first involves manipulating an object within | |
a tree and the second involves taking apart the tree, manipulating the branches | |
and building a new tree |
This file contains hidden or 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.db import models | |
class Slugged(models.Model): | |
title = models.CharField(max_length=500) | |
slug = models.CharField(max_length=2000, blank=True, null=True) | |
class Meta: | |
abstract = True |
This file contains hidden or 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 check_conditions(conditions={}, D={}): | |
for key in conditions: | |
if D[key] == conditions[key]: | |
continue | |
else: | |
return False | |
return True | |
def get_dict_from_list(DL=[], conditions=[], i=0, children_key='children'): | |
""" |
OlderNewer