Skip to content

Instantly share code, notes, and snippets.

View paul-ihnatolia's full-sized avatar

Paul paul-ihnatolia

  • Uzhgorod, Ukraine
View GitHub Profile
@paul-ihnatolia
paul-ihnatolia / custom_timestamps.rb
Created April 23, 2015 13:19
Custom timestamps in rails
# As an option can be placed
# in models/concerns
module CustomTimestamps
extend ActiveSupport::Concern
included do
class_attribute :custom_updated_at, :custom_created_at
before_save :update_custom_updated_at
before_create :set_custom_created_at
end
@paul-ihnatolia
paul-ihnatolia / custom_timestamps.rb
Created April 23, 2015 13:13
Custom timestamps in rails
module CustomTimestamps
extend ActiveSupport::Concern
included do
class_attribute :custom_updated_at, :custom_created_at
before_save :update_custom_updated_at
before_create :set_custom_created_at
end
def update_custom_updated_at
@paul-ihnatolia
paul-ihnatolia / visualizator.rb
Last active December 30, 2015 12:09
Ruby OpenCV
require "opencv"
include OpenCV
WINDOW_NAME = "Difference visualization"
# read videostream from camera
camera = OpenCV::CvCapture.open(0)
# open simple window wedget
# can show (CvMat/IplImage)
window = OpenCV::GUI::Window.new(WINDOW_NAME)
@paul-ihnatolia
paul-ihnatolia / parser.rb
Created November 9, 2012 18:15
Nokogiri parser
require 'nokogiri'
require 'open-uri'
base_url = "http://cms.indygov.org/MyAssessedValue/Result.aspx?Parcel="
neccessary_ids = ["#ctl00_header_txtParcel", "#ctl00_header_txtPropertyLocation", "#ctl00_header_txtTotalAssessed2011"]
input_file_name = '2008 Unsold Tax Sale Properties as of 08-24-2010.txt'
output_file_name = input_file_name.split('.')[0] + "_detail"
if File.exist?(input_file_name)
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Author: seniorihor (12.03.2012)
class MyArray
def initialize(arr)
@array = arr.clone()
@max_positive = 0
@max_minimum = 0
end
@paul-ihnatolia
paul-ihnatolia / general.rb
Created March 11, 2012 22:43 — forked from seniorihor/general.rb
Рішення задачі "Приїзд генерала" з http://codeforces.ru/contest/144/problem/A
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Aurhor: seniorihor and vertoldo (12.03.2012)
class General
def initialize(quantity, numbers)
@quantity = quantity
@numbers = numbers
@posMensh=0
@posBilsh=0
kilkist = gets.chomp.to_i
soldatu=gets.chomp.split(" ").map! {|el| el=el.to_i}
posMensh=soldatu.index[soldatu.min]
posBilsh=soldatu.index[soldatu.max]
sec=0
@paul-ihnatolia
paul-ihnatolia / Driver.java
Created March 10, 2012 13:57
Driver for Stack
package org.uzhnu.homework.stack;
public class Driver {
/**
* @param args
*/
public static void main(String[] args) {
// init empty stack
Stack st = new Stack();
@paul-ihnatolia
paul-ihnatolia / Stack.java
Created March 10, 2012 13:54
Stack for labwork
package org.uzhnu.homework.stack;
public class Stack {
private String [] strArray; //new arr
private int currEl; //pointer to Stack top
private static int defaultSize=10;
Stack(){
this.strArray = new String[defaultSize];
mojeePole = [#a b c d e f g h i k
[0, 0, 0, 0, 0, 0, 0, 0, 0 ,0],#1
[0, 0, 0, 1, 0, 0, 0, 0, 0 ,0],#2
[0, 0, 0, 1, 0, 0, 0, 0, 0 ,0],#3
[0, 0, 0, 1, 0, 0, 0, 0, 0 ,0],#4
[0, 0, 0, 0, 0, 0, 0, 0, 0 ,0],#5
[0, 0, 0, 0, 0, 0, 0, 0, 0 ,0],#6
[0, 0, 0, 0, 0, 0, 0, 0, 0 ,0],#7
[0, 0, 0, 0, 0, 0, 0, 0, 0 ,0],#8
[0, 0, 0, 0, 0, 0, 0, 0, 0 ,0],#9