View git_diff.sh
# 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 📊 Weekly development breakdown
Python 9 hrs 29 mins ███████████████████▋░ 94.0% | |
JSON 29 mins █░░░░░░░░░░░░░░░░░░░░ 4.8% | |
XML 6 mins ▏░░░░░░░░░░░░░░░░░░░░ 1.1% | |
HTML 0 secs ░░░░░░░░░░░░░░░░░░░░░ 0.1% | |
JavaScript 0 secs ░░░░░░░░░░░░░░░░░░░░░ 0.0% |
View sh
# 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
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
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
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
// 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
// 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
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 |