Skip to content

Instantly share code, notes, and snippets.

@codeck
codeck / run_xdrgen.sh
Created August 25, 2015 03:15
how to run xdrgen(a ruby-based project)
#apt-get install bundler
git clone https://github.com/stellar/xdrgen.git
bundle install --path vendor/bundle
bundle exec bin/xdrgen
@codeck
codeck / fetch.sh
Last active August 29, 2015 14:22
A simple poll-based REST API data fetcher script
#!/bin/bash
#
# edit fetsh.lst as a TSV file and press 'q' to stop polling
# poll period: 1 second
#
while [ 1 ]
do
read -t 1 -n 1 char
if [[ $char == 'q' ]]
then
@codeck
codeck / mailsrv
Last active February 16, 2023 19:05
poorman's enterprise mail server
(mainly quoted from http://n3mesisfixx.blogspot.com/2013/07/configuring-exim4-to-route-to-many.html)
0. manage domain "enterprisedomain.com" and mx record and PTR/ip reverse name
1. install debian
2. setup exim4 domains
run $dpkg-reconfigure exim4-config'
set "type" as internet
set "mail name" to *somelocalname* eg. debian or change /etc/mailname+/etc/hosts
set "other dest domain"/dc_other_hostnames as "*somelocalname*; enterprisedomain.com;", make sure *somelocalname* in the list.
3. enable virtual alias
@codeck
codeck / randpw.sh
Created March 27, 2015 13:51
random password
openssl rand 256|tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB'|head -c12
@codeck
codeck / strbuild.sh
Last active August 29, 2015 14:05
stellard build script
wget https://download.libsodium.org/libsodium/releases/libsodium-0.6.0.tar.gz
tar zvfx libsodium-0.6.0.tar.gz
cd libsodium-0.6.0/
./configure --prefix=`realpath .`-bin
make && make install
cd ..
#diff --git a/SConstruct b/SConstruct
#index a4dca74..024e5e0 100644
#--- a/SConstruct
@codeck
codeck / java_overgfw.bat
Created July 11, 2014 20:12
a batch to make android sdk manager over gfw
set _JAVA_OPTIONS=-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8181
rem alternatively,
rem set JAVA_TOOL_OPTIONS=-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8181
"SDK Manager"
@codeck
codeck / ledger_head.sh
Created May 2, 2014 02:29
bash command to monitor rippled ledger fetching progresss
#/bin/bash
#
#command to monitor a rippled stared by `./rippled --fg --net` with "full ledger_history" config
#
while [ 1 ];
do ./rippled -q server_info|grep "complete_ledger"|egrep -o '[[:digit:]]*'|head -n1|xargs -I{} ./rippled -q ledger {} |grep close_time_human;
sleep 5;
done
@codeck
codeck / tcpflow.lua
Last active August 29, 2015 14:00
whireshark script to show how sack make throughput jitter
-- run by
-- "C:\Program Files\Wireshark\tshark" -Q -r ftp.pcapng -X lua_script:tcpflow.lua
local server = "1.1.1.1"
local tap = Listener.new("tcp", "ip.addr == "..server)
function gen_acc(seq)
local datas = {}
local sum = 0
local last_sum = 0
def timeit[T](f:()=>T)(count:Int=1) = {
val st = System.nanoTime()
var ti = 0
var accu = collection.mutable.ListBuffer.empty[T]
while (ti < count) {
f() +=: accu
ti=ti+1
}
val ed = System.nanoTime()
println(s"${(ed-st)/1000000} ms")
@codeck
codeck / it.scala
Last active January 2, 2016 13:38 — forked from Centaur/it.scala
val arg1 = Iterator(2, 3, 4, 8, 9, 12, 14, 17)
val arg2 = Iterator(1, 2, 3, 4, 6, 8, 9, 10, 11, 12, 13, 14, 17)
//??(arg1, arg2)=> Iterator((2, 4), (8, 9), (12, 12),(14, 17))
case class CeRange(start:Int, end:Option[Int]) {
def passed(br: Int) = {
end.map(br < _).getOrElse(true)
}
}