Skip to content

Instantly share code, notes, and snippets.

View earthchie's full-sized avatar

Thanarat Kuawattanaphan earthchie

View GitHub Profile
var ajax = {
x: [],
abortAll: function() {
var i;
for (i in ajax.x) {
if (Object.prototype.hasOwnProperty.call(ajax.x, i)) {
ajax.x[i].abort();
}
}
@earthchie
earthchie / saveExcel.js
Created October 31, 2017 07:19
saveExcel function
function saveExcel(data, filename){
var datenum = function (v, date1904) {
if(date1904) v+=1462;
var epoch = Date.parse(v);
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
},
sheet_from_array_of_arrays = function (data, opts) {
var ws = {};
var range = {s: {c:10000000, r:10000000}, e: {c:0, r:0 }};
@earthchie
earthchie / Satang_Pro_API.md
Created September 4, 2019 12:31
Satang.Pro API

API

PromptPay Deposit QR code

Request

POST https://api.tdax.com/api/qr-deposits/
Authorization:  TDAX-API <Api-Key>
Signature: <Your-Signed-Request-Signature>
/**
* @file agm_voting.sol
* @author DomeCloud co., ltd.
*/
pragma solidity ^0.5.0;
contract Ballot {
struct vote{
@earthchie
earthchie / ExchangeRate.js
Created March 9, 2021 10:58
get Satang and Bitkub Exchange rate
async function getExchangeRate(pair, start, end) {
return {
Satang: await getSatangExchangeRate(pair, start, end),
Bitkub: await getBitkubExchangeRate(pair, start, end)
}
}
async function getSatangExchangeRate(pair, start, end) {
start = start.getTime() - 86399999;
end = end.getTime() + 86400000;
/******************************\
!!! คำเตือน โปรดระวัง !!!
การใช้บอท มีความเสี่ยงที่จะถูกแบนได้
แนะนำให้สร้างบัญชีใหม่มาบอทโดยเฉพาะ
\******************************/
class TLMBot {
constructor(minWaitTime = 5000, maxWaitTime = 15000) {
this.minWaitTime = minWaitTime;
this.maxWaitTime = maxWaitTime;
@earthchie
earthchie / getPrice.js
Created May 13, 2021 15:12
Simple API to get a exchange rate from PancakeSwap V2 Router
const express = require('express');
const { ethers } = require('ethers');
const app = express();
const port = 3000;
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/');
const contract = {
factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73', // PancakeSwap V2 factory
router: '0x10ED43C718714eb63d5aA57B78B54704E256024E', // PancakeSwap V2 router
const { ethers } = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/');
const BEP20 = {
BUSD: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
DOP: '0x844fa82f1e54824655470970f7004dd90546bb28',
};
const Contract = {
router: new ethers.Contract(
@earthchie
earthchie / searchForWalletFromMnemonic.js
Last active May 23, 2021 05:03
ตามหา private key และ path ของกระเป๋าที่สูญหาย จาก mnemonic keys
const ethers = require('ethers');
const mnemonic = `critic seek crop move student season draw fiscal put prevent message cereal`
const target = `0xB1aB1cdC94e4edC8a7cc3187D5CCE0169de7505c`;
let i = -1;
let wallet;
console.log('searching...')
do {
const ethers = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/');
// you can find pair address from Factory Contract, method getPair(token1Addr, token2Addr).
let Contract = {
PancakePair: new ethers.Contract('0xb694ec7C2a7C433E69200b1dA3EBc86907B4578B',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider),
TwindexPair: new ethers.Contract('0xC789F6C658809eED4d1769a46fc7BCe5dbB8316E',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider)
}