Skip to content

Instantly share code, notes, and snippets.

View masogit's full-sized avatar
🙂

Man, Shuo masogit

🙂
  • GE Healthcare
  • Shang, hai
View GitHub Profile
@masogit
masogit / global.js
Last active March 20, 2022 10:39
most simple react global state
import { useState } from "react";
const initGlobal = new Map();
export const getGlobal = mapKey => {
if (mapKey) {
return initGlobal.get(mapKey);
} else {
return initGlobal;
}
@masogit
masogit / hhkb_ctrl_to_caplock.json
Created September 3, 2019 10:22
hhkb press ctrl alone as caplock
{
"title": "Ctrl to Caplock",
"rules": [
{
"description": "Post caps_lock if left_control is tapped alone!",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_control",
@masogit
masogit / hhkb_ctrl_to_caplock.json
Created September 3, 2019 10:22
hhkb press ctrl alone as caplock
{
"title": "Ctrl to Caplock",
"rules": [
{
"description": "Post caps_lock if left_control is tapped alone!",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_control",
@masogit
masogit / find_relations.js
Last active April 12, 2019 17:05
查找朋友关系
const peoples = [
{
name: 'A', friends: [
{ name: 'B' },
{ name: 'X' },
{ name: 'C' },
]
},
{
name: 'D', friends: [
@masogit
masogit / emacs.ahk
Last active February 10, 2023 03:01
AutoHotKey use emacs on windows
LAlt::LCtrl
LCtrl::LAlt
CapsLock & p::Up
CapsLock & n::Down
CapsLock & b::Left
CapsLock & v::^Left
CapsLock & f::Right
CapsLock & g::^Right
CapsLock & e::End
@masogit
masogit / quickSort.js
Created March 6, 2019 03:04
quickSort
var quickSort = function (arr) {
if (arr.length <= 1) { return arr; }
var pivot = arr.pop()
console.log('pivot', pivot)
var left = [];
var right = [];
@masogit
masogit / rubbits.js
Created January 7, 2017 08:53
Fibonacci sequence
const initMonth = 1;
const initRubbits = 2;
const totalMonths = 10;
const pregnancyMonths = 2;
const kidsRubbits = 2;
const parentRubbits = 2;
function rubbits(month) {
if (month == initMonth)
return initRubbits;
@masogit
masogit / triangle_css.html
Created December 29, 2016 17:03
Display triangle border by css
<!DOCTYPE html>
<html>
<head>
<style>
.triangle {
border-width: 15px;
border-style: solid;
border-color: #3cba54 #f4c20d #db3236 #4885ed;
padding: 5px;
}
@masogit
masogit / sort_tree.js
Created December 3, 2016 11:08
Binary tree sort
let arr = [8, 7, 5, 1, 0, 2, 6, 9];
let tree = {};
function build(num, tree) {
if (!tree.self) {
tree.self = num;
} else {
if (num > tree.self) {
tree.right = tree.right || {};
@masogit
masogit / sort_quick.js
Created December 3, 2016 05:46
Quick sort implement by js
let arr = [85, 24, 63, 45, 17, 31, 96, 50];
function split(arr) {
if (arr.length <= 1)
return arr;
else {
let pivot = arr[0];
let less = [];
let larger = [];