Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
├── app | |
│ ├── controllers | |
│ │ ├── center | |
│ │ │ ├── filter_controller.js.coffee | |
│ │ │ └── tickets_controller.js.coffee | |
│ │ ├── center_content_controller.coffee | |
│ │ ├── comments_controller.js.coffee | |
│ │ ├── header | |
│ │ │ └── project_nav_controller.js.coffee | |
│ │ ├── header_controller.coffee |
#!/usr/bin/env bash | |
ssh linode 'cd local_clone; cd happynewsdb; \ | |
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot authlove_development>authlove_development.sql; \ | |
git commit -a -m"i"; \ | |
git push;\ | |
cd ../happyecdb/ ; \ | |
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot ec_development>ec_development.sql; \ | |
git commit -a -m"i"; \ | |
git push;\ |
# install and make run basic bootstrap date-picker functionality described here http://www.eyecon.ro/bootstrap-datepicker/ | |
# app/assets/javascript/datepicker.js.coffee | |
$(document).on 'pageChanged', -> | |
# datepicker for simple_form & Ransack | |
$(".custom_datepicker_selector").datepicker().on 'changeDate', (en) -> | |
correct_format = en.date.getFullYear() + '-' + ('0' + (en.date.getMonth() + 1)).slice(-2) + '-' + ('0' + en.date.getDate()).slice(-2) # date format yyyy-mm-dd | |
$(this).parent().find("input[type=hidden]").val(correct_format) |
# | |
# Given your birthday and the current date, calculate your age in days. | |
# Account for leap days. | |
# | |
# Assume that the birthday and current date are correct dates (and no | |
# time travel). | |
# | |
daysOfMonths = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
def leapYear(year): |
######################################################################### | |
# 10-row School abacus | |
# by | |
# Michael H | |
######################################################################### | |
# Description partially extracted from from wikipedia | |
# | |
# Around the world, abaci have been used in pre-schools and elementary | |
# | |
# In Western countries, a bead frame similar to the Russian abacus but |
# | |
# This question explores a different way (from the previous question) | |
# to limit the pages that it can crawl. | |
# | |
####### | |
# THREE GOLD STARS # | |
# Yes, we really mean it! This is really tough (but doable) unless | |
# you have some previous experience before this course. |
# A list is symmetric if the first row is the same as the first column, | |
# the second row is the same as the second column and so on. Write a | |
# procedure, symmetric, which takes a list as input, and returns the | |
# boolean True if the list is symmetric and False if it is not. | |
# | |
def symmetric(s): | |
# Your code here | |
i= 0 | |
length = len(s) |
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://npmjs.org/install.sh | sh |
树莓派是基于arm内核的小电脑,性能较低,默认cpu频率为700Mhz,所以很多工作并不适合在它上面完成,比如编译软件。所以在它上面的软件需要交叉编译工具来完成。全球范围内,需要交叉编译的芯片非常多,估计超过几万种,每种芯片的编译工具又不仅相同,所以今天我来介绍交叉编译工具的编译工具(是的,很嗷口):crosstool-ng(http://crosstool-ng.org/)。它是为创建交叉编译工具而生。可以为树莓派生成可用的交叉编译工具。当然你可以去raspberry pi 官方提供的工具(http://github.com/raspberrypi/tools.git)。
到ct-ng官网(http://crosstool-ng.org/),下载源码到相应目录。
tar -xjvf crosstool-ng-1.18.0.tar.bz2
版本可能不同,请注意