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 / composer-install.md
Last active August 29, 2015 14:05
PHP composer install guides globally
  // composer.phar是二进制文件
  // 它是一个PHAR (PHP archive),PHP的归档格式,也可以像其他命令一样在命令行上运行。
  
  $ curl -sS https://getcomposer.org/installer | php
  $ sudo mv composer.phar /usr/local/bin/composer

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

@simlegate
simlegate / examples
Last active December 3, 2015 18:19
man httping
httping -g URL -C "key=value" -s -c 5
# 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;
@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;
}

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

@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 / 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 / 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 / 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