Skip to content

Instantly share code, notes, and snippets.

View liwh's full-sized avatar
🎯
Focusing

robie lee liwh

🎯
Focusing
View GitHub Profile
// remove crappy contents from news.google.de
$("div.source, span.source").filter(function() { return /(BILD|WELT ONLINE)/.test( $(this).text() ) }).parent().fadeOut();
$("h2.title > a").filter(function() { return /.*(welt.de|bild.de).*/.test( $(this).attr('href') ) } ).parents("div.story").fadeOut();
~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
@liwh
liwh / _notes.md
Created March 1, 2011 12:26 — forked from mislav/_notes.md

This gist is outdated

Homebrew people have since included this in a recipe.

$ brew update
$ brew install mongodb

( follow the instructions given )

⌘T – Go to File
⇧⌘T – Go to Symbol – This works in the same way as Go to File but for within a specific file.
⌘L – Go to Line
⇧⌘L – Select Line
⌃⌘ + ARROW – Move Code
⇧⌃⌥V – Send selected to Pastie – Send the selected code over to Pastie with a private URL for sharing the code.
⌃S – Simple Search – Most folks know about ⌘F as it’s the same in most applications. This shortcut allows you to do a quick search in the current file iteratively.
⌘] and ⌘[ – Block indentation.
⌥⌘[ - Format Selection.
⇧⌃T – To-do list – This feature scans the project for code marked as ‘FIXME’, ‘TODO’ and ‘CHANGED’.
@liwh
liwh / rails_3_1_beta_1_changes.md
Created May 6, 2011 05:27 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

@liwh
liwh / gh-like.css
Created October 25, 2011 08:28 — forked from robsimmons/gh-like.css
GitHub-esque syntax highlight CSS
/*
Some simple Github-like styles, with syntax highlighting CSS via Pygments.
*/
body{
font-family: helvetica, arial, freesans, clean, sans-serif;
color: #333;
background-color: #fff;
border: none;
line-height: 1.5;
margin: 2em 3em;
@liwh
liwh / sequel + fiveruns-memcache-client
Created April 20, 2012 08:21 — forked from EppO/sequel + fiveruns-memcache-client
trying to cache sequel models in memcached
$ sequel postgres://mylogin:mypasswd@localhost/bddtest
Your database is stored in DB...
>> require 'memcache'
=> true
>> MemCache
=> MemCache
>> MemCache::VERSION
=> "1.5.0.1"
>> CACHE = MemCache.new("localhost")
=> MemCache: 1 servers, 1 buckets, ns: nil, ro: false
@liwh
liwh / gist:2858648
Created June 2, 2012 14:32 — forked from snatchev/gist:1316470
resque worker devise not eager loading
❷ > QUEUE=* rake resque:work --trace
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Invoke resque:setup (first_time)
** Execute resque:setup
** Execute resque:preload
rake aborted!
No such file to load -- devise/confirmations_controller
/Users/stefan/.rvm/gems/ruby-1.9.2-p290@my-rails-project/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:306:in `rescue in depend_on'
/Users/stefan/.rvm/gems/ruby-1.9.2-p290@my-rails-project/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:301:in `depend_on'

Fibur

Fibur is a library that allows concurrency during Ruby I/O operations without needing to make use of callback systems. Traditionally in Ruby, to achieve concurrency during blocking I/O operations, programmers would make use of Fibers and callbacks. Fibur eliminates the need for wrapping your I/O calls with Fibers and a callback. It allows you to write your blocking I/O calls the way you normally would, and still have concurrent execution during those I/O calls.

Example

Say you have a method that fetches data from a network resource:

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb