Skip to content

Instantly share code, notes, and snippets.

user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
@holin
holin / nginx.conf
Created October 26, 2011 02:27 — forked from samqiu/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;
@holin
holin / mysql2sqlite.sh
Created October 26, 2011 05:24 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@holin
holin / gist:1336130
Created November 3, 2011 09:28
Add jquery from console
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery() {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
@holin
holin / appcast.xml
Created January 4, 2012 02:44
Test Sparkle
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Beelog Changelog</title>
<link>http://www.gflashcards.com/beelog/appcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 2.0.0 (2 bugs fixed; 3 new features)</title>
<sparkle:releaseNotesLink>
@holin
holin / authlogic_to_devise.rb
Created March 26, 2012 04:44 — forked from gduquesnay/authlogic_to_devise.rb
Migration for authlogic to devise
class MigrateUsers < ActiveRecord::Migration
def self.up
rename_column :users, :crypted_password, :encrypted_password
add_column :users, :confirmation_token, :string, :limit => 255
add_column :users, :confirmed_at, :timestamp
add_column :users, :confirmation_sent_at, :timestamp
execute "UPDATE users SET confirmed_at = created_at, confirmation_sent_at = created_at"
add_column :users, :reset_password_token, :string, :limit => 255
@holin
holin / Omniauth Twitter Hash
Created March 27, 2012 08:19 — forked from charliemoseley/Omniauth Twitter Hash
Twitter Authentication hash
--
provider: twitter
uid: '15280529'
info:
  nickname: penguinbusiness
  name: Charlie Moseley
  location: Bellevue, WA
  image: http://a1.twimg.com/profile_images/281933747/kitamura_ava_normal.gif
  description: Developer, Otaku, Geek.
  urls:
@holin
holin / goxiazai.js
Created July 12, 2012 01:16
Goxiazai url
var f = $P('f');
var dl_url = decodeURIComponent(f);
$("body").prepend("<a style='color:red;font-size:1.5em' href='"+ dl_url +"'>下载</a>");
@holin
holin / jingnext
Created August 26, 2012 09:27
Jing+ Music Play Next AppleScript
-- 参考 http://hints.macworld.com/article.php?story=20110622061755509
on run
tell application "Safari"
set allWins to every window
set allTabs to {}
repeat with currWin in allWins
set allTabs to allTabs & every tab of currWin
end repeat
repeat with currTab in allTabs
try
@holin
holin / gist:5566381
Created May 13, 2013 05:47
curb(https://github.com/taf2/curb) 绑定ip和使用代理
require "minitest/autorun"
class TestInterface < Minitest::Test
def test_interface
test = "http://www.baidu.com"
ip = "172.16.3.14"
require 'curb'
c = Curl::Easy.new do |curl|