Skip to content

Instantly share code, notes, and snippets.

View vitaliel's full-sized avatar

Vitalie Lazu vitaliel

  • Moldova, Chisinau
View GitHub Profile
#!/usr/bin/env ruby
# Script to help with rails migrations
cmd = "rake db:migrate"
rev = ARGV[0].to_i
if rev > 0
cmd << " VERSION=#{rev}"
@vitaliel
vitaliel / debug.rb
Created October 25, 2009 22:39 — forked from tmm1/debug.rb
# collect information about a running process
# ruby debug.rb <pid>
begin
raise ArgumentError unless pid = ARGV[0]
pid = pid.to_i
raise ArgumentError unless pid > 0
Process.kill(0,pid)
rescue TypeError, ArgumentError
raise 'pid required'
require 'svn/info'
repo = 'sa_cp33'
rev = 19
path = nil
for i in 1..6
path = "/var/svn#{i}/#{repo}"
if test ?d, path
break
#!/usr/bin/env ruby
# Author: Vitalie Lazu
# Date: Mon, 21 Sep 2009 17:59:50 +0300
#
# Starling status plugin for nagios
require 'rubygems'
# needs memcache-client gem
require "memcache"
require 'optparse'
#!/usr/bin/ruby
# Usage:
# ruby extract_l.rb cc.csv ids.txt > new_cc.csv
lines = IO::readlines(ARGV[0]).map {|x| x.chomp! }
ids = IO::readlines(ARGV[1]).map {|x| x.chomp! }
lines.shift
# Output with command
# git log --format="//%h/%ae/%ai/%s" --name-only --relative="iChart ASP.net/" -- iChart ASP.net/
#
class GitBrowseInfo
def initialize(str)
@str = str
end
def parse
# add chars at beginning, last should be \\
BAD_URL_CHARS = "<>\"'\r\n #:/&;,%.=?\\"
# This id will be used in links
def to_param
if new_record?
"new-milestone"
else
"#{id}-#{title.tr(BAD_URL_CHARS, "-")}"
end
# build server role map
task :test_me, :roles => :web do |t|
srv_roles = {}
for role, values in t.roles
values.map do |s|
srv_roles[s.host] ||= []
srv_roles[s.host] << role
end
end
# replace string in files recursively.
# author: Vitalie Lazu
s = ARGV[0]
r = ARGV[1]
FILES = /\.(rb|erb|rhtml|rake|yml|rjs|rxml)$/
def suggest_bak(file)
bak = "#{file}~"
#
# Helper tasks to build debian packages from git repository
#
# apt-get install git-buildpackage
# Create local branches
# $ rake deb:setup
# create a snapshot
# $ rake snap
branch = "snapshot"