Skip to content

Instantly share code, notes, and snippets.

View yuanoook's full-sized avatar

Undefined yuanoook

View GitHub Profile
@yuanoook
yuanoook / JavaScript.md
Created February 28, 2021 08:25
JavaScript.md

Core: Full Name & Definition

What, Why, How, When, Example

3 Dimensions

Vertical: Parent, Children

@yuanoook
yuanoook / nvm-auto-switch-node-for-zsh.sh
Created February 3, 2021 07:16
nvm auto switch node version by current working directory for zsh
# Put this in your ~/.zshrc please
# To set node version by folder
# run: echo "v8.5.0" > .nvmrc
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
@yuanoook
yuanoook / nvm-windows-auto-switch-node-for-git-bash.sh
Last active July 12, 2023 01:37
nvm-windows auto switch node version by current working directory for git-bash
# Put this in your ~/.bashrc please
# To set node version by folder
# run: echo "v8.5.0" > .nvmrc
nvm_echo() {
command printf %s\\n "$*" 2>/dev/null
}
# Traverse up in directory tree to find containing folder
@yuanoook
yuanoook / clickable.js
Created December 5, 2020 08:29
clickable.js
function clickable(node) {
if (
node.offsetHeight < 5 ||
node.offsetWidth < 5
) {
return false
}
const rect = node.getBoundingClientRect()
const inViewPort = !(
@yuanoook
yuanoook / faas.js
Created September 17, 2020 10:59
Function as a service
const Koa = require('koa');
const app = new Koa();
app.use(async ctx => {
const s = eval(ctx.request.query.s)
const r = eval(s)()
ctx.response.body = r
});
app.listen(3003);
@yuanoook
yuanoook / matlab_image_processing.m
Last active April 13, 2022 09:09
Matlab image processing practice
% Practice #1
% Write a computer program capable of reducing the number of intensity levels in an image from 256 to 2, in integer powers of 2. The desired number of intensity levels needs to be a variable input to your program. Display Variable Values Create a variable with numbers and another variable with text.
size = '128';
a = imread(['https://avatars3.githubusercontent.com/u/7521814?s=' size]);
imshow(a);
test(rgb2gray(a));
test(a);
function y = im_downgrade(img, intensity_levels)
@yuanoook
yuanoook / Autopilot.js
Created August 21, 2019 07:40
Autopilot.js
/*
Autopilot System
Flow
Condition > Behavior
Auto
Detect > Suggest > [Wait]
Switch >
@yuanoook
yuanoook / autoTypingZHDate.js
Created December 5, 2018 06:34
autoTypingZHDate
test();
function check(bool) {
console.log(bool ? 'pass' : 'failed')
}
function test() {
check(autoTypingZHDate("201") === "201");
check(autoTypingZHDate("2018") === "2018年");
@yuanoook
yuanoook / hi.js
Last active October 20, 2018 11:19
HI = window.HI || {}
HI.waitMS = async ms => new Promise(resolve => setTimeout(resolve, ms))
HI.loadJS = (src, call) => {
var script = document.createElement('script')
script.src = src // + '?_t=' + Date.now()
script.onload = call
document.head.appendChild(script)
}
@yuanoook
yuanoook / SketchSystems.spec
Created June 21, 2018 13:24
My Awesome Sketch
My Awesome Sketch
First State
some event -> Second State
Second State