Skip to content

Instantly share code, notes, and snippets.

View mjrusso's full-sized avatar

Michael Russo mjrusso

View GitHub Profile
# pyres/failure/redis.py
@classmethod
def all(cls, resq, start=0, count=1):
items = resq.redis.lrange('resque:failed', start, count) or []
ret_list = []
for i in items:
failure = ResQ.decode(i)
failure['redis_value'] = base64.b64encode(i)
ret_list.append(failure)
# pyres ResQ list_range
def list_range(self, key, start, count, decode=True):
items = self.redis.lrange(key, start,start+count-1) or []
ret_list = []
for i in items:
if decode: i = ResQ.decode(i)
ret_list.append(i)
return ret_list
@mjrusso
mjrusso / sha1.js
Created March 27, 2010 20:35 — forked from jed/sha1.js
/* adapted by Jed Schmidt for use as a node.js module.
* the following node.js adapter code is MIT-licensed.
*
* Example usage:
*
* var sha1 = require("sha1.js"), hash;
*
* my_sha1 = sha1.hex( data );
* my_hmac_sha1 = sha1.hex( key, data );
*
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
[67/67] cxx_link: build/default/src/node_4.o build/default/src/node_buffer_4.o build/default/src/node_http_parser_4.o build/default/src/node_net2_4.o build/default/src/node_io_watcher_4.o build/default/src/node_child_process_4.o build/default/src/node_constants_4.o build/default/src/node_cares_4.o build/default/src/node_events_4.o build/default/src/node_file_4.o build/default/src/node_signal_watcher_4.o build/default/src/node_stat_watcher_4.o build/default/src/node_stdio_4.o build/default/src/node_timer_4.o build/default/src/node_script_4.o build/default/src/node_crypto_4.o build/default/deps/c-ares/ares_expand_string_1.o build/default/deps/c-ares/ares_library_init_1.o build/default/deps/c-ares/ares_destroy_1.o build/default/deps/c-ares/ares_mkquery_1.o build/default/deps/c-ares/ares_options_1.o build/default/deps/c-ares/ares_cancel_1.o build/default/deps/c-ares/ares_parse_aaaa_reply_1.o build/default/deps/c-ares/ares_process_1.o build/default/deps/c-ares/ares_free_string_1.o build/default/deps/c-ares/ares_pa
[66/66] cxx_link: build/default/src/node_4.o build/default/src/node_buffer_4.o build/default/src/node_http_parser_4.o build/default/src/node_net2_4.o build/default/src/node_io_watcher_4.o build/default/src/node_child_process_4.o build/default/src/node_constants_4.o build/default/src/node_cares_4.o build/default/src/node_events_4.o build/default/src/node_file_4.o build/default/src/node_signal_watcher_4.o build/default/src/node_stat_watcher_4.o build/default/src/node_stdio_4.o build/default/src/node_timer_4.o build/default/src/node_script_4.o build/default/deps/c-ares/ares_expand_string_1.o build/default/deps/c-ares/ares_library_init_1.o build/default/deps/c-ares/ares_destroy_1.o build/default/deps/c-ares/ares_mkquery_1.o build/default/deps/c-ares/ares_options_1.o build/default/deps/c-ares/ares_cancel_1.o build/default/deps/c-ares/ares_parse_aaaa_reply_1.o build/default/deps/c-ares/ares_process_1.o build/default/deps/c-ares/ares_free_string_1.o build/default/deps/c-ares/ares_parse_srv_reply_1.o build/default/de
@mjrusso
mjrusso / redis-transactions-demo.py
Created October 29, 2010 01:03
Redis transactions demonstration
# Redis transactions demonstration.
# See the following thread on the Redis mailing list for background:
# http://groups.google.com/group/redis-db/browse_thread/thread/8a981b3fd76f8f41
# Output is included in comments below the code.
import redis
def do(r):
r.watch('mykey1')
txn = r.pipeline()
@mjrusso
mjrusso / daily-events-aggregate.hql
Created January 18, 2012 22:43
Measuring User Retention with Hadoop and Hive
select
eventsAggregate.publicationId,
eventsAggregate.userId,
eventsAggregate.deviceModel,
eventsAggregate.eventType,
eventsAggregate.eventDate,
to_date(subs.activationTime) as activationDate,
datediff(eventsAggregate.eventDate, to_date(subs.activationTime)) as eventDay,
eventsAggregate.count
from (
### Keybase proof
I hereby claim:
* I am mjrusso on github.
* I am mjrusso (https://keybase.io/mjrusso) on keybase.
* I have a public key whose fingerprint is C64C 76BF 297F 6C1F DEC8 76D5 B3EF 65A8 D05F 2580
To claim this, I am signing this object:
@mjrusso
mjrusso / ViewController.swift
Created April 15, 2020 00:01
iPadOS 13.4: ImageCaptureCore's ICCameraFile `requestReadData(atOffset:length:completion:)` always passes empty Data object to completion block
import UIKit
import ImageCaptureCore
import MobileCoreServices
class ViewController: UIViewController {
var deviceFinder = DeviceFinder()
override func viewDidLoad() {
super.viewDidLoad()