Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from facebook_analytics_service.tasks import *
all_latency = [(timezone.now() - x).seconds for x in AdAccount.objects.filter(adcreative_last_crawled__isnull=False, should_crawl=True).values_list('adcreative_last_crawled', flat=True)]
max(all_latency)
@leetreveil
leetreveil / index.js
Created August 19, 2014 15:44
requirebin sketch
var musicmetadata = require('musicmetadata');
addDragDropListener(document, function (files) {
musicmetadata(files[0], { duration: true })
.on('metadata', function (result) {
console.log(result);
if (result.picture.length > 0) {
var picture = result.picture[0];
var url = URL.createObjectURL(new Blob([picture.data], {'type': 'image/' + picture.format}));
var image = document.createElement('img');
@leetreveil
leetreveil / gist:47f8cae575ef7db08cb2
Last active November 20, 2015 13:36
List duplicate celery tasks in redis queues
""" List duplicate celery tasks in redis queues """
import datetime
import redis
import json
import base64
import pickle
from collections import Counter
import argparse
import sys
@leetreveil
leetreveil / start-mongo-replset.sh
Last active December 8, 2023 06:34
Shell scripts to create a mongodb replica set and sharded cluster locally
#!/bin/bash
# shell script to create a simple mongodb replica set (tested on osx)
set -e
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
default=$(tput sgr0)
@leetreveil
leetreveil / gist:4647978
Created January 27, 2013 11:40
musicmetadata read from network
var http = require('https');
var musicmetadata = require('musicmetadata');
http.get('https://dl.dropbox.com/u/1269592/Into%20The%20Back%20%28WORNG%20Remix%29.mp3', function (res) {
var parser = new musicmetadata(res);
parser.on('metadata', function (result) {
console.log(result);
});
parser.on('done', function (err) {
if (err) throw err;
@leetreveil
leetreveil / benchbulk.sh
Created September 7, 2012 16:07 — forked from jchris/benchbulk.sh
benchmarking CouchDB bulk inserts in bash
#!/bin/bash
# usage: time benchbulk.sh dbname
# it takes about 30 seconds to run on my old MacBook
BULKSIZE=1000
DOCSIZE=100
INSERTS=10
ROUNDS=10
DBURL="http://localhost:5984/$1"
@leetreveil
leetreveil / gist:1959198
Created March 2, 2012 15:33
unable to load shared lib...
test: test.obj
g++ test.o -o kdssvolumeinfo_node.node -L/usr/local/lib $(KDSS_SLIB_NAME) -shared
test.obj:
g++ $(CPPLAGS) $(CFLAGS) -g -fPIC -DPIC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DEV_MULTIPLICITY=0 $(INCLDIRS) -I/usr/local/include/node kdssvolumeinfo_node.cpp -c -o test.o
wchar_t* command = L"my command";
int len = wcslen(command) + 1;
wchar_t* w_msg = (wchar_t*)malloc(sizeof(wchar_t) * len);
wcscpy(w_msg, command);
free(w_msg);
@leetreveil
leetreveil / gist:1092829
Created July 19, 2011 15:44
Change the author of a specific commit (git)
git filter-branch -f --env-filter 'if [[ "$GIT_COMMIT" = "119900cd7054c64f2b8e4774e59afbfc39a28e73" ]]; then export GIT_COMMITTER_NAME="Lee Treveil" GIT_AUTHOR_NAME="Lee Treveil" GIT_COMMITTER_EMAIL="leetreveil@gmail.com" GIT_AUTHOR_EMAIL="leetreveil@gmail.com"; fi' HEAD