Skip to content

Instantly share code, notes, and snippets.

View Kobold's full-sized avatar

Andy Kish Kobold

  • TenantBase
  • Santa Monica, CA
View GitHub Profile
@Kobold
Kobold / README.md
Last active August 29, 2015 14:06
Obfuscate primary keys

Obfuscating primary keys

Often you'll want urls that are not authenticated, yet are not easily guessed. Giving each of your models a UUID is one approach. Another elegant approach is to use a block cipher to "encrypt" a unique identifier like the primary key (PK).

Let's sketch out what properties a good solution for PK obfuscation has:

  • Generates a one to one mapping between all PKs and obfuscated PKs, with no possibility of collision.
  • Not easily possible for an attacker to determine the obfuscated PK given a PK and vice versa.
  • Reversible, i.e. the originator can determine the original PK given an obfuscated PK.
@Kobold
Kobold / webpack.config.js
Created September 10, 2014 04:14
An example webpack config that I'm not sure handles external dependencies correctly.
var path = require('path');
module.exports = {
entry: {
module1: './static/js/module1.js',
module2: './static/jsx/module2.jsx',
module3: [
'./static/vendor/drop/drop.min.js',
'./static/vendor/jquery-timepicker-jt/jquery.timepicker.js',
'./static/jsx/module3.jsx',
@Kobold
Kobold / knight_moves.py
Created September 8, 2014 02:19
A python sketch aiming to find optimal play for the Big Brother S16 Knight Moves competition.
""""
A quick sketch aiming to find optimal play for the Big Brother S16 Knight Moves
competition. As it stands, this python version is waaay to slow.
Videos of the competition:
* http://www.cbs.com/shows/big_brother/video/fOLeybDVKA8LopMlgTZj05M__wPnnYMI/big-brother-knight-moves/
* https://tv.yahoo.com/video/big-brother-knight-moves-015945588-cbs.html
wins found per second
{2: 343036, 3: 527582, 4: 383558} 11259.6712734