Skip to content

Instantly share code, notes, and snippets.

View miry's full-sized avatar
🇺🇦
🇺🇦 Defending since 2014 → 🇷🇺 still evil 2022 | Putler = Gaga 🤯

Michael Nikitochkin miry

🇺🇦
🇺🇦 Defending since 2014 → 🇷🇺 still evil 2022 | Putler = Gaga 🤯
View GitHub Profile
@miry
miry / RailsTemplate.xml
Created September 11, 2013 16:12
TeamCity template for Rails applications To use it, create a template, and replace the file in `.BuildServer/config/projects/<project_name>/buildTypes/<build_template_id>`
<?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>
@miry
miry / sherlock_beast.rb
Created September 13, 2013 13:07
HackerRank: Sherlock and The Beast
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)
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)
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
@miry
miry / rails.cap
Created October 28, 2013 12:35
Interactive rails console for capistrano 3.
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
/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"
# 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)
@miry
miry / remote_rails_console.sh
Created January 23, 2014 12:20
Run remote Rails console
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)"
{
"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"
@miry
miry / priceFormatter.js.coffee
Last active August 29, 2015 14:04
Example how to use jQuery FormatCurrency plugin Accounting
# 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) ->