View build_osmesa.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on Ubuntu 20.04 | |
apt get install python3 python3-distutils ninja-build libpciaccess-dev | |
# add Mako and meson dependency from python | |
wget https://bootstrap.pypa.io/get-pip.py | |
python3 get-pip.py | |
pip install Mako | |
pip install meson | |
# download and install newest libdrm |
View git_diff.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. committed | |
# 2. staged but not comitted | |
# 3. not added to stage | |
# compare between 2 & 3 | |
git diff [file] | |
# compare between 1 & 2 | |
git diff [file] --cached |
View sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# valid for pyrealsense2 2.35.2 | |
# make sure to upgrade python and other packages (cmake, for example) | |
# https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python for details | |
# 1. download source code from | |
# https://github.com/IntelRealSense/librealsense/releases | |
# 2. in the top level of the package | |
mkdir build | |
cd build |
View crawler_text-to-speech.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Crawler = require("crawler"); | |
const textToSpeech = require('@google-cloud/text-to-speech'); | |
const fs = require('fs'); | |
const util = require('util'); | |
const MPlayer = require('mplayer'); | |
const player = new MPlayer(); | |
async function getSpeech(ssml) { | |
// Construct the request |
View toggle_telegram_ifttt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require("https"); | |
const api_token = "你的 API Token"; | |
const workplace_id = "你的 Workplace ID"; | |
const user_agent = "你的邮箱或应用名"; | |
const webhook = `https://maker.ifttt.com/trigger/你的Event名/with/key/你url的key`; | |
const url = new URL( | |
"https://toggl.com/reports/api/v2/details?user_agent=" + |
View prop.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PropTypes from 'prop-types'; | |
class App extends Component {... | |
getSth(){ return this.xxx; } // getSth = () => this.xxx; | |
render() { | |
return (<p>{this.getSth().bind(this)}</p>) | |
} | |
} |
View functions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. as an object | |
// it works as "let" i.e. visible in block | |
func1("wow"); // Error | |
let func1 = function(var1) { | |
console.log(var1); | |
} | |
func1("wow"); // wow | |
// 2. as a function | |
func2("wow"); // wow |
View var_let.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// var is kind of global variable | |
console.log(a); // undefined | |
var a = "wow"; | |
console.log(a); // wow | |
var a = "wowow"; | |
console.log(a); // wowow | |
// visible globally | |
// visible only within a block | |
while (true) { |
View forInForOf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let list = [6,8,10]; | |
list.tag = "hello"; | |
// values of the numeric properties of the object being iterated | |
for(i of list) { // 6 8 10 | |
console.log(i) | |
} | |
// keys on the object being iterated | |
for(i in list) { // 0 1 2 tag |