a.k.a. what to do when your ISP starts blocking sites :(
Set the SOCKS proxy to local SSH tunnel
networksetup -setsocksfirewallproxy "Ethernet" localhost 8080
To clear the domain and port
| # Author: Pieter Noordhuis | |
| # Description: Simple demo to showcase Redis PubSub with EventMachine | |
| # | |
| # Update 7 Oct 2010: | |
| # - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
| # the WebSocket protocol implementation in the cramp gem does not work | |
| # well with Chrome's (newer) WebSocket implementation. | |
| # | |
| # Requirements: | |
| # - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
| ## Configure eth0 | |
| # | |
| # vi /etc/sysconfig/network-scripts/ifcfg-eth0 | |
| DEVICE="eth0" | |
| NM_CONTROLLED="yes" | |
| ONBOOT=yes | |
| HWADDR=A4:BA:DB:37:F1:04 | |
| TYPE=Ethernet | |
| BOOTPROTO=static |
| # Ways to execute a shell script in Ruby | |
| # Example Script - Joseph Pecoraro | |
| cmd = "echo 'hi'" # Sample string that can be used | |
| # 1. Kernel#` - commonly called backticks - `cmd` | |
| # This is like many other languages, including bash, PHP, and Perl | |
| # Synchronous (blocking) | |
| # Returns the output of the shell command | |
| # Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
| require 'rubygems' | |
| require 'sinatra' | |
| require 'fileutils' | |
| # upload with: | |
| # curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename | |
| post '/:name/:filename' do | |
| userdir = File.join("files", params[:name]) |
| # | |
| #!optional | |
| #!rest | |
| #( | |
| #\ | |
| #\altmode | |
| #\backnext | |
| #\backspace | |
| #\call | |
| #\linefeed |
| # run using ```rvm jruby-1.6.7 do jruby "-J-Xmx2000m" "--1.9" tej.rb``` | |
| require 'rubygems' | |
| require 'nokogiri' | |
| require 'csv' | |
| f = File.open("/tmp/preview.html") | |
| doc = Nokogiri::HTML(f) | |
| csv = CSV.open("/tmp/output.csv", 'w',{:col_sep => ",", :quote_char => '\'', :force_quotes => true}) |
前陣子一直打算謝謝markdown寫作,拖到現在被這位老兄搶了先,很不錯的介紹文章:[为什么Markdown+R有较大概率成为科技写作主流?](http://www.douban.com/note/220903450/).所以我就不再重複了,此文打算用問答的形式介紹下markdown對於文科寫作的意義[^ft]。
###1. 什麼是markdown?
markdown是一種輕量化的標記語言。大家所熟知的標記語言還有latex,lyx, XML,HTML,這類文本的特點就是你在編輯時可以使用各種tag來控制文本的格式。話說回來,mac下的pages,M$的docx也都時XML文檔,只是你在編輯的時候,不需要加入tag,軟件本身替你增加tag了。
這類語言最大的好處就是在編輯時,你可以很大程度的減少格式對於文本的干擾。你想啊,打開一個word文檔,你調個文字大小,設置個 加粗,二號標題,再來個 斜體 什麼的, 時間大半過去了。而標記語言的最大優勢在於,你只要使用系統能夠識別的tag就可以非常方便地控制這些格式。比如markdown,你可以先使用系統默認的那些tag來寫作,等到最後輸出的時候,配置下css模版即可。
markdown是各種標記語言中的小兄弟,一來是因為它年輕,二來因為它非常輕量化。md是 John Gruber 和 Aaron Swartz 最初發明的,廣泛用於技術文檔的寫作。它的最大優勢在於人機皆可讀 (machine-readble, human-readble)。
| $stack, $draws = [], {} | |
| def method_missing *args | |
| return if args[0][/^to_/] | |
| $stack << args.map { |a| a or $stack.pop } | |
| $draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
| end | |
| class Array | |
| def +@ |
| # Get Sublime to use your rvm ruby... Change your ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build | |
| # (for ST3: ~/Library/Application Support/Sublime Text 3/Packages/User/Ruby.sublime-build) to this, replacing YOURUSERNAME. | |
| # I am still looking to optimize this further... For example, avoiding hardcoding by using something like $HOME, although | |
| # I have yet to get any form of that to work. | |
| { | |
| "working_dir": "${project_path}", | |
| "cmd": [ | |
| "/Users/YOURUSERNAME/.rvm/bin/rvm-auto-ruby", "-Ilib:test", "$file" | |
| ], |