As configured in my dotfiles.
start new:
tmux
start new with session name:
| <?php | |
| function transliterate($string) { | |
| $roman = array("Sch","sch",'Yo','Zh','Kh','Ts','Ch','Sh','Yu','ya','yo','zh','kh','ts','ch','sh','yu','ya','A','B','V','G','D','E','Z','I','Y','K','L','M','N','O','P','R','S','T','U','F','','Y','','E','a','b','v','g','d','e','z','i','y','k','l','m','n','o','p','r','s','t','u','f','','y','','e'); | |
| $cyrillic = array("Щ","щ",'Ё','Ж','Х','Ц','Ч','Ш','Ю','я','ё','ж','х','ц','ч','ш','ю','я','А','Б','В','Г','Д','Е','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Ь','Ы','Ъ','Э','а','б','в','г','д','е','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','ь','ы','ъ','э'); | |
| return str_replace($cyrillic, $roman, $string); | |
| } | |
| var_dump(transliterate('андрей шевченко')); # andrey shevchenko | |
| ?> |
| # Cakefile to document, compile, join and minify CoffeeScript files for | |
| # client side apps. Just edit the config object literal. | |
| # | |
| # -jrmoran | |
| fs = require 'fs' | |
| {exec, spawn} = require 'child_process' | |
| # order of files in `inFiles` is important | |
| config = |
| <!-- Open Graph tags for your home page (index). --> | |
| <meta property="og:site_name" content="{Title}" /> | |
| <meta property="fb:app_id" content="FACEBOOK_APPID"/> | |
| <meta property="fb:admins" content="FACEBOOK_USERID" /> | |
| <meta property="og:description" content="{MetaDescription}" /> | |
| <meta property="og:locale" content="en_US" /> | |
| {block:IndexPage} | |
| <meta property="og:image" content="{PortraitURL-128}" /> | |
| <meta property="og:title" content="{Title}" /> |
| #Add this new method | |
| #activeadmin-0.4.0\lib\active_admin\views\pages\show.rb | |
| #after def attributes_table | |
| def attributes_table_for_resource(specified_resource, *args, &block) | |
| panel(I18n.t('active_admin.details', :model => "#{specified_resource.class.name} #{specified_resource.id}")) do | |
| attributes_table_for specified_resource, *args, &block | |
| end | |
| end |
| ActiveAdmin::Dashboards.build do | |
| # Add this section in your dashboard... | |
| section "Background Jobs" do | |
| now = Time.now.getgm | |
| ul do | |
| li do | |
| jobs = Delayed::Job.where('failed_at is not null').count(:id) | |
| link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red' | |
| end |
As configured in my dotfiles.
start new:
tmux
start new with session name:
by Jonathan Rochkind, http://bibwild.wordpress.com
Capistrano automates pushing out a new version of your application to a deployment location.
I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".
| # Resize selenium browser window to avoid Selenium::WebDriver::Error::MoveTargetOutOfBoundsError errors | |
| # | |
| # Example usage with Rspec (in spec/support/spec_helper.rb): | |
| # | |
| # config.before(:each) do | |
| # set_selenium_window_size(1250, 800) if Capybara.current_driver == :selenium | |
| # end | |
| # | |
| def set_selenium_window_size(width, height) | |
| window = Capybara.current_session.current_window.resize_to |
| #!/usr/bin/env ruby | |
| require 'benchmark' | |
| REGEXPS = [ | |
| /^no such file to load -- (.+)$/i, | |
| /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i, | |
| /^Missing API definition file in (.+)$/i, | |
| /^cannot load such file -- (.+)$/i, | |
| ] |
| # Fix for a Rails - Ruby 1.9 bug | |
| # Rails Router, now that it's UTF-8 default, blows up when routing requests | |
| # with invalid chars in the URL; it should properly return a 400 error | |
| # Have to monkey-patch the fix in, since it's not scheduled for release until | |
| # Rails 4.0. | |
| # Adapted Andrew White (pixeltrix)'s fix at | |
| # https://github.com/rails/rails/commit/3fc561a1f71edf1c2bae695cafa03909d24a5ca3, | |
| # but edited to work in 3.0.x. | |
| # 3.1.x, 3.2.x compatibility unknown | |
| require 'action_dispatch/routing/route_set' |