Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
Hi David, | |
I came across your profile online and wanted to reach out about Development | |
Opportunities here at Groupon. The company is growing, and we're always | |
looking for folks with solid skills that can make positive contribution to | |
our continued success. Any chance you'd be open to a quick conversation | |
about opportunities, or for any possible networking potential? If so, let me | |
know when you're free and we can set up a time to chat. Also, if you are | |
interested, it would be great if you could forward a current resume over | |
that I can take a look at. I look forward to hearing back from you! Please | |
let me know if you have any questions. |
Install Java JDK 6.0 update 31 on Ubuntu 12.04 LTS | |
Introduction | |
The first question is why are we installing an old JDK. The answer is that Oracle JDK 6.0 update 31 is the JDK recommended by Cloudera when installing CDH4 (Cloudera Distribution Hadoop v4). | |
This is an update to an older version of this post. Mainly I have changed the JDK from 1.6.0_26 to 1.6.0_31 as this is the recommended JDK for CDH4 . | |
Install Java | |
I have a 64 bit version of Ubuntu 12.04 LTS installed, so the instructions below only apply to this OS. |
module Jekyll | |
module Generators | |
class Pagination | |
# Monkey patch this method to exclude some cats and tags from all standard | |
# paginators | |
# | |
# For this to take effect, you have to define a ``exclude_home`` property in your _config.yml: | |
# | |
# exclude_home: | |
# categories: [notes] |
#!/usr/bin/env ruby | |
require 'rack' | |
# Thin SSL workaround | |
module Rack | |
module Handler | |
class Thin | |
def self.run(app, options={}) | |
app = Rack::Chunked.new(Rack::ContentLength.new(app)) | |
server = ::Thin::Server.new(options[:Host] || '0.0.0.0', |
xstat() { | |
for target in "${@}"; do | |
inode=$(ls -di "${target}" | cut -d ' ' -f 1) | |
fs=$(df "${target}" | tail -1 | awk '{print $1}') | |
crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | | |
grep -oP 'crtime.*--\s*\K.*') | |
printf "%s\t%s\n" "${crtime}" "${target}" | |
done | |
} |
# 支付宝分享到微信的红包识别 | |
# 依赖:tesseract, gems(mini_magick, rtesseract) | |
# 使用: ruby alipay_red_packet.rb xxx.jpg | |
# xxx.jpg 就是支付宝红包图片 | |
require 'mini_magick' | |
require 'rtesseract' | |
img = MiniMagick::Image.new(ARGV[0]) | |
img.crop("#{1080-220}x#{1600-1360}+220+1360") |
First install all these prerequisites for compiling:
sudo apt install g++ autoconf libfontconfig1-dev pkg-config libjpeg-dev libopenjpeg-dev gnome-common libglib2.0-dev gtk-doc-tools libyelp-dev yelp-tools gobject-introspection libsecret-1-dev libnautilus-extension-dev
First download the encoding files (no need to compile these) to the current working directory
wget https://poppler.freedesktop.org/poppler-data-0.4.7.tar.gz