Skip to content

Instantly share code, notes, and snippets.

View simlegate's full-sized avatar
🎯
Focusing

Devin Zhang simlegate

🎯
Focusing
View GitHub Profile
@simlegate
simlegate / nginx-init
Last active December 19, 2015 09:19
nginx init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# 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
@simlegate
simlegate / mutli_thread_web_server.rb
Last active December 20, 2015 00:49
Ruby 构建一个简单的支持多线程的 Web 服务器
require 'thread'
require 'socket'
class RequestHandler
def initialize(session)
@session = session
end
def process
while @session.gets.chop.length != 0
@simlegate
simlegate / rspec_example.rb
Last active December 24, 2015 04:09
Rspec Syntax
# stub class
stub_const('ResourceCategory', Class.new)
# stub class and stub it's methods
stub_const('ResourceCategory', Class.new).stub(:all).and_return([])
@simlegate
simlegate / gem_mirror_cmd.rb
Created October 23, 2013 04:41
Solove problem can't run <gem mirror>.
# $ gem mirror
# ERROR: Install the rubygems-mirror gem for the mirror command
# From: http://qiita.com/yoshiori/items/463de8be446cda6d67ca
require 'rubygems/mirror/command'
Gem::Commands::MirrorCommand.new.execute
@simlegate
simlegate / install.md
Last active January 20, 2022 03:41
搭建私有的gems仓库

分为步:

  • 同步gems mirror
    安装rubygems-mirror 原来的rubygems-mirror好像有问题,所以使用@huacnlee改过的gem
    按照README.md说明配置.mirrorrc

    # 国内最好用taobao的源,rubygems经常被墙
    ---
    - from: http://ruby.taobao.org
    to: /data/rubygems
@simlegate
simlegate / logger.clj
Last active December 28, 2015 13:49
利用可组合的高阶函数构建的一个日志系统
(ns logger.core)
(defn print-logger
[writer]
#(binding [*out* writer]
(println %)))
;; 将消息打印到一个内存buffer
(def writer (java.io.StringWriter.))
@simlegate
simlegate / after_linux.sh
Created January 23, 2014 09:31
安装Linux后自动安装常用的软件
#!/bin/bash
PKG_MANGER="sudo apt-get install"
HOME="/home/simlegate"
echo $PKG_MANGER
echo "正在安装Git......."
nohup $PKG_MANGER git

💯 👍 👎 🔢 🎱 🅰️ 🆎 🔤 🔡 🉑 🚡 ✈️ ⏰ 👽 🚑 ⚓ 👼 💢 😠 😧 🐜 🍎 ♒ ♈ ◀️ ⏬ ⏫ ⬇️ 🔽 ▶️ ⤵️ ⤴️ ⬅️ ↙️ ↘️ ➡️ ↪️ ⬆️ ↕️ 🔼 ↖️ ↗️ 🔃 🔄 🎨 🚛 😲 👟 🏧 🅱️ 👶 🍼 🐤 🚼 🔙 🛄 🎈 ☑️ 🎍 🍌 ‼️ 🏦 📊 💈 ⚾ 🏀 🛀 🛁 🔋 🐻 🐝 🍺 🍻 🪲 🔰 🔔 🍱 🚴 🚲 👙 🐦 🎂 ⚫ 🃏 ⬛ ◾ :

@simlegate
simlegate / nginx-assets-config
Last active August 29, 2015 14:01
配置Nginx服务Web静态资源
// 提高性能
// 让rails server只处理动态请求,不必浪费资源处理静态文件请求
// rails server处理静态文件的性能完全不能和nginx,apache之类的比。
location ~* ^/(images|javascripts|stylesheets|img)/ {
access_log off;
log_not_found off;
expires max;
break;
}
# sudo ln -s ~/nginx.conf unicorn.conf
upstream app_server {
server unix:/tmp/unicorn_padrino.sock fail_timeout=0;
}
server {
listen 80;
charset utf-8;
server_name db.innshine.com;