Skip to content

Instantly share code, notes, and snippets.

View chunrapeepat's full-sized avatar
🏠
Working from home

Chun Rapeepat chunrapeepat

🏠
Working from home
View GitHub Profile
@chunrapeepat
chunrapeepat / twitter.js
Created April 5, 2023 08:19
Make Twitter suck less
// ==UserScript==
// @name Hide Twitter Replies (Home)
// @version 1
// @description Hide all reply elements in a Twitter home page.
// @author Chun Rapeepat
// @match https://twitter.com/home
// @grant none
// ==/UserScript==
(function() {
@chunrapeepat
chunrapeepat / designMode.js
Last active October 14, 2022 15:37
Chrome designMode bookmarklet
javascript:(
function () {
if (document.designMode === "off") {
document.designMode = 'on';
document.body.innerHTML += `<div id="dmbml" style="position:fixed;z-index:99999;background:white;color:black;top:-1px;left:-1px;border: 1px solid #ccc;font-family:sans-serif;">🎨 Design Mode = On<div>`;
void 0;
} else if (document.designMode === "on") {
document.designMode = 'off';
document.getElementById('dmbml').remove();
void 0;
@chunrapeepat
chunrapeepat / seed-phase-secret.js
Created August 7, 2021 12:38
Seed phrase + secret for preventing hack, PoC
const phrase = "A B C D E F G H I J K L"
const secret = "helloworld123"
console.log(`Phase = ${phrase}`)
console.log(`Secret = ${secret}`)
console.log(`Phase + Secret = ${encode(phrase, secret)} (<-- note this on paper)`)
if (phrase !== decode(encode(phrase, secret), secret)) {
console.log("ERROR")
}
@chunrapeepat
chunrapeepat / uptime-chart.js
Last active March 9, 2023 03:37
Uptime Chart -> Chronological timeline format (ECharts)
var data = [];
var dataCount = 20;
var startTime = +new Date();
var categories = ['14/2/2020'];
var types = [
{name: 'Offline', color: 'red'},
{name: 'Online', color: 'green'},
];
// Generate mock data
@chunrapeepat
chunrapeepat / Guitar Framework
Last active May 28, 2022 13:47
a framework that help me learn & play guitar
Up: +4, Down: +3
Embellishment Table:
1 b9 2 m3 M3 4 b5 5 #5 6 m7 M7
8 9 11 b13 13
Chord Voicing:
E: 1 5 8 3 (5) (8)
@chunrapeepat
chunrapeepat / maxSubarray.js
Last active February 17, 2021 05:44
DAY9 - Dynamic Programming - Maximum Subarray Solution
// top-down approach
function maxSubarray(arr) {
const memo = {};
let answer = Number.MIN_VALUE;
function _maxSubarray(arr, i) {
// base case
if (arr.length === 0) return 0;
if (i === 0) return arr[0];
// induction case
@chunrapeepat
chunrapeepat / coinChange.js
Last active April 24, 2020 14:48
DAY9 - Dynamic Programming - Coin Change Solution
// top-down approach
const memo = {};
function coinChange(n) {
// base case
if (n <= 0) return Number.MAX_VALUE;
if (n === 1 || n === 3 || n === 4) return 1;
// induction case
if (memo[n]) return memo[n];
memo[n] = Math.min(...[coinChange(n-1),
coinChange(n-3),
@chunrapeepat
chunrapeepat / findFirstOne.js
Last active April 19, 2020 12:33
DAY5 - Binary Search - Find first number 1 in array
function findFirstOne(arr) {
let L = 0;
let R = arr.length - 1;
let result = -1;
while (L <= R) {
let mid = Math.floor(L + (R - L) / 2);
if (arr[mid] === 1) {
result = mid;
R = mid - 1;
} else {
@chunrapeepat
chunrapeepat / hasSqrt.js
Created April 19, 2020 12:14
DAY5 - Binary Search - has square root
function hasSqrt(N) {
let L = 0;
let R = N;
while (L <= R) {
let mid = Math.floor(L + (R - L) / 2);
let sqare = Math.pow(mid, 2);
if (sqare === N) {
return true;
} else if (sqare < N) {
L = mid + 1;
@chunrapeepat
chunrapeepat / printnum.asm
Created March 11, 2019 16:24
Print the number in Assembly Language (printnum.asm)
TITLE print the number
STACK SEGMENT STACK
dw 64 dup(?)
STACK ENDS
DATA SEGMENT
LINE db 3 dup(?),10,13,'$'
DATA ENDS