Skip to content

Instantly share code, notes, and snippets.

View qhwa's full-sized avatar

Qiu Hua qhwa

View GitHub Profile
@blackjid
blackjid / gulpfile.js
Created April 9, 2014 17:59
Gulp Ionic Server + Livereload + Proxy
var gulp = require('gulp');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var connect = require('gulp-connect');
var paths = {
css: ['./www/css/**/*.css'],
js: ['./www/js/**/*.js'],
@maxlapshin
maxlapshin / gdns.erl
Created May 20, 2013 09:54
Geo DNS server in erlang
%% @doc This is a simple geo-dns server
%% It takes existing erlang dns query parser and https://github.com/mochi/egeoip
%% Here is no implemented database for path routing with some region affinity,
%% so if you are going to use it, you need to implement following databases:
%% 1) Domain -> existing servers
%% 2) Country -> region
%% 3) region -> existing server
-module(gdns).
-author("Max Lapshin <[email protected]>").
-export([start_link/0]).
@nightire
nightire / Changes in Rails 4_1.md
Last active April 21, 2025 07:25
拥抱 Rails 4 —— 详述 Rails 4 的新变化

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb
@bentonporter
bentonporter / gist:2891463
Created June 7, 2012 20:51
Ruby - HMAC-SHA256 example
require 'openssl'
require 'Base64'
key = "secret-key"
data = "some data to be signed"
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip()
/* Arduino USB Keyboard HID demo
* Volume+/Volume-/Mute keys
*/
uint8_t buf[8] = {
0 }; /* Keyboard report buffer */
#define PIN_VOLUME_UP 5
#define PIN_VOLUME_DOWN 6
#define PIN_MUTE 7
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ovidiuch
ovidiuch / create_db.sql
Created March 31, 2012 11:21
MySQL utf8 db and user create
CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT SELECT, INSERT, UPDATE, DELETE ON dbname.* TO 'usr'@'localhost' IDENTIFIED BY 'passwd';