Skip to content

Instantly share code, notes, and snippets.

View yangsibai's full-sized avatar
🎯
Focusing

sibo yangsibai

🎯
Focusing
  • Chengdu
View GitHub Profile
@yangsibai
yangsibai / Selected_layers-PS.jsx
Created September 4, 2020 11:28 — forked from hilukasz/Selected_layers-PS.jsx
get array of selected layers in photoshop via extendscript
var docRef = app.activeDocument;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function newGroupFromLayers(doc) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( sTID('layerSection') );
@yangsibai
yangsibai / webgl.html
Created August 27, 2020 08:15 — forked from rdm/webgl.html
A quick demo of something paint-like in webgl
<html>
<title>WebGL Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
function useShader(gl, program, scriptId) {
var shaderScript= document.getElementById(scriptId); console.log('shaderScript: ',shaderScript);
var shaderType= gl[shaderScript.type.replace(/.*\//,'')]; console.log('shaderType: ',shaderType);
var shader= gl.createShader(shaderType); console.log('shader: ',shader);
gl.shaderSource(shader, shaderScript.text);
@yangsibai
yangsibai / index.js
Created July 26, 2019 01:22 — forked from valpackett/index.js
oxipng wasm wrapper
(async function () {
await wasm_bindgen('oxipng_wasm_bg.wasm')
window.oxi = wasm_bindgen
oxi.init()
const resp = await fetch('y.png')
const arb = await resp.arrayBuffer()
const uarr = new Uint8Array(arb)
console.log(uarr)
const t0 = performance.now()
window.result = oxi.optimize_from_memory(uarr)
@yangsibai
yangsibai / ffmpeg.md
Created August 22, 2018 13:48 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@yangsibai
yangsibai / entering_range.scpt
Created April 28, 2018 03:50 — forked from hiilppp/entering_range.scpt
AppleScript to unlock your Mac's screen. (Use EventScripts to automatically trigger script when a Bluetooth device (e.g., your iPhone) enters your Mac's range: http://www.mousedown.net/mouseware/EventScripts.html)
-- You need to create a Keychain item whose name matches what you use in place
-- of "[keychain_item_name]" on line #7 (and whose password is identical to your
-- user account's password).
tell application "System Events"
if ((get name of every process) contains "ScreenSaverEngine") then
set pw to (do shell script "security find-generic-password -l \"[keychain_item_name]\" -w")
tell application "ScreenSaverEngine" to quit
delay 0.5
keystroke pw

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@yangsibai
yangsibai / introrx.md
Created February 2, 2018 08:32 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@yangsibai
yangsibai / 1) Install
Created May 7, 2016 05:46 — forked from nghuuphuoc/1) Install
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@yangsibai
yangsibai / pre-push.sh
Created March 22, 2016 10:45 — forked from pixelhandler/pre-push.sh
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
@yangsibai
yangsibai / GoMgoSample-1.go
Created February 2, 2016 01:19 — forked from ardan-bkennedy/GoMgoSample-1.go
Sample Go and MGO example
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {