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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""Simple async crawler/callback queue based on gevent.""" | |
import traceback | |
import logging | |
import httplib2 | |
import gevent |
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 human_size(size): | |
import re | |
def sub(m): | |
return '%s.%s%s' % (m.group(1), m.group(2)[:2], 'BKMGT'[len(m.group(2))/3]) | |
return re.sub(r'^(\d{1,3})((?:\d\d\d){1,4})$', sub, str(size)) |
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
// more django {{{ | |
// see http://www.daveoncode.com/2013/10/17/how-to-make-angularjs-and-django-play-nice-together/ | |
// }}} | |
// more angular {{{ | |
angular.module('main', ['ng']) | |
.config(['$httpProvider', function($httpProvider) { | |
angular.extend($httpProvider.defaults, { | |
withCredentials: true, | |
xsrfHeaderName: 'X-CSRFToken', |
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
--- | |
-- https://svn.nmap.org/nmap/nselib/url.lua | |
-- URI parsing, composition, and relative URL resolution. | |
-- | |
-- A URL is represented as a table with the following entries: | |
-- * <code>scheme</code> | |
-- * <code>fragment</code> | |
-- * <code>query</code> | |
-- * <code>params</code> | |
-- * <code>authority</code> |
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
#!/usr/bin/env perl | |
# head -c123456845 /dev/random | szstat >/dev/null | |
sub ps { | |
my $n=shift @_; | |
my @u=qw"B K M G T P E"; | |
my $i=0; | |
while ($n>=1024 and $i<$#u) { | |
$n /= 1024.0; |
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 mus = require('mustache'); | |
var t = npgettext("abcadfadf a", "%(count)d app", "%(count)d apps", count); | |
function gettext_plural() { | |
return function(text, render) { | |
try { | |
var ctx = JSON.parse(text); | |
var count = parseInt(render(ctx[0]), 10); | |
return render(count > 1 && ctx[2] ? ctx[2] : ctx[1]); |
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
angular.module('MyApp', []) | |
.controller('MyCtrl', ['$scope', '$debounce', function($scope, $debounce) { | |
$scope.val = 0; | |
$scope.inc = function() { | |
$debounce(increase, 300); | |
}; | |
var increase = function() { | |
$scope.val++; | |
} |
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
# 1. for: https://docs.newrelic.com/docs/features/request-queuing-and-tracking-front-end-time | |
# 2. as some guys ask this question for haproxy (seems can not do this): | |
# http://www.faultserver.com/q/answers-how-to-set-the-request-start-time-with-haproxy-447033.html | |
# 3. and, we can not add this header in httpd server, because it's too late.. | |
limit_req_zone $binary_remote_addr zone=one:1m rate=1r/s; | |
server { | |
listen 1025; |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
circle { | |
stroke: #fff; | |
} | |
</style> | |
<body> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>OMG Particles!</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script> | |
<style type="text/css"> | |
body { | |
background: #222; |