Skip to content

Instantly share code, notes, and snippets.

View miry's full-sized avatar

Michael Nikitochkin miry

View GitHub Profile
@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
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
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)
@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)
@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 / Rakefile
Last active December 21, 2015 20:00
Rubymotion: A nice trick to find a right profile instead to put a full path to the file
Motion::Project::App.setup do |app|
# Find Provising profile depends on Profile name
# https://github.com/HipByte/RubyMotion/blob/master/lib/motion/project/template/ios/config.rb#L88
app.provisioning_profile('IOS Wildcard Team Profile')
#or use same as app name
app.provisioning_profile(app.name)
# ...
end
@miry
miry / Rakefile
Created August 27, 2013 11:05
Rubymotion tricks to generate the build version.
Motion::Project::App.setup do |app|
#Simple example to generate a pretty build version
app.version = `git log -n 1 --pretty=format:'%h'`.upcase
app.short_version = '1.0'
#...
end
@miry
miry / info_kill.sh
Last active December 20, 2015 12:28
#!/bin/bash
function info_kill() {
local frame=0
while caller $frame; do
((frame++));
done
echo "kill $*"
gem: --no-rdoc --no-ri
@miry
miry / .zshrc
Last active October 21, 2018 09:47
My zsh config
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="aussiegeek"
# Example aliases