Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
set background=dark | |
colors solarized | |
let g:airline_theme='solarized' | |
let g:airline_powerline_fonts = 1 | |
let g:airline_left_sep = '' | |
let g:airline_left_alt_sep = '' | |
let g:airline_right_sep = '' | |
let g:airline_right_alt_sep = '' | |
let g:airline_symbols.branch = '' |
" encoding | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
" preference | |
syntax on | |
set ai | |
set shiftwidth=2 | |
set tabstop=2 | |
set softtabstop=2 |
#!/bin/sh | |
echo 'Delete all local snapshots expect last one.' | |
for date in $(tmutil listlocalsnapshots / | cut -d. -f4 | sed '$d') | |
do | |
tmutil deletelocalsnapshots $date | |
done | |
echo 'Thinlocalsnapshots' | |
tmutil thinlocalsnapshots / |
#!/bin/sh | |
GetCPUTemp() { | |
value=`cat /sys/class/thermal/thermal_zone0/temp | tr -d '\n'` | |
cpu_temp=`awk "BEGIN {print $value/1000.0}"` | |
echo "$cpu_temp" | |
} | |
GetGPUTemp() { | |
gpu_temp=`vcgencmd measure_temp |sed -e "s/temp=//g" | sed -e "s/'C//g"` |
# https://github.com/gpakosz/.tmux | |
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license, | |
# without any warranty. | |
# Copyright 2012— Gregory Pakosz (@gpakosz). | |
# -- navigation ---------------------------------------------------------------- | |
# if you're running tmux within iTerm2 | |
# - and tmux is 1.9 or 1.9a |
// 1. open DownloadMaster in chrome | |
// 2. use the code in chrome console | |
urls = ["", ""] //urls array | |
addDownload = function(url) { | |
showPanel(); | |
document.getElementById("HTTP_usb_dm_url").value = url; | |
dm_add_status(); | |
} |
// from http://stackoverflow.com/questions/2436966/how-would-you-compare-jquery-objects | |
// You need to compare the raw DOM elements, e.g.: | |
if ($(this).parent().get(0) === $('body').get(0)) | |
// or | |
if ($(this).parent()[0] === $('body')[0]) |
validates :domain, uniqueness: { unless: Proc.new { |shop| shop.domain == '' or shop.domain == nil } } |
# This is an example of how to use database_cleaner gem and | |
# RSpec tags to make `after_commit` hook play nice with | |
# `use_transactional_fixtures`. | |
# Simply mark the specs that use after_commit with | |
# `:uses_after_commit` tag. | |
# ... | |
require 'database_cleaner' |