Skip to content

Instantly share code, notes, and snippets.

View zhehaowang's full-sized avatar
🤔
🤦‍♀️ 🤦‍♂️ 🤦‍♀️ 🤦‍♂️ 🤦‍♀️ 🤦‍♂️ 🤦‍♀️ 🤦‍♂️ 😂

Zhehao Wang zhehaowang

🤔
🤦‍♀️ 🤦‍♂️ 🤦‍♀️ 🤦‍♂️ 🤦‍♀️ 🤦‍♂️ 🤦‍♀️ 🤦‍♂️ 😂
View GitHub Profile
@zhehaowang
zhehaowang / poi.py
Created December 26, 2020 15:25
annotate communes with poi
#!/usr/bin/env python3
import argparse
import glob
import json
import requests
import os
from json.decoder import JSONDecodeError
# import hack
@zhehaowang
zhehaowang / csv2xlsx.py
Created May 22, 2020 19:26
utf-8 recovery hack
import os
import glob
import csv
from xlsxwriter.workbook import Workbook
for csvfile in ["out.csv"]:
workbook = Workbook(csvfile[:-4] + '.xlsx')
worksheet = workbook.add_worksheet()
with open(csvfile, 'r', newline='', encoding='utf-8') as f:
reader = csv.reader(f)
@zhehaowang
zhehaowang / move_and_perfect_forwarding.cpp
Created June 21, 2019 02:45
To demonstrate how rvalue references can be useful: in implementing moves and perfect forwarding.
#include <iostream>
#include <string>
#include <vector>
struct MyObject {
MyObject(const char * c) : content(c) {
std::cout << "default ctor\n";
}
MyObject(const MyObject& rhs) : content(rhs.content) {
@zhehaowang
zhehaowang / quotes.log
Created August 22, 2018 19:20
quotes
"Advocate for yourself. Honestly that's the key to everything here. If you don't, people are going to make assumptions, and such assumptions are usually wrong."
-- Adam
"Regarding career: First, deepen your technical skills, especially transition from a good programmer (which you probably were already in college) to a good engineer (who understands software and systems as a whole, including scalability, maintainability, flexibility, lifecycle, dependencies, risks, ...)
Then, start building out soft skills. These might have the biggest impact on your career in the long run. Like presenting your work, influencing others, mentor people, creativity and innovation ..."
-- Jochen
"I have two kinds of problems, the urgent and the important. The urgent are not important, and the important are never urgent." -- Eisenhower
"No idea is really bad, unless we are uncritical. What is really bad is to have no idea at all."
@zhehaowang
zhehaowang / when_genius_failed.md
Last active August 15, 2018 14:30
When Genius Failed

When Genius Failed

What is Long Term Capital Management (LTCM)

LTCM is a hedge fund founded by the bond arbitrage group from Salomon, plus Nobel laureate economists (Merton and Scholes) from Harvard.

They operated from 1994 to 1998, culminating in $1 turning into over $4 for each dollar invested in 1993 (and a $4.5 billion total capital), and losing it all (each $1 worth 33 cents) in 5 weeks in 1998. The Fed organized a bailout operation to ingest capital to LTCM from major Wall Street banks, out of fear of LTCM collapsing triggering a series of crises.

What does LTCM trade; How do they make money

@zhehaowang
zhehaowang / ip_prefix_within_range.py
Created May 12, 2018 00:54
IP prefix within range
#!/usr/local/bin/python3
def ipPrefixRange(addr, start, end):
"""
@param addr valid String of ip address e.g. 192.168.0.0/16
@param start int range to start iteration from
@param end int range to end the iteration with
@return [String] list of string of possible prefixes between start and end
"""
assert start <= end
@zhehaowang
zhehaowang / clean-architecture.md
Last active February 25, 2022 22:48
Clean Architecture: book notes

Clean architecture

Part 1

Goal

Goal of architecture: to minimize human resources required to build and maintain the required system

A good indication of a badly designed system: look at the cost of each line of code, and the productivity of each engineer over time

@zhehaowang
zhehaowang / historical_data.js
Last active December 30, 2017 21:11
Example websocket reader for gdax api
const Gdax = require('gdax');
let fs = require('fs');
const publicClient = new Gdax.PublicClient();
// currency pairs we are interested in
const currencyPairs = ['BTC-USD', 'ETH-BTC', 'ETH-USD', 'LTC-BTC', 'LTC-USD', 'BCH-USD'];
// time range we are interested in
const startDate = "2015-01-01T00:00:00.000Z";
@zhehaowang
zhehaowang / test_return_object.cpp
Last active October 26, 2017 03:04
Gist for testing returning an object (RVO).
// Apple LLVM version 8.0.0 (clang-800.0.42.1)
// g++ -o test test_return_object.cpp
// ./test
#include <iostream>
int g_int = 0;
class Test {
public:
@zhehaowang
zhehaowang / TestRegister.cs
Created December 19, 2016 23:48
Unity test for sha256oid
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
public class TestRegister : MonoBehaviour {
public string test() {
CspParameters cspParams = new CspParameters();