Skip to content

Instantly share code, notes, and snippets.

View gokusenz's full-sized avatar
🎯
Focusing

Nattawut Ruangvivattanaroj gokusenz

🎯
Focusing
View GitHub Profile
@gokusenz
gokusenz / post.js
Created June 5, 2020 18:28
puppeteer post
// Used for serializing POST parameters from an object
const querystring = require('querystring');
// ...
const browser = await puppeteer.launch();
const page = await browser.newPage();
let postData = {a: 1, b: 2};
@gokusenz
gokusenz / b.txt
Created March 6, 2020 08:30
Open browser with external browser
?openExternalBrowser=1
@gokusenz
gokusenz / cookies.js
Created March 5, 2020 09:43
How to save cookies and load it in another puppeteer session?
// Save cookies to disk
const fs = require('fs').promises;
// ... puppeteer code
const cookies = await page.cookies();
await fs.writeFile('./cookies.json', JSON.stringify(cookies, null, 2));
@gokusenz
gokusenz / elasp_time.go
Created February 16, 2020 19:28
elapsed time for golang
func main() {
start := time.Now()
r := new(big.Int)
fmt.Println(r.Binomial(1000, 10))
elapsed := time.Since(start)
log.Printf("Binomial took %s", elapsed)
}
@gokusenz
gokusenz / go.mod
Last active February 16, 2020 11:35
Example for go modules with replace
module github.com/gokusenz/go-healthcheck
go 1.12
replace (
github.com/gokusenz/go-healthcheck/cmd => ./cmd
github.com/gokusenz/go-healthcheck/healthcheck => ./healthcheck
)
require (
@gokusenz
gokusenz / i.json
Created February 13, 2020 16:48
iterm :D
{
"Working Directory" : "\/Users\/nruangvivatt",
"Prompt Before Closing 2" : false,
"Selected Text Color" : {
"Green Component" : 0.8579363226890564,
"Red Component" : 0.84028750658035278,
"Blue Component" : 0.89713811874389648
},
"Rows" : 25,
"Ansi 11 Color" : {
@gokusenz
gokusenz / screen.md
Created July 31, 2019 08:22
screen command

Use screen -ls to see how many screen are available.

screen -ls

You want to restore screen 7849.pts-0.mint, then type this command.

screen -r 7849

we are using “Ctrl-A” and “d” to detach the screen.

Second, we can use the exit command to terminating screen.

@gokusenz
gokusenz / rsync.py
Created July 30, 2019 16:26
Rsync example [Python3]
#!/usr/bin/env python
import sys
import os
import re
import subprocess as sub
import requests
def runProcess(exe):
p = sub.Popen(exe, stdout=sub.PIPE, stderr=sub.PIPE)
@gokusenz
gokusenz / emotion.php
Created May 27, 2019 13:14
Line Notify emotion
<?php
$code = '100005';
$bin = hex2bin(str_repeat('0', 8 - strlen($code)) . $code);
$emoticon = mb_convert_encoding($bin, 'UTF-8', 'UTF-32BE');
?>
@gokusenz
gokusenz / gist:993b020ab820d8057265442095a8949c
Created March 4, 2019 00:00
laravel-admin problem with PostgresSQL
# https://github.com/z-song/laravel-admin/pull/219
# https://github.com/z-song/laravel-admin/issues/161
// orderByRaw('"order" = 0,"order"')