Skip to content

Instantly share code, notes, and snippets.

View kohgpat's full-sized avatar
🤖
...

Nikolay Burlov kohgpat

🤖
...
  • Russia, Siberia
View GitHub Profile
@kohgpat
kohgpat / ruby_spreadsheet_example.rb
Created April 2, 2012 11:40
Ruby spreadsheet example
1 require 'spreadsheet'
# Open workbooks
current_workbook = Spreadsheet.open('jan.xls')
total_workbook = Spreadsheet.open('output.xls')
# Process xls
# Iterate through workbook spreadsheets
current_workbook.worksheets.each_with_index do |current_spreadsheet, spreadsheet_index|
@kohgpat
kohgpat / statistics.rb
Created April 19, 2012 17:00
Statistics from xml parcels
# encoding: UTF-8
require 'hpricot'
class Reporter
attr_accessor :path
attr_accessor :documents
def initialize(path)
@path = path
@kohgpat
kohgpat / remove_dups_from_array_by_key.rb
Created April 25, 2012 15:52
Remove dups from array by key
Hash[*a.map{|x| [x.text, x]}].values
a = [Thing.new('a'), Thing.new('b'), Thing.new('c'), Thing.new('c')]
# => [#<Thing a>, #<Thing b>, #<Thing c>, #<Thing c>]
Hash[a.map{|x| [x.text, x]}].values
# => [#<Thing a>, #<Thing b>, #<Thing c>]
class Thing
attr_reader :text
@kohgpat
kohgpat / duplicates.rb
Created April 30, 2012 12:42
Duplicates P023
# encoding: UTF-8
require 'builder'
require 'spreadsheet'
Spreadsheet.client_encoding = 'UTF-8'
class Person
attr_accessor :fam, :im, :ot, :w, :dr
attr_accessor :s_pol, :n_pol, :enp, :dp
@kohgpat
kohgpat / peoplescinema.rb
Created May 18, 2012 11:28
Peoples Cinema - Movies and Shows
# encoding: UTF-8
require 'nokogiri'
require 'open-uri'
require 'colorize'
doc = Nokogiri::HTML(open('http://www.peoplescinema.ru/cgi-bin/i10.cgi'))
puts "Peoples Park\n".colorize(:blue)
@kohgpat
kohgpat / peoplescinema.rb
Created May 18, 2012 11:28
Peoples Cinema - Movies and Shows - Today
# encoding: UTF-8
require 'nokogiri'
require 'open-uri'
require 'colorize'
doc = Nokogiri::HTML(open('http://www.peoplescinema.ru/cgi-bin/i10.cgi'))
puts "Peoples Park\n".colorize(:blue)
@kohgpat
kohgpat / fabrikakino.rb
Created May 20, 2012 06:12
Fabrika Kino - Movies and Shows - Today
# encoding: UTF-8
require 'nokogiri'
require 'open-uri'
require 'colorize'
doc = Nokogiri::HTML(open('http://fabrikakino.ru/kino/'))
puts "Fabrika Kino\n".colorize(:yellow)
@kohgpat
kohgpat / parser.rb
Created June 9, 2012 07:38
xml parser
# encoding: UTF-8
# dependencies
require '~/Repo/sax-machine/lib/sax-machine.rb'
require 'pp'
class ZGLV
include SAXMachine
element :VERSION, as: :version
@kohgpat
kohgpat / fines.rb
Created July 3, 2012 08:10
Fines...
require 'nokogiri'
require 'dbf'
require 'ostruct'
class Dictionary
def initialize
@doc = Nokogiri::XML(File.open("dictionaries/F014.xml"))
end
# Utility commands surrounding Hubot uptime.
spawn = require('child_process').spawn
module.exports = (robot) ->
robot.hear /hubot (who|where) are you\??/i, (msg) ->
msg.finish()
child = spawn('/bin/sh', ['-c', "echo I\\'m $LOGNAME@$(hostname):$(pwd) \\($(git rev-parse HEAD)\\)"])
child.stdout.on 'data', (data) ->
msg.send "#{data.toString().trim()} running node #{process.version} [version: #{robot.version}, pid: #{process.pid}, name: #{robot.name} ]"