Skip to content

Instantly share code, notes, and snippets.

View huobazi's full-sized avatar
🎯
Focusing

Marble Wu huobazi

🎯
Focusing
View GitHub Profile
@huobazi
huobazi / template_mail.rb
Created August 1, 2011 05:25
send email by template
# coding: utf-8
require "rubygems"
require "yaml"
require "mail"
DEBUG = ARGV[0] == "-t" ? true : false
Mail.defaults do
delivery_method :smtp, {
:address => "authsmtp1.nri.co.jp",
@huobazi
huobazi / cfile.html
Created August 9, 2011 02:08 — forked from sofish/cfile.html
customize input
<!Doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Customize input:file</title>
<style>
.sl-custom-file{position:relative;display:inline-block;zoom:1;cursor:pointer;overflow:hidden;vertical-align:middle;}
.sl-custom-file .ui-input-file{position:absolute;right:0;top:0;_font-size:100px;_font-size:12px;_zoom:30;font-size:300px\9;height:100%;_height:auto;opacity:0;filter:alpha(opacity=0);-ms-filter:"alpha(opacity=0)";cursor:pointer;}
</style>
</head>
@huobazi
huobazi / install_ruby.sh
Created August 10, 2011 03:02 — forked from gyulalaszlo/install_rails_stack.sh
Debian Squeeze i686 from blank install to RVM + Ruby 1.9.2 + MongoDB 1.8.2 + NGINX + Passenger
cd $HOME
mkdir binaries
cd binaries/
echo "Installing dev toolchain"
sudo apt-get install curl git bzip2 gcc make build-essential libcurl4-openssl-dev libssl-dev zlib1g-dev
echo "Getting Mongo..."
@huobazi
huobazi / gist:1167296
Created August 24, 2011 04:15
ruby object to yaml
File.open("demo.yml",'w:UTF-8') do|file|
file.puts topic.to_yaml
end
@huobazi
huobazi / will_paginate.js
Created August 26, 2011 03:33 — forked from huacnlee/will_paginate.js
使 WillPaginate 支持用左右键翻页
// Keyboard shortcuts for browsing pages of lists
(function($) {
$(document).keydown(handleKey);
function handleKey(e) {
var left_arrow = 37;
var right_arrow = 39;
if (e.target.nodeName == 'BODY' || e.target.nodeName == 'HTML') {
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
var code = e.which;
@huobazi
huobazi / gist:1172797
Created August 26, 2011 05:56
Regular expression to remove HTML comments
text = text.gsub(/<!--(.|\s)*?-->/,'')
@huobazi
huobazi / keyboard_code_enums.js
Created September 1, 2011 02:06 — forked from cjcliffe/keyboard_code_enums.js
Javascript Keycode Enums
var enums = {};
enums.keyboard = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
PAUSE: 19,
CAPS_LOCK: 20,
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@huobazi
huobazi / nginx.conf
Created September 15, 2011 02:17 — forked from huacnlee/nginx.conf
Nginx http proxy cache to mirror of Rubygems.org
# 在本地服务器建立 rubygems.org 的镜像缓存,以提高 gem 的安装速度
# 此配置设置缓存过期为1天,也就是说,新上的 gem 无法马上安装
# 做这个起什么作用?
# rubygems 的很多资源文件是存放到 Amazon S3 上面的,由于 GFW 对某些 S3 服务器又连接重置或丢包,导致 gem 安装异常缓慢或有时候根本无法连接安装。
# 而通过这种跳板的方式可以很好的解决这个问题,当然前提是 Nginx反向代理 服务器需要在国外
proxy_cache_path /var/cache/rubygems levels=1:2 keys_zone=RUBYGEMS:10m
inactive=24h max_size=1g;
server {
listen 80;
@huobazi
huobazi / Gemfile
Created September 21, 2011 08:29
Model can not named 'Thread'
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem "mongoid", "2.0.0"
gem "bson", "1.2.4"
gem "bson_ext", "1.2.4"