Skip to content

Instantly share code, notes, and snippets.

View pixe1f10w's full-sized avatar

Ilia Zhirov pixe1f10w

  • hexbrains softworks
  • Planet Earth
View GitHub Profile
@pixe1f10w
pixe1f10w / ivr_code.rb
Created April 2, 2013 07:06
Application logic adapted from [https://github.com/pixe1f10w/artificial-stupidity] to use with [https://github.com/pixe1f10w/callcenter]. Showcase of IVR functionality.
# letters in the right order (according to russian phone keyboard)
@letters = { ch: 7, f: 7, k: 4, r: 6, sh: 8, softness_mark: 9, v: 2, z: 3 }
@backup = @letters
@app_path = Dir.pwd
def sound *args
play *args
sleep 0.4
end
@pixe1f10w
pixe1f10w / drop_dupes.sql
Created January 23, 2013 07:45
drop dupes from telephony logs in lanbilling
delete tel28020130112 from tel28020130112 left outer join ( select min(record_id) as record_id, hash from tel28020130112 group by hash ) as keeprows on tel28020130112.record_id = keeprows.record_id where keeprows.record_id is null;
@pixe1f10w
pixe1f10w / configuration_extensions.rb
Created December 5, 2012 09:12
Overriding Rails 3 database configuration depending upon platform
# lib/extenstions/configuration_extentions.rb
module Rails
class Application
class Configuration
def database_configuration
require 'erb'
case RUBY_PLATFORM.downcase
when /darwin/
@pixe1f10w
pixe1f10w / quoted2csv.rb
Created October 12, 2012 06:45
extract quoted substings from file and write them to csv file
#!/usr/bin/env ruby
# encoding: utf-8
def main
o = File.open ARGV[ 1 ], 'w'
File.open ARGV[ 0 ], 'r' do |i|
@pixe1f10w
pixe1f10w / cbrf_curr.rb
Created October 12, 2012 06:17
cbrf currency rates dump
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'rubyful_soup'
@pixe1f10w
pixe1f10w / gist:3863909
Created October 10, 2012 07:57
dump telephony traffic for lanbilling (uses `eval` from https://gist.github.com/3863897)
delimiter //
create procedure `dumpcalls` ( in tbl varchar( 50 ), in agent char( 3 ), in year char( 4 ), in month char( 2 ) )
begin
declare done int default false;
declare query char( 255 );
declare cur cursor for
select
concat( 'insert into ', tbl, ' ( select * from billing.', table_name, ' )' ) as table_name
from
@pixe1f10w
pixe1f10w / mysql_eval.sql
Created October 10, 2012 07:54
mysql eval
delimiter //
create procedure `eval`( in param text )
begin
set @sql = param;
prepare stmt from @sql;
execute stmt;
deallocate prepare stmt;
end //