This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CronParser | |
COLUMNS = [:mins, :hours, :days, :months, :wdays] | |
RANGES = { :mins => 0..59, :hours => 0..23, :days => 1..31, :months => 1..12, :wdays => 0..6 } | |
class << self | |
# parses given cron tab string and returns next time corresponding to given | |
def find_next_time(time, str) | |
h = parse(str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'matrix' | |
class Matrix | |
alias old_minor minor | |
def minor(*param) | |
if param.size == 2 and param[0].kind_of?(Integer) and param[1].kind_of?(Integer) | |
rows = [] | |
@rows.size.times do |i| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# LaTeX and Dia compilation script 0.2.1 | |
# author: Jakub Kuźma <[email protected]> | |
require 'rake/clean' | |
task :default => [:pdf, :acroread] | |
SRC = FileList['*.tex'] | |
IMG = FileList['*.dia'] | |
BIB = FileList['*.bib'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GameOfLife | |
def initialize(alive = [2, 3], born = [3]) | |
@generation = {} | |
@generations = 0 | |
@alive = alive | |
@born = born | |
end | |
def add_neighbour(pos) | |
if cell = @generation[pos] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Form < Qt::Widget | |
# Define slots of our class. Parenthesis are REQUIRED. | |
slots 'showMessage()' | |
def initialize(parent = nil) | |
# Call the parent class constructor and pass the arguments to | |
# it (equivalent to super(parent) call). | |
super | |
@ui = Ui_Form.new | |
# Create our layout on this window. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'Qt4' | |
require 'ui_form' | |
require 'form' | |
app = Qt::Application.new(ARGV) | |
widget = Form.new | |
widget.show | |
app.exec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# produkt | |
Tuple(id: 1, parent_id: nil, value: nil, name: product) | |
String(id: 2, parent_id: 1, value: "IBM T41", name: name) | |
String(id: 3, parent_id: 1, value: "Great notebook", name: description) | |
Integer(id: 4, parent_id: 1, value: 500, name: price) | |
# kategoria | |
Tuple(id: 5, parent_id: nil, value: nil, name: category) | |
String(id: 6, parent_id: 5, value: "Computers", name: name) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def longest_road(visited_roads = [], skip_roads = []) | |
visited_roads << self | |
# left roads | |
unvisited_left_roads = left_roads - visited_roads - skip_roads | |
left_road_lenghts = unvisited_left_roads.map do |road| | |
lenghts, new_visited_roads = road.longest_road(visited_roads, unvisited_left_roads) | |
visited_roads = (visited_roads + new_visited_roads).uniq | |
lenghts | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install build-essential libssl-dev zlib1g-dev libreadline5-dev | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz | |
tar xzf ruby-1.9.1-p0.tar.gz | |
cd ruby-1.9.1-p0 | |
./configure | |
make | |
sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install build-essential libssl-dev zlib1g-dev libreadline5-dev | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz | |
tar xzf ruby-1.9.1-p0.tar.gz | |
cd ruby-1.9.1-p0 | |
./configure | |
make | |
sudo make install |
OlderNewer