Skip to content

Instantly share code, notes, and snippets.

View metaory's full-sized avatar

Pou Yan metaory

View GitHub Profile
@metaory
metaory / resume.json
Created March 8, 2024 07:40
resume.json
{
"basics": {
"name": "John Doe",
"label": "Programmer",
"image": "",
"email": "john@gmail.com",
"phone": "(912) 555-4321",
"url": "https://johndoe.com",
"summary": "A summary of John Doe…",
"location": {
@metaory
metaory / weak-cache.js
Last active January 9, 2024 08:42
WeakMap Cache
const { log } = console;
const TTL_MN = 5 // mintes
const TTL_MS = TTL_MN * 60 * 1_000 // milliseconds
const MapRefs = new Map();
const Maps = new WeakMap();
function fetchStuff(someId) {
const ref = MapRefs.get(someId);
const map = Maps.get(ref);
const expired = Date.now() - (map?.ts ?? 0) > TTL_MS
@metaory
metaory / replace-wildcard-with-non-repeating.js
Last active June 10, 2022 14:53
replace wildcard with non-repeating characters
/*
Rick is a fan of logic-based games. However, he is bored of the classic ones, like Sudoku and Mastermind, since he has solved so many of them. Recently he found a new game in which one is given a string with some question marks in it. The objective is to replace all of the question marks with letters (one letter per question mark) in such a way that no letter appears next to another letter of the same kind.
Write a function:
function solution(riddle);
that, given a string riddle, returns a copy of the string with all of the question marks replaced by lowercase letters (a−z) in such a way that the same letters do not occur next to each other. The result can be any of the possible answers as long as it fulfils the above requirements.
Examples:
# [DESKTOP]
#require("electron").webFrame.setZoomFactor(1)
# [LAPTOP]
#require("electron").webFrame.setZoomFactor(1.5)
#require("electron").webFrame.setZoomFactor(0.8)
#require("electron").webFrame.setZoomFactor(0.5)
@metaory
metaory / install-redis.sh
Created November 30, 2015 13:01 — forked from four43/install-redis.sh
Install Redis
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.githubusercontent.com/four43/e00d01ca084c5972f229/raw/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@metaory
metaory / gist:56e3f92781860a45db8c
Created November 16, 2015 14:01 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch