Skip to content

Instantly share code, notes, and snippets.

View mynameiskreang's full-sized avatar

Kreangkrai Supchid mynameiskreang

View GitHub Profile
type Input struct {
SenderName string `json:"sender_name"`
Content string `json:"content"`
Type string `json:"type"`
}
func main() {
//bs, _ := ioutil.ReadFile("./input.json")
bs := `{
"sender_name": "Kreang \u00e0\u00b9\u0080\u00e0\u00b8\u0081\u00e0\u00b8\u00b5\u00e0\u00b8\u00a2\u00e0\u00b8\u0087",
@mynameiskreang
mynameiskreang / Decode Chat Facebook
Created February 20, 2022 17:14
Decode Chat Facebook
function decodeChatFacebook(input) {
let d = new TextDecoder;
let uint8 = input.split('').map(m => m.charCodeAt());
return d.decode(new Uint8Array(uint8));
}
let sample = "Kreang \u00e0\u00b9\u0080\u00e0\u00b8\u0081\u00e0\u00b8\u00b5\u00e0\u00b8\u00a2\u00e0\u00b8\u0087";
console.log(decodeChatFacebook(sample));
#! /usr/bin/env bash
## kill process by port
kill -9 $(lsof -t -i:{port})
@mynameiskreang
mynameiskreang / main.js
Created November 12, 2019 03:36
loop async/await
async function f() {
let sumPass = 0;
for (let i = 0; i < 100; i++) {
const isPass = await f1(i);
if (isPass) {
sumPass++;
// await makeAsyncRequest(i);
const ps = new Promise((resolve, reject) => {
setTimeout(() => {resolve(i);}, 100);
});
@mynameiskreang
mynameiskreang / Working with non-default SSH key pair paths
Last active October 21, 2019 04:40
Working with non-default SSH key pair paths
If you used a non-default file path for your GitLab SSH key pair,
you must configure your SSH client to find your GitLab private SSH key
for connections to GitLab.
Open a terminal and use the following commands
(replacing other_id_rsa with your private SSH key):
eval $(ssh-agent -s)
ssh-add ~/.ssh/other_id_rsa
@mynameiskreang
mynameiskreang / Git Command line instructions.md
Last active September 5, 2019 08:12
Git Command line instructions

Command line instructions

You can also upload existing files from your computer using the instructions below.


Git global setup

git config --global user.name "kreangkrai supchid"
git config --global user.email "kreang@kreangkrai.com"

Create a new repository

git clone git@github.com:mynameiskreang/repo.git

#!/bin/bash
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
sudo tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2
sudo mv phantomjs-2.1.1-linux-x86_64 /usr/local/share
sudo ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin