Skip to content

Instantly share code, notes, and snippets.

View Dowwie's full-sized avatar

Darin Gordon Dowwie

View GitHub Profile
@Dowwie
Dowwie / gist:08f3766276cb7ff56845
Created December 18, 2014 18:25
pyshiro : porting Apache Shiro 1.2.3 to Python 3
I'm working full time porting the vast majority of Apache Shiro, a robust security management platform-framework written in Java, to Python 3. Porting is a massive undertaking and I could use some help. I'm working as quickly as possible, making things pythonic as I go. Interfaces and abstract objects will come last and any major refactoring will come even later. I have to get my arms around this beast first.
email me at dkcdkg@gmail.com if you are interested in working together on this project
thanks to Les and Apache for making Shiro happen
It's not a question of *IF* this porting project will finish but *WHEN* -- the sooner I get help, the sooner the python community can benefit
@Dowwie
Dowwie / gist:218ca26ea08d399785a1
Created February 12, 2015 15:45
How do YOU copy your dicts?
import timeit
import copy
from statistics import median, mean, stdev
def dictcopy1():
a = {'one': 1, 'two': 2, 'three': 3}
b = dict(a)
return b
@Dowwie
Dowwie / marshmallow_example.py
Created July 26, 2015 22:58
Marshmallow Full Example
from marshmallow import fields, Schema, pprint
from abc import ABCMeta, abstractmethod
class Serializable(metaclass=ABCMeta):
@classmethod
@abstractmethod
def serialization_schema(cls):
"""
@Dowwie
Dowwie / gist:40c73ad49f2d109a7b7c
Last active November 12, 2015 16:41
Memoized Property Performance Test
import timeit
class reify(object):
def __init__(self, wrapped):
self.wrapped = wrapped
try:
self.__doc__ = wrapped.__doc__
except: # pragma: no cover
pass
@Dowwie
Dowwie / keybase.md
Last active October 26, 2018 12:21

Keybase proof

I hereby claim:

  • I am dowwie on github.
  • I am dowwie (https://keybase.io/dowwie) on keybase.
  • I have a public key ASCP2ZdSKPFGdm0BB6qVpYSEy4MYa8s29VooXlJn-9gnSgo

To claim this, I am signing this object:

@Dowwie
Dowwie / main.py
Last active January 18, 2017 20:31
Experimenting with refactoring permission authorization with a Rust implementation (thus far, a Rust integration is slower)
# works for python 2.7
import ctypes
import timeit
rustLib = "./libauthz.so"
assigned_perms = ["domain1:action3:target1", "domain1:action1,action2", "domain1:action4:target2"]
required_perm = "domain1:action4:target3"
def testRust():
@Dowwie
Dowwie / authz.go
Created January 21, 2017 18:38
experimenting with refactoring yosai permission authorization checks using Go
package main
import (
"C"
"fmt"
"strings"
"gopkg.in/fatih/set.v0"
)
type Permission struct {
@Dowwie
Dowwie / fast.md
Created January 27, 2017 15:12 — forked from hemanth/fast.md
Guido van Rossum's Tips for fast Python

Guido van Rossum11 Sep 2012 - Public

Some patterns for fast Python. Know any others?

  • Avoid overengineering datastructures. Tuples are better than objects (try namedtuple too though). Prefer simple fields over getter/setter functions.

  • Built-in datatypes are your friends. Use more numbers, strings, tuples, lists, sets, dicts. Also check out the collections library, esp. deque.

  • Be suspicious of function/method calls; creating a stack frame is expensive.

@Dowwie
Dowwie / working_with_pg_time.py
Last active June 9, 2017 17:13
A Python implementation of Craig Kerstiens's blog post, "Working with Time"
"""
This is a python implementation of Craig Kerstiens blog post:
http://www.craigkerstiens.com/2017/06/08/working-with-time-in-postgres/
"""
from random import randint
import functools
from datetime import datetime
import numpy as np
from arrow import Arrow
@Dowwie
Dowwie / bench_maplit_hash.rs
Last active January 8, 2018 17:48
bench_maplit_hash.rs
#![feature(test)]
extern crate test;
#[macro_use] extern crate bencher;
#[macro_use] extern crate maplit;
use test::Bencher;
use std::collections::HashSet;
fn test_maplit() -> HashSet<&'static str> {