Skip to content

Instantly share code, notes, and snippets.

View imagescape's full-sized avatar

Imaginary Landscape, LLC imagescape

View GitHub Profile
## models.py
class HourRange(models.Model):
practice = models.ForeignKey(Practice)
rules = rec_fields.RecurrenceField(
help_text='recurrences for this hour range'
)
opening_time = models.TimeField(blank=True, null=True)
closing_time = models.TimeField(blank=True, null=True)
message = models.TextField(blank=True, null=True)
@imagescape
imagescape / UpgradeDjango.md
Last active June 27, 2018 12:16
Upgrade Django from 1.1 to 1.5.1. This highlights some of the issues that one may encounter when updating Django. It's not possible to cover every case, but this should provide a good general starting point.

Upgrade Django from 1.1 to 1.5.1. This highlights some of the issues that one may encounter when updating Django. It's not possible to cover every case, but this should provide a good general starting point.

Change to DATABASES variable in settings.py.

Django now supports multiple databases and changes are needed to how the database connections are defined.

  • Changed in Django 1.2
  • Change Required by Django 1.4
  • Source:
@imagescape
imagescape / Install Openssh from Source
Created April 8, 2013 14:37
Install openssh in an alternate location from source
# We will assume installation in the /opt/ directory
mkdir /opt/openssh/
cd /opt/openssh/
# gather and install the dependencies
wget http://zlib.net/zlib-1.2.7.tar.bz2
tar jxvf zlib-1.2.7.tar.bz2
cd zlib-1.2.7
./configure --prefix=/opt/openssh/dist/
#!/usr/bin/env python
import os, sys, argparse, subprocess
from fabric.api import *
DONESND = os.environ.get('NOTIFY_DONE_SOUND', None)
ERRORSND = os.environ.get('NOTIFY_ERROR_SOUND', DONESND)
DEVNULL = open(os.devnull, 'w')
#!/usr/bin/env python
import os, sys, argparse, subprocess
from fabric.api import *
def get_args():
parser = argparse.ArgumentParser(description='Run bash commands on a remote host. Get notified when its done.')
parser.add_argument('hoststring', type=str, nargs=1,
help='ssh user@host string')
#!/bin/bash
"$@";
notify-send "Complete:" "$*" &
playsound "$NOTIFY_SOUND" > /dev/null &
let b = do OutOfKittens.protect {
do_some_stuff();
that_might_raise();
out_of_kittens();
};
do b.handle |t| {
UseAardvarksInstead
}
package main
import "fmt"
import "time"
import "runtime"
const (
MAX_UPDATES = 50
MAX_FRAMES = 25
)
/proj.bkp3$ git repack -A -d
Counting objects: 1168, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1020/1020), done.
Writing objects: 100% (1168/1168), done.
Total 1168 (delta 687), reused 105 (delta 32)
/proj.bkp3$ git prune
/proj.bkp3$ git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5