View turn_off_ ConnectHardwareKeyboard.js
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 {
View backup_react_native_async_storage.rb
#!/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]
View test-clang-format.sh
`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
View vscode.user.setting.json
// 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,
View routes.rb
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
View recursive_test.rb
@max_count = 5
def recursive_test(p1)
begin
if @max_count > 1
raise "test"
else
@max_count + p1
end
rescue
View create_snap_shots.rb
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
View gmail_sender.rb
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
View app.py
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)
View nginx-default-conf
vim `/etc/nginx/sites-available/default`
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name erlang.us;