Skip to content

Instantly share code, notes, and snippets.

@jamescw
jamescw / generate_id.py
Last active Nov 29, 2016
A simple one way hash function for generating unique IDs from a constant set of personal fields
View generate_id.py
def generate_id(
first_name,
father_name,
last_name,
mother_full_name,
gender,
birthday_day,
birthday_month,
birthday_year
@jamescw
jamescw / gist:1a15baf57528c8ab4ef9
Created Mar 18, 2015
Shape file export for django import export
View gist:1a15baf57528c8ab4ef9
from import_export.formats.base_formats import Format
from shapely.geometry import Point, mapping
from fiona import collection
class SHPFormat(Format):
def get_title(self):
return 'shp'
View gist:6ae15d64459ddd2a451a
number = '07045656789'
def hash_to_digits(num, length=10):
return abs(hash(num)) % (10 ** length)
hash = hash_to_digits(number)
@jamescw
jamescw / vagrant.py
Created May 23, 2012
Create vagrant VMs using fabric
View vagrant.py
from fabric.api import *
def create_local_vm(name=None, image="lucid32"):
if not name:
name = env.project + "_VM"
local("vagrant box add {0} http://files.vagrantup.com/{1}.box".format(name,image))
local("vagrant init {0}".format(name))
@jamescw
jamescw / bootCheck.ino
Created Apr 20, 2012 — forked from jcw/bootCheck.ino
Identify which boot loader is loaded in the ATmega328
View bootCheck.ino
// Detect which type of boot loader is present, using a fixed built-in table
// 2012-03-06 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <avr/pgmspace.h>
#include <util/crc16.h>
#define VERSION "2"
// list of all known boot loaders with their unique signatures
struct { word crc; const char* desc; } signatures[] = {
View gist:1227875
/* JeeNode / JeeNode USB / JeeSMD
-------|-----------------------|----|-----------------------|----
| |D3 A1 [Port2] D5 | |D3 A0 [port1] D4 | |
|-------|IRQ AIO +3V GND DIO PWR| |IRQ AIO +3V GND DIO PWR| |
| D1|TXD| ---- ---- |
| A5|SCL| D12|MISO|+3v | |
| A4|SDA| Atmel Atmega 328 D13|SCK |MOSI|D11 |
| |PWR| JeeNode / JeeNode USB / JeeSMD |RST |GND | |
| |GND| D8 |BO |B1 |D9 |
| D0|RXD| ---- ---- |