Skip to content

Instantly share code, notes, and snippets.

View wmh's full-sized avatar
🎯
Focusing

Hunter Wu wmh

🎯
Focusing
  • Not available for hire.
  • Taipei 104
View GitHub Profile
aws polly synthesize-speech \
--output-format mp3 \
--voice-id Zhiyu \
--language-code cmn-CN \
--text file://p50.txt \
p50.mp3
@wmh
wmh / cnt.sql
Created June 25, 2019 15:11
解 leetcode db 問題需要用到的一招
SELECT id,
@dep := dep dep,
@cnt := IF(@dep = dep, @cnt + 1, 1) cnt
FROM `emp`,
(SELECT @cnt := 0, @dep := 0) init
@wmh
wmh / cobinhood-list-assets.js
Created July 31, 2018 09:28
Convert cobinhood assets to SQL
// https://cobinhood.com/funds
var sql = 'INSERT INTO token_mappings (src, name, coin_name, image_url) VALUES \n';
document.querySelectorAll('div.sc-AUpyg > div.sc-cSYcjD').forEach((row) => {
const name = row.querySelector('span.sc-gjAXCV').textContent.trim();
const svg = window.btoa(new XMLSerializer().serializeToString(row.getElementsByTagName('svg')[0]));
const fullname = row.querySelector('span.sc-iybRtq').textContent.trim();
sql += `('cobinhood', '${name}', '${fullname}', '${svg}'),\n`;
});
console.log(sql);
@wmh
wmh / binance-asset-list.js
Last active July 31, 2018 08:24
Convert Binance assets to SQL statment
// https://www.binance.com/userCenter/balances.html
var sql = 'INSERT INTO token_mappings (src, name, coin_name, image_url) VALUES \n';
document.querySelectorAll('ul.accountInfo-lists > li.td > div').forEach((row) => {
const imgURL = row.querySelector('div.coin > img').getAttribute('src');
const coin = row.querySelector('div.coin').textContent.trim();
const fullname = row.querySelector('div.fullName').textContent.trim();
sql += `('binance', '${coin}', '${fullname}', '${imgURL}'),\n`;
});
console.log(sql);
@wmh
wmh / VerifySign.sol
Created March 14, 2018 02:48
Solidity Verify Signature
pragma solidity ^0.4.21;
contract VerifySign {
function verify(bytes _msgHex, uint8 _v, bytes32 _r, bytes32 _s) public pure returns (address) {
bytes32 prefixedHash = keccak256("\x19Ethereum Signed Message:\n", uint2str(_msgHex.length), _msgHex);
address signer = ecrecover(prefixedHash, _v, _r, _s);
return signer;
}
@wmh
wmh / short.js
Created February 7, 2018 14:54
只留放空
$('#fem03001\\:prodName option').each(function (idx, ele) { if (ele.innerText.indexOf('空')==-1) {$(ele).remove()} })
@wmh
wmh / fix.js
Created January 26, 2018 03:30
Fix go-ethereum wiki anchors
# https://github.com/ethereum/go-ethereum/wiki/Management-APIs
document.querySelectorAll('a').forEach(function (a) {
var href = a.getAttribute('href');
if (href.indexOf('#') === 0 && href !== href.toLowerCase()) {
a.setAttribute('href', href.toLowerCase());
}
});
// https://www.esunbank.com.tw/bank/Layouts/esunbank/Accessibility/rate_exchange.aspx
var trs = document.querySelectorAll('table.inteTable tr')
for (var i = 0; i < trs.length; ++i) {
var buyPrice = trs[i].querySelector('td:nth-child(2)'),
selPrice = trs[i].querySelector('td:nth-child(3)');
if (buyPrice == null || isNaN(buyPrice.innerText) || selPrice == null || isNaN(selPrice.innerText)) {
continue;
}
console.log(1);
var buyPriceFloat = parseFloat(buyPrice.innerText),
@wmh
wmh / get-mcc-2.js
Last active September 11, 2017 02:04
Get MCC List by jQuery
// https://github.com/musalbas/mcc-mnc-table/blob/master/mcc-mnc-table.csv
var mccs={};
document.querySelectorAll('table.js-csv-data > tbody > tr > td:nth-child(2)').forEach(function (ele) {
mccs[ele.innerText] = 1;
});
Object.keys(mccs).join(',');
@wmh
wmh / cal.js
Created April 10, 2016 11:56
Calculate time from central airport to nagoya
// http://www.meitetsu.co.jp/cht/timetable/centrair/timetable/access_e05_02.html
$('table[bordercolor=lightgrey] tr').each(function () {
var $this = $(this),
$departCell = $this.find('td:nth-child(2)'),
$arriveCell = $this.find('td:nth-child(5)'),
departTime = $departCell.text(),
arriveTime = $arriveCell.text();
if (departTime.indexOf(':') == -1 || arriveTime.indexOf(':') == -1) {
return;
}