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
@wmh
wmh / dabblet.css
Created April 16, 2014 02:16 — forked from anonymous/dabblet.css
Untitled
.scroll-text {
border: 1px solid red;
width: 400px;
height: 4.5em;
overflow: hidden;
}
.scroll-text ul {
width: 800px;
height: 100px;
overflow: hidden;
@wmh
wmh / uploadfile-partial.js
Created January 28, 2015 05:17
jquery validation & uploadfile plugin conflict
var fileInputStr = "<input type='file' class='ignore' id='" + fileUploadId + "' name='" + s.fileName + "' accept='" + s.acceptFiles + "'/>";
if(s.multiple) {
if(s.fileName.indexOf("[]") != s.fileName.length - 2) // if it does not endwith
{
s.fileName += "[]";
}
fileInputStr = "<input type='file' class='ignore' id='" + fileUploadId + "' name='" + s.fileName + "' accept='" + s.acceptFiles + "' multiple/>";
}
@wmh
wmh / 2.js
Last active September 11, 2017 03:19
Select My Country
// https://kktix.com/users/edit
$('#user_place_id').val($('#user_place_id option:contains(臺灣)').attr('value'));
@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;
}
@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(',');
// 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 / 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());
}
});
@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 / 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 / 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);