This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====== 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unsign_value(signature, value) | |
{ | |
var hmac = crypto.createHmac('sha1', CONFIG.secret_key); | |
hmac.update(value); | |
return signature === hmac.digest('hex'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function build_absolute_url(req) { | |
var protocol = req.socket.encrypted ? 'https' : 'http', | |
host = req.headers.host || '<no host>'; | |
return protocol+'://'+host+req.url; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |