Skip to content

Instantly share code, notes, and snippets.

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

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
-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
@dongyuwei
dongyuwei / 如何快速熟悉新项目.md
Created July 25, 2018 08:27
如何快速熟悉新项目?
  • 从build入手:理解项目模块依赖关系
  • 从CI/CD入手:理解项目开发-测试-发布流程
  • 从测试入手:单元测试、集成测试、E2E测试
  • 理解宏观架构,通读技术文档和代码
  • 使用debugger跟踪代码执行核心流程
  • 关注细节:一切不知道的都是需要了解的
const exec = require("child_process").execSync;
const devicePreferences = exec(
`/usr/libexec/PlistBuddy -c "Print :DevicePreferences" ~/Library/Preferences/com.apple.iphonesimulator.plist`
).toString();
const regexp = /\s+([A-Za-z0-9-]+)\s=\sDict\s\{/g;
let matched = [];
while ((matched = regexp.exec(devicePreferences)) !== null) {
const simulatorUuid = matched[1];
try {
@dongyuwei
dongyuwei / backup_react_native_async_storage.rb
Last active February 16, 2018 07:22
This is a simple ruby script to backup react-native AsyncStorage in iOS Simulator. So we can backup and restore the whole redux store in AsyncStorage for development.
#!/usr/bin/env ruby
# backup workbench.app's AsyncStorage filesystem, so we can restore the whole redux store for development.
require "open3"
Open3.popen3("ps ax | grep workbench.app | awk '{print $5}' ") { |stdin, stdout, stderr|
process_name = stdout.readlines()[0]
base_dir = process_name.split('/data/')[0]