Skip to content

Instantly share code, notes, and snippets.

// 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',
---
-- 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>
@kindy
kindy / szstat
Created January 17, 2014 16:40
used to count stream size. like tee, but not save stream to file.
#!/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;
@kindy
kindy / a.js
Created December 4, 2013 11:46
mustache i18n support in django
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]);
@kindy
kindy / app.js
Created November 26, 2013 06:17
angular.module('MyApp', [])
.controller('MyCtrl', ['$scope', '$debounce', function($scope, $debounce) {
$scope.val = 0;
$scope.inc = function() {
$debounce(increase, 300);
};
var increase = function() {
$scope.val++;
}
@kindy
kindy / srv.conf
Last active April 26, 2018 18:14
add X-Request-Start for New Relic
# 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;
@kindy
kindy / index.html
Created September 24, 2013 13:14 — forked from mbostock/.block
<!DOCTYPE html>
<meta charset="utf-8">
<style>
circle {
stroke: #fff;
}
</style>
<body>
@kindy
kindy / index.html
Created September 17, 2013 02:28 — forked from mbostock/.block
<!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;
@kindy
kindy / vimrc
Last active December 22, 2015 06:39
" <buffer-number> <file-name> <modify> <file-type> <encoding> <line><col> <byte-of-file> <char-under-cursor> <pos-of-file>
" #17 ~/.vimrc [+][vim] [utf-8] 2336,1 @59791 0x6E Bot
set statusline=%<#%n\ %f\ %h%m%r%y%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ %-16.(%l,%c%V%)\ @%o\ 0x%B\ %P
" use :grep to search
set grepprg=ack\ --nocolor\ --nogroup
set grepformat=%f:%l:%m
" use <C-j> and <C-k> to navigate in search result
nm <c-j> :cn<CR>
nm <c-k> :cp<CR>
/* lisp.c: high-speed LISP interpreter */
/* src: http://www.cs.auckland.ac.nz/~chaitin/lisp.c */
/*
The storage required by this interpreter is 8 * 4 = 32 bytes times
the symbolic constant SIZE, which is 32 * 1,000,000 =
32 megabytes. To run this interpreter in small machines,
reduce the #define SIZE 1000000 below.
To compile, type
cc -O -olisp lisp.c