Skip to content

Instantly share code, notes, and snippets.

@reu
reu / assets.rb
Created February 19, 2012 11:19
Overriding capistrano assets:precompile task to precompile only when there are changes in any of the assets.
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
if capture("cd #{latest_release} && #{source.local.log(source.next_revision(current_revision))} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
else
logger.info "No changes on assets. Skipping pre-compilation."
end
end
end
@pwc3
pwc3 / SkypeMenuUpdater.rb
Created May 18, 2012 23:42
Shows the number of unread Skype conversations in the menu bar
#!/usr/bin/env ruby
FSCRIPT_PATH = "/Library/Frameworks/FScript.framework"
GDB = IO.popen("gdb", "w")
def gdb(cmd)
GDB.puts cmd
GDB.flush
end
@pifleo
pifleo / cmd
Created October 14, 2012 20:59
Proxy List Fetcher Using Ruby
$ chmod +x ./proxy_list_fetcher.rb
$ ./proxy_list_fetcher.rb | head
180.94.88.58 8080 Afghanistan fast HTTPS High +KA
187.87.155.2 8080 Brazil fast HTTPS High +KA
120.132.132.119 8080 China medium HTTPS High +KA
210.211.109.244 8081 Viet Nam fast HTTP Low
216.244.71.143 3128 United States medium HTTPS High +KA
190.237.224.22 8080 Peru slow HTTPS High +KA
@rubiojr
rubiojr / mr_status_bar_app.rb
Created November 30, 2009 11:47
MacRuby StatusBar Application
#
# Initialize the stuff
#
# We build the status bar item menu
def setupMenu
menu = NSMenu.new
menu.initWithTitle 'FooApp'
mi = NSMenuItem.new
mi.title = 'Hellow from MacRuby!'
mi.action = 'sayHello:'
@xiaods
xiaods / chinesedecimal.rb
Created February 27, 2010 15:51
convert RMB currency to chinese describe
$KCODE = 'u'
# Goal: 小写金额转换为大写金额
# Limit: 金额整数位支持到亿位,小数点后支持两位并且不支持四舍五入
class ChineseFee
attr_reader :chn_numbers, :chn_units, :chn_decimals
def initialize
@chn_numbers = %w(零 壹 贰 叁 肆 伍 陆 柒 捌 玖)
@chn_units = %w(元 拾 佰 仟 万 拾万 佰万 仟万 亿)
@tehprofessor
tehprofessor / watir_phantomjs_user_agent_settings.rb
Created May 1, 2013 18:28
Configuring Watir to use a custom user agent with the PhantomJS driver. The user agent gem has been deprecated, and this functionality is not documented anywhere (obvious).
require 'watir-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs("phantomjs.page.settings.userAgent" => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
driver = Selenium::WebDriver.for :phantomjs, :desired_capabilities => capabilities
browser = ::Watir::Browser.new driver
# Quick test to make sure it's set
browser.goto 'http://www.useragentstring.com/'
browser.textarea(:id => "uas_textfeld").value
@netwjx
netwjx / autoproxy.md
Last active December 9, 2017 12:29
autoproxy rules

AutoProxy 代理规则

  • 查看
  • 修订版本

Posted in

  • AutoProxy
  • gfwList
  • Rule
@brundage
brundage / database.yml
Created November 16, 2012 22:05
Use sqlite in-memory database for rspec testing
test:
adapter: sqlite3
encoding: utf8
pool: 5
timeout: 5000
database: ":memory:"
verbosity: quiet
@bruth
bruth / README.md
Created April 27, 2012 00:51
sortedGroupBy using Underscore

sortedGroupBy

jsFiddle Example

Convenience function for performing a groupBy on a list then a sortBy on the resulting groups using Underscore methods.

sortedGroupBy(list, groupByIterator, sortByIterator)
@mariotaku
mariotaku / .travis.yml
Last active August 8, 2018 13:10
Sign and upload compiled apk to Github releases automatically using Travis CI
language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-22.0.0