Skip to content

Instantly share code, notes, and snippets.

View wenweih's full-sized avatar
🏠
Working from home

huangwenwei.com wenweih

🏠
Working from home
View GitHub Profile
@wenweih
wenweih / block_projector.go
Created March 12, 2021 04:55
Sample for Post
package repository
import (
"context"
"errors"
"fmt"
"time"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/pgjson"
{"version":1,"resource":"file:///Users/wenwei/work/shop/nooks-living/.rubocop.yml","entries":[{"id":"MzjP.yml","timestamp":1730099310285},{"id":"SJSE.yml","timestamp":1730099408032}]}
@wenweih
wenweih / ethereum_top_accounts.py
Last active January 11, 2019 05:58
Query top accounts from Etherscan
#!/usr/bin/env python
import requests
from bs4 import BeautifulSoup
import csv
def dump(soup):
table = soup.find_all("div", class_="table-responsive")
for t in table:
for tr in t.find_all('tr'):
{"sig":"f057d15d95b206ed44d8fad2ba40c1604f9063ef2fca9b46fd8902d9f07bef8980a8ab21526ddb4abe07c54e2a34a8d94d2f6088e8dc4dd459823c85e308eda20","msghash":"4cae631c768edc6be84530466c2b1dbba14e97d08ca30d33a7fd6c0b9fccc916"}
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.16;
contract Token {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
This automatically creates a getter function for the totalSupply.
@wenweih
wenweih / Gemfile
Created December 29, 2016 16:50 — forked from adamrobbie/Gemfile
Rails Endless pagination
gem 'will_paginate'
@wenweih
wenweih / vim_cheatsheet.md
Created November 23, 2016 02:38 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
require 'digest/sha2'
module BitcoinAddress
extend self
N = [0,1,2,3,4,5,6,7,8,nil,nil,nil,nil,nil,nil,nil,9,10,11,12,13,14,15,16,nil,17,18,19,20,21,nil,22,23,24,25,26,27,28,29,30,31,32,nil,nil,nil,nil,nil,nil,33,34,35,36,37,38,39,40,41,42,43,nil,44,45,46,47,48,49,50,51,52,53,54,55,56,57]
def validate? address
g = address.bytes.inject(0){|g,n| g*58+N[n-49]}.to_s(16)
n = g.slice!(0..-9)
(n.length...42).each{n.insert(0,'0')}
caculate = Digest::SHA256.hexdigest(Digest::SHA256.digest(convert(n)))[0,8]
g == caculate ? true : false
@wenweih
wenweih / gist:b124236cb9bc876c67837e703fbc14ac
Created September 18, 2016 16:28 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@wenweih
wenweih / puma.rb.example
Created May 13, 2016 15:14
My puma configuration file
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.