Skip to content

Instantly share code, notes, and snippets.

View simlegate's full-sized avatar
🎯
Focusing

Devin Zhang simlegate

🎯
Focusing
  • ChengDu
View GitHub Profile
@simlegate
simlegate / examples
Last active December 3, 2015 18:19
man httping
httping -g URL -C "key=value" -s -c 5

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
@simlegate
simlegate / linux-command
Last active July 16, 2017 10:01
Linux常用命令
# 查看网络端口占用情况
netstat -an | grep 9000
# 通过list open file命令可以查看到当前打开文件,在linux中所有事物都是以文件形式存在,包括网络连接及硬件设备。
lsof -i:9000
# 查看php.ini文件的位置
php --ini
<?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();
@simlegate
simlegate / custom-error-page
Created October 31, 2014 05:35
Nginx return custom json
error_page 400 404 405 =200 @40*_json;
location @40*_json {
default_type application/json;
return 200 '{"code":"1", "message": "Not Found"}';
}
error_page 500 502 503 504 =200 @50*_json;
location @50*_json {
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 / kill.sh
Created December 11, 2015 05:26
the command of killing process
kill $(ps aux | grep '[p]ython csp_build.py' | awk '{print $2}')