Skip to content

Instantly share code, notes, and snippets.

View hellwolf's full-sized avatar

Miao ZhiCheng hellwolf

View GitHub Profile
@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 / 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: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());
@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
===== 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 / add-watermark.sh
Created December 3, 2016 15:46
ImageMagick command: add water mark to picture
composite -dissolve 30% -gravity southwest ../utilities/roth_emblem_105_bordered.png fed-assets-2003-2016.png fed-assets-2003-2016-marked.png