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 / 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 / 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 / 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 / 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 / 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|