Skip to content

Instantly share code, notes, and snippets.

View jdmaturen's full-sized avatar

jd jdmaturen

View GitHub Profile
@jdmaturen
jdmaturen / bg_nbd.py
Created October 16, 2013 05:36
Implementation of the beta-geometric/NBD (BG/NBD) model from '"Counting Your Customers" the Easy Way: An Alternative to the Pareto/NBD Model' (Fader, Hardie and Lee 2005) http://brucehardie.com/papers/018/fader_et_al_mksc_05.pdf and accompanying technical note http://www.brucehardie.com/notes/004/
"""
Implementation of the beta-geometric/NBD (BG/NBD) model from '"Counting Your Customers" the Easy Way: An Alternative to
the Pareto/NBD Model' (Fader, Hardie and Lee 2005) http://brucehardie.com/papers/018/fader_et_al_mksc_05.pdf and
accompanying technical note http://www.brucehardie.com/notes/004/
Apache 2 License
"""
from math import log, exp
import numpy as np
@jdmaturen
jdmaturen / sbg.py
Last active May 1, 2020 19:43
Implementation of the shifted beta geometric (sBG) model from "How to Project Customer Retention" (Fader and Hardie 2006) http://www.brucehardie.com/papers/021/sbg_2006-05-30.pdf Apache 2 License
"""
Implementation of the shifted beta geometric (sBG) model from "How to Project Customer Retention" (Fader and Hardie 2006)
http://www.brucehardie.com/papers/021/sbg_2006-05-30.pdf
Apache 2 License
"""
from math import log
burp:~ jd$ curl --referer http://t.co/ -is i.imgur.com/7RsFUmL.jpg
HTTP/1.1 302 Moved Temporarily
Server: cloudflare-nginx
Date: Wed, 14 Aug 2013 18:58:01 GMT
Content-Type: text/html
Content-Length: 165
Connection: keep-alive
Location: http://imgur.com/7RsFUmL
CF-RAY: 9dfdfc465cb0707
@jdmaturen
jdmaturen / gist:4163044
Created November 28, 2012 18:22
maxgif id samples
6An
80P
2lf
1c6
7zS
1U6
2de
2yZ
2a2
6I8
@jdmaturen
jdmaturen / gist:3627593
Created September 4, 2012 22:44 — forked from argv0/gist:3627514
Markov Chain Thing I Wrote A Long Time Ago
just write something funny, dufus.
The token system is ridiculous because it makes security weaker, by offering a
larger surface area for attack.
If I had to guess, Salesforce is concerned that users are embedding their
passwords into scripts which could be stolen and used outside the company for
other purposes. Why are users putting their passwords in scripts? I imagine
it's because of the web-centric oauth flow coupled with short oauth token
expiration intervals but THATS a different story.
So *within* an authorized set of IP addresses, the regular password works.
<?php
// … 
/**
* Default, shared method for authenticating a connection to AWS.
*
* @param string $operation (Required) Indicates the operation to perform.
* @param array $payload (Required) An associative array of parameters for authenticating. See the individual methods for allowed keys.
* @return CFResponse Object containing a parsed HTTP response.
*/
public function authenticate($operation, $payload)
@jdmaturen
jdmaturen / pbc_pool_transport.py
Created June 20, 2011 23:39
Riak python client PBC connection pooling
import logging
log = logging.getLogger('socrates')
from Queue import Empty, Full, Queue
from riak.transports import RiakPbcTransport
from riak.transports.transport import RiakTransport
class PbcPoolTransport(RiakTransport):
@jdmaturen
jdmaturen / gist:939068
Created April 23, 2011 23:05
Riak resource allocation (rough expansion)
# of keys: 10,000,000
size of key: 60bytes (40bytes bitcask + 20bytes for name)
bounded size of each value: 1k
# of active items (usually per day): 1,000,000 (of course how you determine this number is up for grabs, I suggest measuring)
RF: 3
130% * (1k * 1mm * 3) / 1024**3 ~= 4GB for filesystem cache
130% * (10mm * 60b * 3) / 1024**3 ~= 2GB+ for key space
@jdmaturen
jdmaturen / bucket_client.py
Created April 16, 2011 08:31
riak bucket that manages retries + conflict resolution w/ example increment counter implementation
from riak import RiakError
class Bucket(object):
"""Wrap up retries and conflict resolution"""
def __init__(self, client, name, resolve, retries=5):
self.client = client
self.name = name
self.bucket = client.bucket(name) # base bucket
self.resolve = resolve
self.retries = retries