Skip to content

Instantly share code, notes, and snippets.

View bluenex's full-sized avatar
🧐
Be explicit with the least redundant.

Tulakan Ruangrong bluenex

🧐
Be explicit with the least redundant.
View GitHub Profile
@bluenex
bluenex / findClosestTimestampPair.ts
Last active September 27, 2023 06:51
A collection of snippets
interface ObjectWithTimestamp {
timestamp: number;
}
function findClosestTimestampPair(
arr1: ObjectWithTimestamp[],
arr2: ObjectWithTimestamp[]
): [ObjectWithTimestamp, ObjectWithTimestamp][] | [] {
arr1.sort((a, b) => a.timestamp - b.timestamp);
arr2.sort((a, b) => a.timestamp - b.timestamp);
@bluenex
bluenex / climbStairs.js
Last active August 19, 2022 05:54
Visualize the possibility of https://leetcode.com/problems/climbing-stairs. Can be run up to around n=18 before memory allocation error occurs.
// 1 -> 1
// 2 -> 11 2
// 3 -> 111 12 21
// 4 -> 1111 112 121 211 22
// 5 -> 11111 1112 1121 1211 122 2111 212 221
// 6 -> 111111 11112 11121 11211 12111 1122 1212 1221 21111 2112 2121 2211 222
const getAllScenarios = (current, collection) => {
if (!collection.has(current)) {
collection.set(current, "");
@bluenex
bluenex / cobalt2.itermcolors
Last active April 27, 2022 15:02
iTerm2 color theme collection
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
@bluenex
bluenex / alacritty.yml
Created February 16, 2021 06:08
My alacritty config file placing at `~/.config/alacritty/alacritty.yml`.
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Import additional configuration files
#
# Imports are loaded in order, skipping all missing files, with the importing
# file being loaded last. If a field is already present in a previous import, it
# will be replaced.
#
# All imports must either be absolute paths starting with `/`, or paths relative
# to the user's home directory starting with `~/`.
@bluenex
bluenex / day1.js
Last active February 16, 2021 06:06
A collection of snippets for Advent of Code 2020
function day1() {
var val = document.querySelector('pre').innerText;
var arr = val.split('\n').map(x => Number(x));
var finder = (main, rest, target) => {
let result = null;
rest.forEach(x => { if (main + x === target) { result = [main, x] } });
return result;
};
@bluenex
bluenex / mins.md
Created September 18, 2019 16:12
scraping-pattern

MINS event URL

http://go.activecalendar.com/UPennMINS/event/mahoney-institute-for-neurosciences-seminar---47th-annual-flexner-lecture/

Event slug

mahoney-institute-for-neurosciences-seminar---47th-annual-flexner-lecture
@bluenex
bluenex / gatsby-starter.md
Last active May 4, 2019 15:04
My personal Gatsby starter as a commands. Will probably become a repo later.

Create a project with hello-world base:

gatsby new gatsby-tutorial https://github.com/gatsbyjs/gatsby-starter-hello-world 

Install plugins. Here are plugins at the moment:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.