Skip to content

Instantly share code, notes, and snippets.

View dongyuwei's full-sized avatar
💭
天天听儿歌

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile

上次培训有人问git bisect这个命令怎么应用,今天查了一下文档并实际动手练习了一下,如果项目有自动化测试,那么使用起来就比较简单了, 比如:

  1. git bisect start master 2f381c3 master 也可以是特定的commit rev
  2. git bisect run node test.js

很快就可以自动定位是哪个 commit让测试挂了。

但如果没有自动化测试,或者自动化测试覆盖不全,或者测试运行很慢(如e2e)测试,那么可能就需要人工介入,git bisect还有很多半自动化的运行模式,使用起来稍微复杂一些。

Math.log2(100) == 6.6, 100个commits只需要跑7次测试就可以找到bad commit。问题就是每次测试需要多久了。每次10分钟也需要70分钟了。

@dongyuwei
dongyuwei / node-chakracore-time-travel-debugger-launch.json
Last active June 4, 2019 05:08
vscode launch setting for node-chakracore-time-travel-debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Time-Travel Live",
"type": "node-chakracore-time-travel-debugger",
"request": "launch",
"program": "${workspaceFolder}/test.js",
"cwd": "${workspaceFolder}"
}
-ifndef(PRINT).
-define(PRINT(Var), io:format("DEBUG: ~p:~p - ~p~n~n ~p~n~n", [?MODULE, ?LINE, ??Var, Var])).
-endif.
@dongyuwei
dongyuwei / flatbuffer.demo.md
Last active May 15, 2019 09:22
flatbuffer for english dictionary

flatbuffer Scheme: dictionary.fbs

table Word {
  frequency:long;
  ipa:string;
  translation:[string];
}
{
  "keys": [
    "downbeat"
  ],
  "values": [
    {
      "frequency": 236548,
      "ipa": "daʊnˈbit",
 "translation": [
@dongyuwei
dongyuwei / gif.sh
Last active September 20, 2019 07:49
convert -resize '368x268!' -delay 50 *.png animation.gif
gifsicle --colors 256 animation.gif --no-loopcount > animation2.gif
gifsicle -O3 --lossy=80 animation2.gif -o animation3.gif

install graphviz

brew install graphviz -v

write a .dot file

cat test.dot

graph {
    a -- b;
    b -- c;
 a -- c;
{
relativeUrls: true,
dumpLineNumbers: 'comments'
}
@dongyuwei
dongyuwei / detect-bad-svg.rb
Created September 21, 2018 01:40
find the svg which fontcustom failed to compile
files = `ls ./svg_icons/*.svg`
bad_files = []
files.split("\n").each {|f|
`rm -rf ./tmp ./tmp2`
`mkdir ./tmp`
`cp #{f} ./tmp`
ok = system("fontcustom compile ./tmp/ -o tmp2")
if $?.exitstatus != 0
puts "bad file: #{f}"
bad_files.push f