Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
Really makes me think

Andida Syahendar JesusIslam

🤔
Really makes me think
  • Indonesia
View GitHub Profile
@JesusIslam
JesusIslam / tokenPriceApi.js
Created Nov 2, 2021 — forked from Linch1/tokenPriceApi.js
Retrive the price of any bsc token from it's address without using external service like poocoin/dextools
View tokenPriceApi.js
let pancakeSwapAbi = [{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountADesired","type":"uint256"},{"internalType":"uint256","name":"amountBDesired","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"},{"interna
@JesusIslam
JesusIslam / remap.go
Last active Dec 2, 2020
Remap Range to Another Range
View remap.go
package main
import (
"fmt"
)
func main() {
unmappedValue := 512
minInput := 0
maxInput := 1023
@JesusIslam
JesusIslam / concurrent.go
Last active Nov 14, 2019
Example of Concurrent Processing With Channels
View concurrent.go
package main
import (
"context"
"flag"
"fmt"
"runtime"
ipgen "github.com/wahyuhadi/go-ipgen"
)
@JesusIslam
JesusIslam / app.js
Created Mar 29, 2019
Get Approximate LoC
View app.js
let headers = new Headers();
//headers.append('Content-Type', 'text/json');
headers.append('Authorization', 'Basic ' + btoa('username' + ":" + 'token'))
fetch('https://api.github.com/repos/username/reponame/stats/contributors', { method:'GET', headers: headers })
.then(response => response.json())
.then(contributors => contributors
.map(contributor => contributor.weeks
.reduce((lineCount, week) => lineCount + week.a - week.d, 0)))
@JesusIslam
JesusIslam / tls-client.go
Created Jan 2, 2019 — forked from michaljemala/tls-client.go
SSL Client Authentication Golang sample
View tls-client.go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
@JesusIslam
JesusIslam / .git-commit-template.txt
Created Jun 28, 2018 — forked from adeekshith/.git-commit-template.txt
This commit message template helps you write great commit messages and enforce it across teams.
View .git-commit-template.txt
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
@JesusIslam
JesusIslam / read_line.go
Created Dec 23, 2017
Read Line Helper Function for go-serial
View read_line.go
func readByLine(port io.ReadWriteCloser) {
scanner := bufio.NewScanner(port)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
// Will return string
fmt.Println(scanner.Text())
}
}
@JesusIslam
JesusIslam / radixsort.go
Created Dec 4, 2017
Radix Sort Example for Go, taken from github.com/dgryski/go-radixsort
View radixsort.go
func Ints(E []int) {
// Algorithm from CLRS, chapter 8
const m = 256
n := len(E)
counts := make([]int, m)
src := E
@JesusIslam
JesusIslam / log.go
Created Oct 29, 2017 — forked from cespare/log.go
Golang apache logging
View log.go
type ApacheLogRecord struct {
http.ResponseWriter
ip string
time time.Time
method, uri, protocol string
status int
responseBytes int64
elapsedTime time.Duration
}
@JesusIslam
JesusIslam / mhz19.ino
Last active Jan 22, 2019
Read MH-Z19 CO2 Sensor Data
View mhz19.ino
// Make sure to wait the sensor to heat up first before attempting to get CO2 concentration data for the first time (approx 3 minutes preheat time).
int readCO2()
{
byte cmd[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
// command to ask for data
byte response[9]; // for answer
// co2Serial is a software serial instance
co2Serial.write(cmd, 9); //request PPM CO2