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
sudo apt-get install graphviz | |
pip install django-extensions | |
pip install pygraphviz | |
# add 'django_extensions' to INSTALLED_APPS | |
# all models from INSTALLED_APPS (django too) | |
./manage.py graph_models -a -g -o my_project.png | |
# just two apps: emailing and localization |
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
This should be located in: yourapp/management.py | |
from django.db.models.signals import post_syncdb | |
from django.contrib.auth import models as auth_models | |
from django.contrib.auth.models import User, Permission | |
from django.contrib.contenttypes.models import ContentType | |
def create_supervision_permissions(sender, **kwargs): | |
print '== create_supervision_permissions ==' | |
# create a content type for the app if it doesn't already exist |
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
private static final int EASTER_EGG_COUNT = 7; | |
private static final long EASTER_EGG_DURATION = 1000; | |
/** Easter egg click counter */ | |
private int mEasterEggClickCount = 0; | |
/** Easter egg first click timestamp */ | |
private long mEasterEggStart = -1; |
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 optparse import OptionParser | |
from myapp.management.commands import my_command | |
def make_test_wrapper_for(command_module): | |
def _run_cmd_with(*args): | |
"""Run the possibly_add_alert command with the supplied arguments""" | |
cmd = command_module.Command() | |
(opts, args) = OptionParser(option_list=cmd.option_list).parse_args(list(args)) | |
cmd.handle(*args, **vars(opts)) |
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
# encrypt.py | |
import os, random, struct | |
from Crypto.Cipher import AES | |
def encrypt_file(key, in_filename, out_filename=None, chunksize=64*1024): | |
""" Encrypts a file using AES (CBC mode) with the | |
given key. | |
key: | |
The encryption key - a string that must be |
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 Crypto.Cipher import AES | |
import base64 | |
import hashlib | |
import os | |
# the block size for the cipher object; must be 16, 24, or 32 for AES | |
BLOCK_SIZE = 32 | |
# the character used for padding--with a block cipher such as AES, the value | |
# you encrypt must be a multiple of BLOCK_SIZE in length. This character is |
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
pallet: defnode macro | |
list: | |
os-family | |
location-id | |
architecture | |
image-id | |
hardware-id | |
os-name-matches | |
os-version-matches |
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=> (require 'clojure.edn) | |
nil | |
user=> (slurp "stored-array.dat") | |
"[1 2 3 4]\n" | |
user=> (clojure.edn/read-string (slurp "stored-array.dat")) | |
[1 2 3 4] |
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
(defn partition-with | |
[f coll] | |
{:pre [(fn? f) (coll? coll)]} | |
(let [coll (partition-by f coll) | |
coll (partition 2 coll) | |
coll (map #(concat (first %) (second %)) coll) | |
] | |
coll)) | |
(defn partition-on |
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
#! /bin/sh | |
# | |
# skeleton example file to build /etc/init.d/ scripts. | |
# This file should be used to construct scripts for /etc/init.d. | |
# | |
# Written by Miquel van Smoorenburg <[email protected]>. | |
# Modified for Debian | |
# by Ian Murdock <[email protected]>. | |
# Further changes by Javier Fernandez-Sanguino <[email protected]> | |
# |