Skip to content

Instantly share code, notes, and snippets.

@dseg
dseg / jst.sh
Created March 30, 2017 10:26
Output now in BusyBox (for example, Alpine Linux) as Japan Standard Time
TZ=JST-9 date -Iseconds|tr T ' '|tr - /|head -c 19
@dseg
dseg / Satoshi to BTC
Created June 1, 2017 15:19
satoshi2btc.sh
# Usage: btc bitcoin_amount_in_satoshi
# $ btc 1550000000
# 15.50000 BTC
#
function btc {
if [[ -n $1 ]]; then
btc=$(bc -l <<< "$1 / 100000000.0")
printf '%.5f BTC\n' $btc
fi
}
use std::io::Write;
use std::net::{TcpListener, TcpStream};
use std::thread;
fn handle_client(mut stream: TcpStream) {
thread::spawn(move || {
stream.write(b"Hello World\r\n").unwrap();
});
}
@dseg
dseg / estimategas.sh
Created March 28, 2018 07:48
Estimate Gas (of Ethereum)
#!/bin/sh
# Requirements: geth
fee=$(geth attach ipc:/home/ubuntu/main_net/geth.ipc --exec 'web3.fromWei(web3.eth.gasPrice*web3.eth.estimateGas({from:"0xc1912fee45d61c87cc5ea59dae31190fffff232d"}))')
date
echo -n $fee | tr -d \"
echo \ ETH.