This file contains hidden or 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
| module Resque | |
| def push_with_meta(queue, item) | |
| if item.respond_to?(:[]=) | |
| item[:meta] = {:queued_at => Time.now.to_f} | |
| end | |
| push_without_meta(queue, item) | |
| end | |
| class Job | |
| # Returns a Hash of the meta data related to this Job. |
This file contains hidden or 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 'statsd' | |
| $statsd = Statsd.new('your_host_here') | |
| ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args| | |
| event = ActiveSupport::Notifications::Event.new(*args) | |
| controller = event.payload[:controller] | |
| action = event.payload[:action] | |
| format = event.payload[:format] || "all" | |
| format = "all" if format == "*/*" | |
| status = event.payload[:status] |
This file contains hidden or 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
| description "Fluentd" | |
| start on runlevel [2345] | |
| stop on runlevel [016] | |
| respawn | |
| respawn limit 5 60 | |
| exec sudo -u fluentd /opt/fluentd/usr/bin/fluentd -c /opt/fluentd/etc/fluent.conf --log /opt/fluentd/var/log/fluentd.log |
This file contains hidden or 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
| # textutil -convert html file.doc -stdout | pandoc -f html -t markdown -o file.md | |
| see also: https://gist.github.com/2380036 | |
This file contains hidden or 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
| vagrant@lucid32:~$ locale | |
| locale: Cannot set LC_CTYPE to default locale: No such file or directory | |
| locale: Cannot set LC_ALL to default locale: No such file or directory | |
| LANG=en_US | |
| LC_CTYPE=UTF-8 | |
| LC_NUMERIC="en_US" | |
| LC_TIME="en_US" | |
| LC_COLLATE="en_US" | |
| LC_MONETARY="en_US" | |
| LC_MESSAGES="en_US" |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| # Temporarily add this dir to your path | |
| # export PATH=~/gists/bundle_benchmark:$PATH | |
| # cd to any of your project and run the benchmark | |
| # cd ~/my-project | |
| # benchmark.rb | |
| require 'benchmark' | |
| require 'bundler' |
This file contains hidden or 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
| class Hash | |
| # options: | |
| # :exclude => [keys] - keys need to be symbols | |
| def to_ostruct_recursive(options = {}) | |
| convert_to_ostruct_recursive(self, options) | |
| end | |
| private | |
| def convert_to_ostruct_recursive(obj, options) | |
| result = obj |
This file contains hidden or 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
| # -*- encoding: utf-8 -*- | |
| Gem::Specification.new do |s| | |
| s.name = 'parallel_assets_compiler' | |
| s.version = '0.2.0' | |
| s.platform = Gem::Platform::RUBY | |
| s.author = 'Jørgen Orehøj Erichsen' | |
| s.email = '[email protected]' | |
| s.summary = 'Compile assets in parallel' | |
| s.description = 'Compile assets in parallel to speed up deployment' |
This file contains hidden or 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
| # config/initializers/redcarpet.rb | |
| module ActionView | |
| module Template::Handlers | |
| class Markdown | |
| class_attribute :default_format | |
| self.default_format = Mime::HTML | |
| def call(template) | |
| markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true) | |
| markdown.render(template.source).html_safe.inspect |
This file contains hidden or 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
| # Disclaimer: this solution has been taken from the post: http://stackoverflow.com/a/5071198/784270 | |
| # navigate to the bundler gem and in lib/bundler/runtime.rb, | |
| # find the line that does Kernel.require and wrap it like this | |
| puts Benchmark.measure("require #{file}") { | |
| Kernel.require file | |
| }.format("%n: %t %r") | |
| # Add |