Skip to content

Instantly share code, notes, and snippets.

Avatar

Sheron W sheronw

View GitHub Profile
@sheronw
sheronw / git_diff.sh
Created Sep 25, 2020
compare between different state #git
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
Java 5 hrs 27 mins ████████████████████▋ 98.6%
Git Config 4 mins ▎░░░░░░░░░░░░░░░░░░░░ 1.4%
Other 0 secs ░░░░░░░░░░░░░░░░░░░░░ 0.0%
@sheronw
sheronw / sh
Last active Jun 18, 2020
build pyrealsense2 from source
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
@sheronw
sheronw / crawler_text-to-speech.js
Last active Apr 17, 2020
Some snippets for **my** raspberry Pi speaker
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
@sheronw
sheronw / toggle_telegram_ifttt.js
Created Apr 14, 2020
Use #IFTTT to send #Toggl Reports to #Telegram
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=" +
@sheronw
sheronw / prop.js
Last active Jun 12, 2020
set up #react
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>)
}
}
@sheronw
sheronw / functions.js
Created Mar 23, 2020
different types of function declaration in #js
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
@sheronw
sheronw / var_let.js
Created Mar 23, 2020
difference between var and let in #js
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) {
@sheronw
sheronw / unrelated_history.sh
Last active Mar 22, 2020
merge unrelated branch back to master #git
View unrelated_history.sh
git checkout master
# put everything remote to this branch
git rebase origin master
# merge another branch to the updated master
git merge your-branch --allow-unrelated-histories
@sheronw
sheronw / forInForOf.js
Created Mar 21, 2020
different between for...in and for...of #js
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
You can’t perform that action at this time.