Skip to content

Instantly share code, notes, and snippets.

View mattrobenolt's full-sized avatar
🀠
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”

Matt Robenolt mattrobenolt

🀠
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”
View GitHub Profile
$fh = fopen($box->download_url('862161200'), 'r'); // Open box.net file
$tmp = tempnam(sys_get_temp_dir(), 'DOC'); // create tmp file
print_r($tmp);
echo '<br />';
$tfh = fopen($tmp, 'w');
fwrite($tfh, fread($fh, 13421772)); // write bytes from box.net file to tmp file
fseek($tfh, 0);
// Then load tmp file into ZipArchive->open() and use this function:
http://www.botskool.com/geeks/how-extract-text-docx-or-odt-files-using-php
import xbmc
import xbmcgui
METHODS = ("Director", "Genre", "TagLine", "Plot", "PictureURL", "Title", "OriginalTitle", "Votes", "Cast", "File", "Path", "IMDBNumber", "Year", "Premiered", "FirstAired", "Rating", "PlayCount", "LastPlayed")
class OpenGraphPlayer(xbmc.Player) :
def __init__ (self):
xbmc.Player.__init__(self)
def onPlayBackStarted(self):
@mattrobenolt
mattrobenolt / Redis benchmark on 256MB
Created October 13, 2011 14:41
Redis benchmarks on Rackspace Cloud servers
====== PING (inline) ======
10000 requests completed in 0.28 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.57% <= 1 milliseconds
100.00% <= 1 milliseconds
35211.27 requests per second
/*
* This is how we have to do it now.
*/
var buffers = [];
var nread = 0;
something.on('data', function(chunk) {
buffers.push(chunk);
nread += chunk.length;
});
function unsign_value(signature, value)
{
var hmac = crypto.createHmac('sha1', CONFIG.secret_key);
hmac.update(value);
return signature === hmac.digest('hex');
}
var secret_key = 'abcdefghijklmnopqrstuvwxyz';
var hash = crypto.createHash('sha1');
hash.update(secret_key);
console.log(unsign_value('8a8d431c4bee603699e3fd3e9593a3264af0f57c', 'value1'));
function unsign_value(signature, value)
{
var hmac = crypto.createHmac('sha1', hash.digest());
hmac.update(value);
console.log(signature);
function build_absolute_url(req) {
var protocol = req.socket.encrypted ? 'https' : 'http',
host = req.headers.host || '<no host>';
return protocol+'://'+host+req.url;
}
def qs_to_dict(qs, exclude=(), func=None):
return [model_to_dict(model, exclude, func) for model in qs]
def model_to_dict(model, exclude=(), func=None):
result = {}
fields = [field.name for field in model._meta.fields if field.name not in exclude]
if callable(func):
for field in fields:
key = func(field)
if key:
from django.core.cache import cache
class CacheTransactionMiddleware(object):
"""Queues up set and delete calls so they can be executed in bulk.
This middleware queues up cache.set and cache.delete calls into
one big set_many or delete_many call at the end of the request
life cycle. This can drastically improve latency especially when
many many calls are executed in loops.
"""
var SimpleStream = function(){
Stream.call(this);
this.readable = true;
};
util.inherits(SimpleStream, Stream);
SimpleStream.prototype.write = function(chunk) {
this.emit('data', chunk);
};
SimpleStream.prototype.end = function() {
this.emit('end');