This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please don't comment in this gist since I'm not notified by any comments here: | |
# https://github.com/isaacs/github/issues/21 | |
# This is the discussion to comment on: http://blog.arkency.com/2014/07/4-ways-to-early-return-from-a-rails-controller/ | |
class ApplicationController < ActionController::Base | |
# ... | |
around_action :catch_halt | |
def render(*args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' # for Mutex: Ruby doesn't provide out of the box thread-safe arrays | |
class ThreadPool | |
def initialize(max_threads = 10) | |
@pool = SizedQueue.new(max_threads) | |
max_threads.times{ @pool << 1 } | |
@mutex = Mutex.new | |
@running_threads = [] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby client.rb SheetName > output.xls | |
require 'drb/drb' | |
SERVER_URI="druby://localhost:8787" | |
DRb.start_service | |
service = DRbObject.new_with_uri(SERVER_URI) | |
puts service.get_excel_output('sheet_name' => ARGV.first || 'Test') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was created to replace compass in a Rails project. | |
The generator supports multiple themes and the sprite dimensions are available in a dimensions.sass file as variables. | |
There are no other dependencies than Ruby and ImageMagick binaries (or compatible commands with convert and identify). | |
The image name contains an MD5 hash of all images content and is stored directly into public/assets | |
so that the resulting CSS doesn't depend on sprockets. | |
It took about 0.2s to generate two theme sprites for me with about 30 images each. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select username, count(*) over() from user order by username limit 5 offset 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for simple use case - doesn't take into account multiple occurrences | |
parseParams = (search = window.location.search)-> | |
d = (str)-> decodeURIComponent str.replace /\+/g, ' ' | |
query = search.substring 1 | |
regex = /(.*?)=([^\&]*)&?/g | |
params = {} | |
params[d(m[1])] = d(m[2]) while m = regex.exec query | |
params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack_web_console' | |
require 'rack-webconsole' | |
Rack::Webconsole.inject_jquery = true | |
#Rack::Webconsole.key_code = '39' | |
use Rack::Webconsole | |
run ->(env) { | |
return [404, {}, []] unless env['PATH_INFO'] == '/' | |
RackConsole.new(binding).call env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file_cache_path "/root/chef-solo" | |
cookbook_path "/root/chef-solo/cookbooks" | |
json_attribs "/root/chef-solo/node.json" |
NewerOlder