Skip to content

Instantly share code, notes, and snippets.

//豆瓣:只显示楼主
javascript:void(function(){$(".topic-reply li").each(function(){ if($(this).find(".user-face a").attr('href')!=$(".user-face:first").find('a').attr('href')){$(this).toggle() } });})();
// 豆瓣:高亮楼主
javascript:void(function(){$(".topic-reply li").each(function(){ if($(this).find(".user-face a").attr('href')==$(".user-face:first").find('a').attr('href')) {$(this).css('border', "1px solid")}});})();
// Fixed for prototype extend issue
function hackjQuery(jQuery){
if(jQuery.fn.jquery == '1.3.2'){
jQuery.event.handle = function(event) {
// returned undefined or false
var all, handlers;
event = arguments[0] = jQuery.event.fix( event || window.event );
event.currentTarget = this;
RewriteRule ^/jobs/([^-^/]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)-(.*) /house/$8/trade=$1&category=$2&subclass=$3&district=$4&education=$5&education=$6&experience=$7 [C,NC]
RewriteRule ^/jobs/([^-^/]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)/(.*) jobs-list.php?$6&wage=$1&nature=$2&searchtype=$3&key=$4&page=$5 [QSA,L,NC]
@rainchen
rainchen / methodfinder_what.rb
Created September 17, 2012 08:03 — forked from wtaysom/methodfinder_what.rb
_why's Ruby MethodFinder addition tweaked and revised.
require 'methodfinder'
# _why's MethodFinder addition tweaked and revised.
# <http://redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html>
class MethodFinder
def self.with_redirected_streams
redirect_streams
yield
ensure
@rainchen
rainchen / formtastic_localizer_patch.rb
Created September 25, 2012 04:11
this patch allowed to use a proc to :label option, then we can pass a proc to ActiveAdmin `filter` method
# ActiveAdmin use Formtastic as the "filter" field builder
# this patch allowed to use a proc to :label option, then we can pass a proc to `filter` method
# e.g.: filter :foo, :label => proc { I18n.tr('activerecord.attributes.foo.bar') }
module Formtastic
class Localizer
def localize_with_proc_value(key, value, type, options = {})
if value.is_a?(::Proc)
value.call(key)
else
localize_without_proc_value(key, value, type, options = {})
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>

Capybara

save_and_open_page

Matchers

have_button(locator)
@rainchen
rainchen / photo.rb
Created June 5, 2013 04:43
Clever enums in rails using module style
class Photo < ActiveRecord::Base
module Statues
QUEUED = 'queued'
NEW = 'new'
def self.values
constants.map(&method(:const_get))
end
# you can define more special methods as you wanted for Statues
end
@rainchen
rainchen / deploy.rb
Last active December 18, 2015 16:29
private_pub capistrano tasks
namespace :private_pub do
desc "Start private_pub server"
task :start do
run "cd #{current_path};RAILS_ENV=#{rails_env} bundle exec rackup private_pub.ru -s thin -E #{rails_env} -D -P tmp/pids/private_pub.pid"
end
desc "Stop private_pub server"
task :stop do
run "cd #{current_path};if [ -f tmp/pids/private_pub.pid ] && [ -e /proc/$(cat tmp/pids/private_pub.pid) ]; then kill -9 `cat tmp/pids/private_pub.pid`; fi"
end