Skip to content

Instantly share code, notes, and snippets.

View arion's full-sized avatar

Abushaev Denis arion

View GitHub Profile
@arion
arion / gist:1250251
Created September 29, 2011 08:06 — forked from SkyWriter/gist:1250250
My aliases
alias b='bundle'
alias be='b exec'
alias ber='b exec rake'
alias beu='b exec uniqfrd'
alias bi='b install --path vendor'
alias bil='bi --local'
alias binit='bi && b package && echo '\''vendor/ruby'\'' >> .gitignore'
alias bu='b update'
alias create-repo='touch .gitignore && git add .gitignore && git commit -m '\''Created repo'\'' && git checkout -b develop'
alias g='git'
@arion
arion / .bashrc
Created March 7, 2012 04:57
Show rvm gemset ans git branch in your command prompt
function detect_git_branch {
local git_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/")
[ "$git_branch" != "" ] && echo " ($git_branch) "
}
function detect_rvm_name {
local gemset=$(echo $GEM_HOME | awk -F'/' '{print $NF}')
[ "$gemset" != "" ] && echo "($gemset)"
}
@arion
arion / test_client_spec.rb
Created March 30, 2012 07:11
spec seconds_left bug
it "should calculate with real tarif" do
time = Time.local(2011, 5, 6, 13, 00, 0)
Timecop.freeze(time) do
real_tarif_settings = YAML.load(File.read(File.join(RACK_ROOT, 'spec', 'support', 'unit_tarif.yml')))
real_calc_module = CalculationModule.create!(:slug => 'real_tariff', :settings => real_tarif_settings)
real_tarif = Tarif.create!(:name => 'real_tariff', :starts_at => 1.year.ago)
CalculationRule.make!(:calculation_module => real_calc_module, :service => Service.find(ServerConfig.service_autorun_id), :tarif => real_tarif)
computer = Computer.make!(:computer_class => ComputerClass.find('b12d1111-50c0-11e1-95f6-0023df7d4b7e'))
# свой сервис
@arion
arion / test_client_spec.rb
Created March 30, 2012 08:03
second spec for seconds_left
it "should calculate with real tarif" do
time = Time.local(2011, 5, 6, 13, 00, 0)
Timecop.freeze(time)
real_tarif_settings = YAML.load(File.read(File.join(RACK_ROOT, 'spec', 'support', 'unit_tarif.yml')))
real_calc_module = CalculationModule.create!(:slug => 'real_tariff', :settings => real_tarif_settings)
real_tarif = Tarif.create!(:name => 'real_tariff', :starts_at => 1.year.ago)
CalculationRule.make!(:calculation_module => real_calc_module, :service => Service.find(ServerConfig.service_autorun_id), :tarif => real_tarif)
computer = Computer.make!(:computer_class => ComputerClass.find('b12d1111-50c0-11e1-95f6-0023df7d4b7e'))
@arion
arion / git.plugin.zsh
Created April 10, 2012 07:41
zsh full git commit command
full_git_commit()
{
git add . && git commit -a -m "$1" && git push
}
alias fgc=full_git_commit
# use `fgc 'my commit message'`
@arion
arion / hardsub.rb
Created April 15, 2012 18:28
hardsub two subtitle file in one avi
#!/usr/bin/env ruby
require "rubygems"
require "pry"
$DEBUG = false
def hardsub(source_file, sub_file, sub_encoding, position, result_file)
command = %Q{ mencoder -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2000 #{source_file} \
-subwidth 75 -subcp #{sub_encoding} -subfont-text-scale 3 -sub #{sub_file} \
@arion
arion / gist:3214307
Created July 31, 2012 06:44
fatal cap log section
bundle exec cap production deploy -s domain='xxx@xxx' -s branch='develop' -s rvm_bin_path='/home/cpc-system/.rvm/bin' -s deploy_to='/home/cpc-system/apps/tarif-edit' -s rvm_path='/home/cpc-system/.rvm' -s repository='ssh://git@red/omg-tarif-edit.git' -s deploy_via=copy -s git_shallow_clone=1
* executing `production'
triggering start callbacks for `deploy'
* executing `multistage:ensure'
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote ssh://git@red/omg-tarif-edit.git develop"
command finished in 11884ms
@arion
arion / importfm.rb
Created August 20, 2012 12:46
scrobble all you local files to last.fm
# -*- encoding : utf-8 -*-
require "mp3info"
require "rockstar"
require "pry"
IMPORT_DIR = '/Users/arion/Music'
Rockstar.lastfm = YAML.load_file('lastfm.yml')
a = Rockstar::Auth.new
token = a.token
@arion
arion / imo_im_userscript.js
Created March 26, 2013 06:03
IMO.IM userscript for fluid
window.fluid.dockBadge = 0;
setTimeout(updateDockBadge, 500);
setInterval(updateDockBadge, 1000);
function updateDockBadge() {
var elements = document.querySelectorAll(".attention-bubble>span");
var element;
var sumNotice = 0;
@arion
arion / inherited_properties.rb
Last active December 25, 2015 13:59
created by http://mediumexposure.com/multiple-table-inheritance-active-record/ with some modifications For use add to your model: include InheritedProperties inherits_properties_from 'SomePropertiesClass'
module InheritedProperties
extend ActiveSupport::Concern
included do
end
def properties_with_autobuild
properties_without_autobuild || build_properties
end