Skip to content

Instantly share code, notes, and snippets.

View sofianhw's full-sized avatar
💭
I may be slow to respond.

Sofian Hadiwijaya sofianhw

💭
I may be slow to respond.
View GitHub Profile
@sofianhw
sofianhw / hdwallet.go
Created October 18, 2022 08:06 — forked from miguelmota/hdwallet.go
Golang Ethereum HD Wallet implementation
package hdwallet
import (
"crypto/ecdsa"
"errors"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/ethereum/go-ethereum/accounts"
/**
*Submitted for verification at Etherscan.io on 2021-10-31
*/
// File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
// OpenZeppelin Contracts v4.3.2 (utils/Strings.sol)
pragma solidity ^0.8.0;
@sofianhw
sofianhw / example_etl.py
Created July 30, 2017 11:01 — forked from dlstadther/example_etl.py
Example ETL Using Luigi
# import python core modules
import os
import shutil
import datetime
# import external modules
import pandas as pd
import requests
# import luigi modules
__d("Chromedome", ["fbt"], function(a, b, c, d, e, f, g) {
f.start = function(h) {
if (h.off || top !== window ||!/(^|\.)facebook\.com$/.test(document.domain))
return;
var i = h.stop || "Stop!", j = h.text || "This is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Facebook feature or \"hack\" someone's account, it is a scam and will give them access to your Facebook account.", k = h.more || g._("For more information, see {url}.", [g.param("url", 'https://www.facebook.com/selfxss')]);
if ((window.chrome || window.safari)&&!h.textonly) {
var l = 'font-family:helvetica; font-size:20px; ';
[[i, h.c1 || l + 'font-size:50px; font-weight:bold; ' + 'color:red; -webkit-text-stroke:1px black;'], [j, h.c2 || l], [k, h.c3 || l], ['', '']].map(function(r) {
setTimeout(console.log.bind(console, '\n%c' + r[0], r[1]));
});
@sofianhw
sofianhw / main.go
Created October 27, 2016 05:39 — forked from tonyhb/main.go
Golang: Converting a struct to a map (to a url.Values string map)
package main
import (
"fmt"
"net/url"
"reflect"
"strconv"
)
type Person struct {
@sofianhw
sofianhw / local-dnsserver.md
Created June 23, 2016 18:10 — forked from nsbingham/local-dnsserver.md
Testing a CNAME

Setting up a local DNS server with bind on OSX Mavericks

This is really just an approach for locally testing DNS changes, which can easily be done with a HOSTS file if the change involves an IP address, but gets a bit trickier when things like CNAMEs are involved. This is only meant to test locally off a single machine.

  1. Install bind using homebrew

    brew install bind

  2. Follow the installation steps to start up bind

@sofianhw
sofianhw / beautiful_idiomatic_python.md
Created April 28, 2016 17:29 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@sofianhw
sofianhw / install_opencv2.4.9.sh
Last active March 17, 2016 09:46 — forked from mitmul/install_opencv2.4.8.sh
install OpenCV 2.4.9 for CentOS 6.3
#! /bin/bash
sudo yum install -y gcc g++ gtk+-devel libjpeg-devel libtiff-devel jasper-devel libpng-devel zlib-devel cmake unzip
sudo yum install -y yum-priorities
wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -ivh epel-release-6-8.noarch.rpm
sudo yum install -y eigen3-devel —enablerepo=epel
pip install numpy
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9
@sofianhw
sofianhw / gist:5f1e1d098dff923531e0
Created March 7, 2016 17:55 — forked from tnolet/gist:7361441
Install collectd 5.4 on Centos 6.x and make it spit out cool metrics. Copied from http://linuxdrops.com/install-collectd-statistics-collecter-on-centos-rhel-ubuntu-debian/ and tweaked for your and my pleasure. For all other cool options, check the provided link.
#!/bin/bash
# Perform installation as root
# Install prereqs
yum -y install libcurl libcurl-devel rrdtool rrdtool-devel rrdtool-prel libgcrypt-devel gcc make gcc-c++
# Get Collectd, untar it, make it and install
wget http://collectd.org/files/collectd-5.4.0.tar.gz
tar zxvf collectd-5.4.0.tar.gz
@sofianhw
sofianhw / remotemd5.py
Created February 10, 2016 13:07 — forked from brianewing/remotemd5.py
Python MD5 of remote file (URL)
import os, hashlib, urllib2, optparse
def get_remote_md5_sum(url, max_file_size=100*1024*1024):
remote = urllib2.urlopen(url)
hash = hashlib.md5()
total_read = 0
while True:
data = remote.read(4096)
total_read += 4096