Skip to content

Instantly share code, notes, and snippets.

View knight42's full-sized avatar
❤️
Loving @FogDong

Zack Zeng knight42

❤️
Loving @FogDong
View GitHub Profile
@knight42
knight42 / xls2csv.py
Created March 23, 2017 09:36
Convert xls to csv
#!/usr/bin/python -O
# -*- coding: utf-8 -*-
########################
# Require python-xlrd
########################
from __future__ import print_function, unicode_literals, with_statement, division
import xlrd
import csv
from os import sys
@knight42
knight42 / git-change-author-info.sh
Last active May 31, 2017 14:10
git-change-author-info.sh
#!/bin/sh
# git clone --bare https://github.com/user/repo.git
# cd repo.git
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
@knight42
knight42 / choose.rs
Last active August 23, 2016 07:05
doesn't work :/
use syntax::ast;
use syntax::ptr::P;
use syntax::codemap;
use syntax::parse::token;
use syntax::tokenstream::TokenTree;
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
use syntax::ext::build::AstBuilder;
use syntax_pos::Span;
use rustc_plugin::Registry;
use syntax::util::small_vector::SmallVector;

Keybase proof

I hereby claim:

  • I am knight42 on github.
  • I am knight42 (https://keybase.io/knight42) on keybase.
  • I have a public key ASBcXMtM1C4xjqaqqM-hbhT93xhcebCOv2i-FyjK51VDqAo

To claim this, I am signing this object:

@knight42
knight42 / naive-request.js
Last active December 8, 2016 08:37
naive promisified request
#!/usr/bin/node
"use strict";
const net = require('net');
const url = require('url');
const qs = require('querystring');
function request(opts) {
if(! /^https?:\/\//.test(opts.url)) opts.url = `http://${opts.url}`;
@knight42
knight42 / npm_registry.conf
Created March 5, 2016 01:26
npm registry caching proxy using nginx
proxy_cache_path /mnt/array1/nginx/cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g;
proxy_temp_path /mnt/array1/nginx/temp;
keepalive_timeout 2;
tcp_nodelay on;
sendfile on;
limit_conn_zone $binary_remote_addr zone=addr:20m;
limit_req_zone $binary_remote_addr zone=req_per_ip:20m rate=80r/s;
limit_req zone=req_per_ip burst=100;
#!/usr/bin/python3 -O
# -*- coding: utf-8 -*-
import hashlib
import binascii
from passlib.utils import des
def GenerateNTResponse(AuthChal, PeerChal, UserName, Password):
'''
IN 16-octet AuthenticatorChallenge,