Skip to content

Instantly share code, notes, and snippets.

View robertu7's full-sized avatar
🏁
#0d6763, #c0a46b

robertu robertu7

🏁
#0d6763, #c0a46b
View GitHub Profile
@robertu7
robertu7 / OpenSSL 速成
Last active August 29, 2015 14:16
「OpenSSL Cookbook」筆記
算法:RSA / DSA / ECDSA
- 通常使用 RSA
- ECDSA 尚未被 CA 廣泛支持
- SSH 通常使用 RSA 和 DSA
- 2048-bits RSA and DSA, at least 512-bits ECDSA
- Passphrase
- 確保 Key 可以安全地 存放、傳輸、備份
- 每次重啓服務器或操作 Key 時候,都要輸入密碼
文件類型
@robertu7
robertu7 / Express API 速成
Last active August 29, 2015 14:16
Express API 筆記
Application
- app.locals:定義本地變量
- app.mountpath:獲取 mounted 的 sub app 的路徑
- app.all():匹配所有 HTTP verbs
- app.engine():註冊渲染引擎
- app.listen():監聽端口
- app.param():給指定 paramter 添加 callback
- app.set() / app.get( ):設置 / 獲取常量
- app.user():安裝中間件
* 設置靜態文件訪問:app.use(express.static(__dirname + '/public'))
@robertu7
robertu7 / Linux 進程術語
Created March 5, 2015 02:54
「理解 Linux 進程」筆記
PID:標識和區分進程的 ID
- 隨機分配
- PPID:父進程的 ID
* PID 為 1 的進程由內核創建的 init 進程
進程狀態
- R(running, 0)
- S(sleeping, 1)
- D(disk sleep, 2):不可中斷睡眠狀態
- T(stopped, 4)
@robertu7
robertu7 / 使用 SSH 证书登录
Last active August 29, 2015 14:16
使用 SSH 证书登录
1. 本地生成公私钥:ssh-keygen -t rsa
2. 复制 id_rsa.pub 到 远端 .ssh/authorized_keys(权限:644)
3. 修改配置 /etc/ssh/sshd_config
- RSAAuthentication yes
- PubkeyAuthentication yes
- AuthorizedKeysFile .ssh/authorized_keys
- 可选:PasswordAuthentication no
@robertu7
robertu7 / FWFSA.css
Created March 7, 2015 07:15
修復 -webkit-font-smoothing: antialiased 在 input 和 button 元素不起作用的 BUG
input, button {
-webkit-font-smoothing: antialiased !important;
}
@robertu7
robertu7 / autofocus.js
Last active August 29, 2015 14:16 — forked from mlynch/autofocus.js
AngularJS Directive:Autofocus 基於是否為 Mobile Browser
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus>
*/
angular.module('autofocusDirective', [])
.directive('autofocus', ['$rootScope', '$window', '$timeout', function ($rootScope, $window, $timeout){
@robertu7
robertu7 / DDBB.css
Created March 11, 2015 11:36
Disable Desktop Browser Bounce
html {
height: 100%;
overflow: hidden;
}
body {
height: 100%;
overflow: auto;
}
@robertu7
robertu7 / hideKeyboard.js
Created March 12, 2015 07:15
AngularJS Directive:在 Mobile Browser 提交表單後自動隱藏 Keyboard
/**
* Usage:
* <form hide-keyboard></form>
*/
angular.module('hideKeyboardDirective', [])
.directive('hideKeyboard', ['$rootScope', function ($rootScope){
return {
restrict: 'A',
controller: function (){
@robertu7
robertu7 / BPL.js
Last active August 29, 2015 14:17
Begin Place List
var place_list = [
// Games
{'name': '河洛客棧', 'lat': 25.9, 'lon': 22.9}, // 金庸群俠傳 - 河洛客棧(259, 229)
// TV Shows
{'name': 'Walt\'s House', 'lat': 35.126407, 'lon': 106.536532}, // Breaking Bad 絕命毒師
{'name': 'Winterfell', 'lat': 56.185096, 'lon': -4.050264}, // Game of Thrones 權力的遊戲
{'name': '思い出横丁', 'lat': 35.693267, 'lon': 139.699624}, // 深夜食堂
{'name': 'St Bart\'s Hospital', 'lat': 51.518524, 'lon': -0.102420}, // Sherlock 神探夏洛克
// Movies
{'name': 'West 57th Street', 'lat': 40.767518, 'lon': -73.984131}, // Taxi Driver 出租車司機
@robertu7
robertu7 / Distance.js
Created March 30, 2015 09:26
Calculates the distance between two points (given the latitude/longitude of those points)
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//::: :::
//::: This routine calculates the distance between two points (given the :::
//::: latitude/longitude of those points). It is being used to calculate :::
//::: the distance between two locations using GeoDataSource (TM) prodducts :::
//::: :::
//::: Definitions: :::
//::: South latitudes are negative, east longitudes are positive :::
//::: :::
//::: Passed to function: :::