Skip to content

Instantly share code, notes, and snippets.

View lotusirous's full-sized avatar
💭
for { Learn() }

Kha Nguyen lotusirous

💭
for { Learn() }
View GitHub Profile
package main
import (
"log"
"net/http"
"sync/atomic"
"time"
)
var isBusy int32
@lotusirous
lotusirous / c_version.c
Created November 20, 2021 08:26
The version of c you are using
#include <stdio.h>
#define version __STDC_VERSION__
int
main (int argc, char *argv[])
{
printf ("Your c version is: %ld\n", version);
return 0;
}
@lotusirous
lotusirous / byteArray_to_hex.js
Created September 1, 2021 06:44
A helper function to convert a byte array to hex (source: https://mkyong.com/java/java-how-to-convert-bytes-to-hex/)
function toHex(bArr) {
var result = "";
for (var i = 0; i < bArr.length; i++) {
let dec = bArr[i] & 0xff;
var hex = Java.use("java.lang.Integer").toHexString(dec);
if (hex.length % 2 == 1) {
hex = "0" + hex;
}
result += hex;
}
@lotusirous
lotusirous / XOR_2_images.py
Created July 31, 2021 10:08
Xor 2 images with python
from cv2 import cv2
foo = cv2.imread("./foo.png")
bar = cv2.imread("./bar.png")
key = cv2.bitwise_xor(foo, bar)
cv2.imshow("xored data", key)
@lotusirous
lotusirous / init.vim
Created June 14, 2021 05:26
Simple vim configuration for development
set wildignore+=*.pyc
set guicursor=
set relativenumber
set nohlsearch
set hidden
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
const array1 = ["A", "B", "C"];
const array2 = ["1", "2", "3"];
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
// acc is the Accumulator for our result, it starts with []
// for each element in array 1, we will use the add operator when `map` with each element in array 2.
const result = array1.reduce(
(acc, v) => [...acc, ...array2.map((x) => v + x)],
@lotusirous
lotusirous / goembed.go
Created May 17, 2021 07:06
Go embed read each file in a folder
package main
import (
"embed"
"fmt"
"log"
)
//go:embed ddl/*
var files embed.FS
package main
import (
"bufio"
"fmt"
"io"
"log"
"os/exec"
"strings"
)
@lotusirous
lotusirous / find_file_by_hash.go
Last active September 17, 2020 00:18
An example of finding apk file by its hash
package main
import (
"crypto/md5"
"flag"
"fmt"
"io"
"log"
"os"
"path/filepath"

VNC server on XFCE4

Create .vnc/xstartup

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4