Skip to content

Instantly share code, notes, and snippets.

View Soontao's full-sized avatar
😊
I may be slow to respond.

Theo Sun Soontao

😊
I may be slow to respond.
View GitHub Profile
@Soontao
Soontao / go_key_lock.go
Last active May 20, 2020 08:01
Golang lock by key
package go_key_lock
import "sync"
// KeyLock type
type KeyLock struct {
locks *sync.Map
mu *sync.Mutex
}
import { Router } from "express";
export const router = Router();
router.use((request, response, next) => {
const { path, method, body } = request;
const parts = path.split("/").filter(Boolean);
let objectId = "";
let actionName = "";
@Soontao
Soontao / convert_flac_to_mp3.sh
Created September 5, 2020 01:40
Convert Flac to MP3
#!/bin/bash
find . -name "*.flac" -exec ffmpeg -i {} -ab 320k -map_metadata 0 -id3v2_version 3 {}.mp3 \;
@Soontao
Soontao / ubuntu_set_ustc_mirror.sh
Created November 2, 2020 06:31
Set ubuntu apt mirror to USTC
# default
sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
# china
sudo sed -i 's/cn.archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
@Soontao
Soontao / create_users.sh
Last active November 2, 2020 07:37
create multi users with bash
#!/bin/bash
# run with root
# sudo bash ./create_users.sh
count=10
usrprefix=user
dftpass=123456
dftshell=/bin/bash
#!/bin/bash
# run with root
# sudo bash ./install_docker_ubuntu.sh
apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
apt-get remove docker docker-engine docker.io containerd runc
apt-get install -y apt-transport-https ca-certificates curlg-agentsoftware-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
{
"xsappname":"mt-server-starter",
"tenant-mode":"shared",
"description":"",
"scopes":[
{
"name":"$XSAPPNAME.Callback",
"description":"With this scope set, the callbacks for subscribe, unsubscribe and getDependencies can be called.",
"grant-as-authority-to-apps":[
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
{
"appId":"mt-server-starter!t16391",
"appUrls":{
"onSubscription":"https://you-app-routes.cfapps.us10.hana.ondemand.com/callback/v1.0/tenants/{tenantId}"
},
"displayName":"MT Stater SaaS",
"description":"MT Stater SaaS",
"category":"Service"
}
@Soontao
Soontao / debounce.js
Created January 5, 2021 05:57
debounce function
function debounce(func, wait) {
var timer;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
timer = null;
func.apply(context, args);
}, wait);
};
// main.js
const cluster = require('cluster')
if (cluster.isMaster) {
console.log("starting...");
for (var i = 0; i < 4; i++) {