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
| touch tailme | |
| # Tail the same file twice | |
| tailer.rb tailme | |
| echo "smth" |cat >tailme | |
| # results: | |
| Tailing tailme | |
| Tailing tailme |
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
| # | |
| gem install ruby-debug19 -- --with-ruby-include=/home/belbo/.rvm/src/ruby-1.9.2-head/ |
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 Apiv2::MainController < ApplicationController | |
| before_filter :lazy_developer | |
| def lazy_developer | |
| redirect_to params.merge(:host => 'localhost', :port => 3000) if params.key? :devel | |
| redirect_to params.merge(:host => 'skroutz.gr', :port => 80) if params.key? :prod | |
| end | |
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 'action_controller/test_process' | |
| # Paperclip attachments in factories, made easy based on technicalpickles | |
| Factory.class_eval do | |
| def attach(name, path, content_type = nil) | |
| if content_type | |
| add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}", content_type) | |
| else | |
| add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}") | |
| end |
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
| # Bundler-rc deploy recipe | |
| namespace :bundler do | |
| task :create_symlink, :roles => :app do | |
| shared_dir = File.join(shared_path, 'bundle') | |
| release_dir = File.join(current_release, '.bundle') | |
| run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}") | |
| end | |
| desc "Install gem bundle if needed" |
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
| # Exception notifier (rails3) only works as a rack middleware, | |
| # but what if you need notifications inside a rake task or a script? | |
| # This is a quick hack around that. | |
| # | |
| # Wrap your code inside an exception_notify block and you will be notified of exceptions | |
| # | |
| # exception_notify { clear_payments } | |
| def exception_notify | |
| yield | |
| rescue Exception => exception |
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 'redis' | |
| require 'benchmark' | |
| $redis = Redis.new | |
| #$redis.flushall | |
| array_size = Integer(ARGV.first) | |
| a = Array.new(array_size) { rand(1_000_000) } | |
| a = a.uniq |
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
| desc "Commit website to html branch" | |
| task :html do | |
| system <<-GITFOO | |
| test -e 'for_html' && rm -rf for_html | |
| test -e '.git/html.index' && rm .git/html.index | |
| jekyll --no-auto for_html | |
| export GIT_INDEX_FILE=.git/html.index | |
| git add -f for_html | |
| tree_id=$(git write-tree --prefix=for_html/) |
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
| patch_url=https://raw.github.com/gist/1658360/afd06eec533ad0140011bdaf652e6cd82eedf7ec/cumulative_performance.patch | |
| yaml_url=http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz | |
| ruby_url=http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz | |
| build_package_falcon_patch() { | |
| echo 'applying falcon patch' | |
| curl $patch_url | patch -p1 | |
| build_package_standard $1 | |
| } |
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
| # TO_FOLDER=/something | |
| # FROM=/your-es-installation | |
| DATE=`date +%Y-%m-%d_%H-%M` | |
| TO=$TO_FOLDER/$DATE/ | |
| echo "rsync from $FROM to $TO" | |
| # the first times rsync can take a bit long - do not disable flusing | |
| rsync -a $FROM $TO | |
| # now disable flushing and do one manual flushing |