Skip to content

Instantly share code, notes, and snippets.

View hellwolf's full-sized avatar

Miao ZhiCheng hellwolf

View GitHub Profile
@hellwolf
hellwolf / defineReplace(map).pri
Created December 24, 2010 18:49
qmake map function
defineReplace(map) {
vname = $$1
fs = $$2
eval(v = \$\$$$vname)
for(f, fs) {
eval(v = \$\$$${f}(v))
}
return ($$v)
@hellwolf
hellwolf / bash getopts
Created January 5, 2011 14:39
bash getopts
while getopts "u:r:" opt;
do
case "$opt" in
"u")
SVN_URL=$OPTARG
;;
"r")
REVISION=$OPTARG
;;
*)
@hellwolf
hellwolf / gist:8584479
Created January 23, 2014 18:50
iptables nat redirect
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat --flush
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8000
iptables -t nat -A POSTROUTING -j MASQUERADE
@hellwolf
hellwolf / gist:8584504
Created January 23, 2014 18:51
Apache VirtualHosts and ProxyPass
NameVirtualHost *
# default vhost
<VirtualHost *>
DocumentRoot /
</VirtualHost>
# www.snailattach.com
<VirtualHost *>
ServerName www.example.com
@hellwolf
hellwolf / gist:45a468509dc6b4b01874
Created January 2, 2015 18:23
getParameterByName
function getParameterByName(name) {
'use strict';
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=?([^&#]*)"),
results = regex.exec(location.search);
return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@hellwolf
hellwolf / gist:21f52fa7af3e5ab00ab8
Created September 30, 2015 21:16
configure PyDev unittest file pattern
Run configuration ->
Python unittest ->
(one of the configuration) ->
Arguments ->
PyUnit: Override PyUnit preferences for this launch?
--include_files 'integration_*.py'
@hellwolf
hellwolf / test-extended-key.js
Created December 8, 2015 15:35
using bitcoinjs-lib and test hardended/non-hardened extended keys concepts
var bitcoin = require('bitcoinjs-lib');
var network = bitcoin.networks.bitcoin;
var privateSeed = 'f9b64acde29b65ea8909f33380a7e87dc5f07b9437891cb8a0ef0e6fedc775e7fab0c846d45afb226c08d373f55a21c025410ee5a168a57000a8db9e8e3a29cb';
console.log("privateSeed", privateSeed);
var master = bitcoin.HDNode.fromSeedHex(privateSeed, network);
// derive hardened node and its neutered version
var hardenedNode = deriveAccount(master, 0);
var hardenedNeutered = hardenedNode.neutered();
var hardenedBase58 = hardenedNeutered.toBase58();
@hellwolf
hellwolf / spawn.js
Last active December 29, 2015 19:27
[NodeJS] Spawn a child process and write a pid file
!/usr/bin/env node
var spawn = require('child_process').spawn;
var fs = require('fs');
var c = spawn(process.argv[3], process.argv.slice(4), { stdio: 'inherit' });
if (c.pid) {
pidFile = fs.createWriteStream(process.argv[2]);
pidFile.write(c.pid.toString());
===== geth-dev
#!/bin/bash
exec geth \
--datadir "C:\Users\zhimiao\AppData\Roaming\Ethereum.dev" \
--password "C:\Users\zhimiao\AppData\Roaming\Ethereum.dev\dev.passwordfile" \
--dev \
"$@"
@hellwolf
hellwolf / ImportJSON.gs
Created November 10, 2016 08:32
ImportJSON.gs with username/password support
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();