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-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;

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 / 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
<?php
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
@simlegate
simlegate / ref.java
Created October 20, 2014 08:01
Java垃圾回收机制循环引用问题
class A{
public B b;
}
class B{
public A a;
}
public class Main{
public static void main(String[] args){
A a = new A();
zh-CN:
admin:
home:
name: "首页"
pagination:
previous: "&laquo; 上一页"
next: "下一页 &raquo;"
truncate: "…"
misc:
filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
@simlegate
simlegate / sec_websocket_key_rule.rb
Last active November 16, 2015 15:56
something important about Websocket handshaking
require 'digest/sha1'
require 'base64'
# client request
# GET / HTTP/1.1
# Upgrade: websocket
# Connection: Upgrade
# Host: example.com
# Origin: null
# Sec-WebSocket-Key: sN9cRrP/n9NdMgdcy2VJFQ==
@simlegate
simlegate / examples
Last active December 3, 2015 18:19
man httping
httping -g URL -C "key=value" -s -c 5