Skip to content

Instantly share code, notes, and snippets.

View hbin's full-sized avatar

Huang Bin hbin

  • China, Beijing
View GitHub Profile
@hbin
hbin / hbin's keyboard
Created June 2, 2012 02:43
Keyboard setting for NBA Live 2005
bind K_4 PLAYCALL4
bind K_3 PLAYCALL3
bind K_2 PLAYCALL2
bind K_1 PLAYCALL1
bind K_DOWN DOWN
bind K_UP UP
bind K_LEFT LEFT
bind K_RIGHT RIGHT
bind K_Z BACKDOWN
bind K_C CROSSOVER
@hbin
hbin / stylish-railscast.css
Last active December 17, 2015 10:49
Stylish for railscast
body{
background: #222 !important;
color: #999 !important;
}
code{
background: #111;
border-radius: 3px;
border-color: #555 !important;
}
@hbin
hbin / Install_tmux
Created November 22, 2013 03:25 — forked from simme/Install_tmux
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@hbin
hbin / bootstrap-scripts.md
Last active December 21, 2022 13:36
Bootstrap scripts

Bootstrap scripts

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install curl git-core python-software-properties

Firewall

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@hbin
hbin / benchmark_net_http.rb
Last active August 29, 2015 13:57
Net HTTP Benchmark(net/http, open-uri, curb, typhoeus)
require 'rack'
require 'rack/handler/webrick'
require 'net/http'
# The code for this is inspired by Capybara's server:
# http://github.com/jnicklas/capybara/blob/0.3.9/lib/capybara/server.rb
class LocalhostServer
READY_MESSAGE = "Server ready"
class Identify
@hbin
hbin / kaminar_array.rb
Created May 13, 2014 15:55
This would be helpful when handling an Array object for the kaminari gem.
if defined?(Kaminari)
class Array
# This would be helpful when handling an Array object that
# has a different count value from actual count.
#
# Example:
# arr = ['a', 'b', 'c', 'd', 'e']
#
# paged = arr.paginate(total_count: 200).page(2) #-> ['a', 'b', 'c', 'd', 'e']
# paged.total_count #-> 200
@hbin
hbin / benchmark_escape_html.rb
Last active June 11, 2018 05:10
Benchmark escape html methods
require 'benchmark/ips'
require 'open-uri'
require 'cgi'
require 'erb'
require 'rack'
puts "===== Short String =====\n\n"
Benchmark.ips do |x|
@hbin
hbin / init-deb.sh
Created July 21, 2014 07:33
Init Script For Manage Nginx
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@hbin
hbin / dashboard_controller.rb
Last active August 29, 2015 14:05
Rickshaw real-time chart example
class DashboardController < ApplicationController
def index
end
def status
failed = rand(100)
processed = rand(100) + 500
render json: {
Total: failed + processed,