Skip to content

Instantly share code, notes, and snippets.

View jcaxmacher's full-sized avatar
💭
Focused

J Axmacher jcaxmacher

💭
Focused
View GitHub Profile
@jcaxmacher
jcaxmacher / windows_auth.py
Created September 14, 2012 01:33 — forked from ig0774/windows_auth.py
WSGI middleware that provides SPNEGO authentication using the Win32 extensions
from base64 import b64decode, b64encode
from lru_dict import LruDict
import win32api
import win32security
import sspi, sspicon
__all__ = ['WindowsAuth']
def _get_user_name():
'''Uses the Windows API to retrieve the current user name'''
@jcaxmacher
jcaxmacher / inject.py
Last active December 11, 2015 22:18
scope creep
def inject(**vars):
def decorator(fn):
def fun(*args, **kwargs):
gls = globals().copy()
gls.update(vars)
new_fn = type(fn)(fn.__code__, gls)
return new_fn(*args, **kwargs)
return fun
return decorator
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;
body {
font: 12px sans-serif;
}
svg {
margin-top: 50px;
}
.chart rect {
stroke: white;
fill: steelblue;
}
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
/*
Converts any integer into a base [BASE] number. I have chosen 36
as it is meant to represent the integers using case-insensitive alphanumeric
characters, [no special characters] = {0..9}, {A..Za..z}
I plan on using this to shorten the representation of possibly long ids,
a la url shortenters
base36.saturate('5t6C9') takes the base 36 key, as a string, and turns it back into an integer
base36.dehydrate(9759321) takes an integer and turns it into the base 36 string
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 36
# as it is meant to represent the integers using case-insensitive alphanumeric
# characters, [no special characters] = {0..9}, {A..Za..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@jcaxmacher
jcaxmacher / oop.js
Created March 11, 2014 12:38 — forked from rahulkmr/oop.js
function mixin(dest) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var prop in source) {
if (!dest[prop]) {
dest[prop] = source[prop];
}
}
}
}

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

import random
def random_password():
alpha_lower = random.sample('abcdefghijklmnopqrstuvwxyz', 5)
alpha_upper = random.sample('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 10)
num = random.sample('0123456789', 4)
special = random.sample('!@#$%^&*', 4)
full = alpha_upper + alpha_lower + num + special
random.shuffle(full)