Skip to content

Instantly share code, notes, and snippets.

View chrischambers's full-sized avatar

Chris Chambers chrischambers

View GitHub Profile
" Map Interface: {{{2
if !hasmapto('<Plug>SaveWinPosn')
map <unique> <Leader>swp <Plug>SaveWinPosn
endif
python << EOF
import os
import sys
import vim
for p in sys.path:
if os.path.isdir(p):
vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))
EOF
endfunction
cleanup () {
find ./ -name '*~' -or -name '*.pyc' -or -name '#*#' -or -name '.*~' -or -name '.#*' | xargs rm -f
clear
}
# The previous cleanup function is potentially dangerous in an environment where you could have filenames with spaces.
# The safest pattern when using the find... xargs combo is to use null-terminators for filenames, i.e.
`find ... -print0 | xargs -0 ...`:
cleanup () {
Feature: Store information about achievements # achievements.feature:1
In order to manage achievements # achievements.feature:3
As a programmer # achievements.feature:4
I want to model them using the Django ORM # achievements.feature:5
Scenario: Creating simple achievements # achievements.feature:7
Given that I have the following achievement data: # achievement-steps.py:29
| name | teaser | description |
| Bronze Star | The bronze award | This is the third rank |
| Silver Star | The silver award | This is the second rank |
from django.db.models import ForeignKey
from django.contrib.auth.models import User
import threadlocals
class UserField(ForeignKey):
""" UserField
By defaults, foreign key to User; null=True, blank=True
try:
from south.modelsinspector import add_introspection_rules
except ImportError:
add_introspection_rules = False
if add_introspection_rules:
add_introspection_rules([
(
[UserField],
[],
# I need the best idiomatic way of getting a map of users and their points.
# The values/annotation combo *almost* gives me what I want, but doesn't return
# full user objects, only their ids.
>>> Points.objects.values('user').annotate(total_points=Sum('amount'))
[{'total_points': 40, 'user': 1}, {'total_points': 30, 'user': 2}]
# I've opted for something like this, instead:
Points.objects.users().annotate(total_points=Sum('points__amount'))
@chrischambers
chrischambers / gist:1154231
Created August 18, 2011 14:56
Summary, Networking Stuff

IP Addresses:

  • A bit is a BInary digiT. It uses base 2.
  • A byte is 8 bits.
  • An IPv4 address is 4 bytes (32 bits) long. It is usually expressed in decimal notation, i.e. 0-255.0-255.0-255.0-255.
  • IP addresses comprise 2 parts:
This is a quick test of the gist-vim functionality.
More Booyah.
@chrischambers
chrischambers / gist:748467e46db72d6c0dea
Last active June 20, 2018 03:08
Oneshot layer patch (modified for qmk firmware)
from 6c22c5f613adb15b9fe4d31ee70567d05cf127c8 mon sep 17 00:00:00 2001
from: ahtn <ahtn@users.noreply.github.com>
Date: Sun, 18 Oct 2015 17:25:46 +1000
Subject: [PATCH] Adds oneshot layer and oneshot tap toggling
* Adds ACTION_LAYER_ONESHOT
* Adds ONESHOT_TAP_TOGGLE
* Mentions sticky keys in the docs on oneshot.
---
tmk_core/doc/keymap.md | 18 +-