Skip to content

Instantly share code, notes, and snippets.

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

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@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]
`brew install clang-format`
`clang-format -h`
`clang-format -i -style=Mozilla InputController.mm`
`clang-format -style=Mozilla -dump-config`
ref: http://tonyarnold.com/2014/05/31/autoformatting-your-code.html
// Place your settings in this file to overwrite the default settings
{
"workbench.colorTheme": "Monokai Dimmed",
"window.zoomLevel": 1,
"workbench.statusBar.visible": false,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
admin_constraint = lambda do |request|
request.env['warden'].authenticate? and not request.env['warden'].user.nil?
end
constraints admin_constraint do
mount Logster::Web, at: "/logs"
end
@dongyuwei
dongyuwei / recursive_test.rb
Created August 23, 2017 03:37
test recursive function call in rescue block
@max_count = 5
def recursive_test(p1)
begin
if @max_count > 1
raise "test"
else
@max_count + p1
end
rescue
@dongyuwei
dongyuwei / create_snap_shots.rb
Created August 21, 2017 01:50
snapshot design for rails's ActiveRecord model
class CreateSnapShots < ActiveRecord::Migration[5.0]
def change
create_table :snap_shots do |t|
t.integer :user_id
t.string :table_name
t.text :table_data , limit: 4294967295
t.integer :table_id
t.integer :snapshot_id
t.timestamps
require 'pony'
=begin
Use gmail's smtp server to send email:
1. Turn on 2-Step Verification (see https://myaccount.google.com/security)
2. Sign in using App Passwords (see https://support.google.com/accounts/answer/185833?hl=en)
or alternative method:
1. Turn off 2-Step Verification (see https://myaccount.google.com/security)
2. Allow less secure apps: https://myaccount.google.com/u/0/lesssecureapps?pli=1
@dongyuwei
dongyuwei / app.py
Created July 18, 2017 12:45 — forked from rduplain/app.py
Add a second static directory to Flask, in ../static/.
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route('/base/<path:filename>')
def base_static(filename):
return send_from_directory(app.root_path + '/../static/', filename)