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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE template SYSTEM "../../../project-config.dtd"> | |
| <template> | |
| <name>Rails</name> | |
| <settings> | |
| <options> | |
| <option name="executionTimeoutMin" value="20" /> | |
| </options> | |
| <parameters> |
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
| def validate(count) | |
| result = nil | |
| count.downto(0).each do |j| | |
| i = count - j | |
| if j == count && j % 3 == 0 | |
| result = Array.new(j, 5) | |
| elsif i % 5 == 0 && j % 3 == 0 | |
| result = Array.new(j, 5) + Array.new(i, 3) | |
| elsif i == count && i % 5 == 0 | |
| result = Array.new(i, 3) |
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 'benchmark' | |
| Benchmark.bm do |x| | |
| x.report { n.times { nil.to_s } } | |
| x.report { n.times { "#{nil}" } } | |
| end | |
| # user system total real | |
| # 0.020000 0.000000 0.020000 ( 0.027392) | |
| # 0.040000 0.000000 0.040000 ( 0.041352) |
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
| namespace :deploy do | |
| namespace :check do | |
| task :linked_files => 'config/database.yml' | |
| end | |
| end | |
| remote_file 'config/database.yml' => '/tmp/database.yml', roles: :app | |
| file '/tmp/database.yml' do |t| | |
| default_template = <<-EOF |
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
| namespace :rails do | |
| desc 'Execute rails console' | |
| task :console do | |
| on roles(:app) do | |
| within release_path do | |
| with rails_env: fetch(:rails_env) do | |
| _execute_interactive(:bundle, :exec, :rails, :console) | |
| end | |
| end | |
| 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
| /ip dns static add address=127.0.0.1 ttl=600w name=".*\\.vk\\.com" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="rs.mailer.ru" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="googleads.g.doubleclick.net" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="pagead2.googlesyndication.com" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="www.googletagservices.com" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="a.pr.dotua.org" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="google-analytics.com" | |
| /ip dns static add address=127.0.0.1 ttl=600w name=".*\\.google-analytics\\.com" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="mc.yandex.ru" | |
| /ip dns static add address=127.0.0.1 ttl=600w name="share.yandex.ru" |
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
| # Codingame: http://www.codingame.com/ide/?target=clogin&s=1&id=227787048586488d4709f87be22b41eab2321d#!test:247723:true:%2523!list | |
| n = STDIN.gets.to_i | |
| if n == 0 | |
| puts 0 | |
| exit | |
| end | |
| values = STDIN.gets.split(' ').map(&:to_i) | |
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
| ssh example.com "cd /data/apps/example/current && ( RAILS_ENV=production RBENV_ROOT=/data/rbenv RBENV_VERSION=2.0.0-p247 /data/rbenv/bin/rbenv exec bundle exec rails console)" |
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
| { | |
| "name": "application", | |
| "description": "Sets up rails project", | |
| "default_attributes": { | |
| "rails-stack": { | |
| "deployer": "deployer", | |
| "authorized_keys": [ | |
| "PUBLIC_KEY_FOR_APP_DEPLOYER_USER1", | |
| "PUBLIC_KEY_FOR_APP_DEPLOYER_USER2" |
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
| # Usage: | |
| # - Download the jquery plugin from https://github.com/openexchangerates/accounting.js | |
| # - Save the min file in the `vendor/assets/javascripts/ folder | |
| # - Add this file to `app/assets/priceFormatter.js.coffee` | |
| # - Add to `app/assets/application.js.coffee`: | |
| # `#= require accounting.js` | |
| # `#= require priceFormatter.js` | |
| class PriceFormatter | |
| constructor: ($scope) -> |