Skip to content

Instantly share code, notes, and snippets.

View HakubJozak's full-sized avatar

Jakub Hozak HakubJozak

  • Prague, Czech Republic
View GitHub Profile
@HakubJozak
HakubJozak / after.slim
Last active February 22, 2018 13:24
Pred a po
.page-header
h2 = Device.listing_name
.table-responsive
table.table.table-condensed
thead
tr
th = t_attr :device
th = t_attr :auditorium
th = create_button Device
@HakubJozak
HakubJozak / like.rb
Created December 12, 2017 10:34
General LIKE query in Rails 5
# Performs SQL LIKE query on a ActiveRecord model. First
# parameter is the +query+, the rest is columns listing.
# One level nesting of belongs to assoctions is supported.
#
# Usage:
#
# Company.like("john", :name, :phone, :email, person: [ :name, :email ])
#
#
def self.like(*args)
@HakubJozak
HakubJozak / a.css
Last active December 8, 2017 17:15
body {
color: pink;
}
@HakubJozak
HakubJozak / test.rb
Created December 1, 2017 08:42
multitenant gem is NOT THREAD SAFE
require 'multitenant'
threads = 2.times.map do |i|
Thread.new(i) do |id|
Multitenant.current_tenant = id
sleep rand
if Multitenant.current_tenant == id
putc '.'
@HakubJozak
HakubJozak / dog.rb
Created April 20, 2017 15:53
animals
# Vytvorte tridu Dog.
# Bude mit jednu instancni promennou @energy a dve metody.
#
# #eat! - zvysi energie o 10
# #walk! - snizi hodnotu energie o 1
# #bark! - snizi hodnotu energie o 5
#
# alive? - true, kdyz energie je vetsi nez 0
require 'sinatra'
require_relative './weather'
weather = Weather.new( pondeli: 'Jasno',
utery: 'Zatazeno',
streda: 'Dest')
require 'sinatra'
calendar = {
pondeli: 'Jasno',
utery: 'Zatazeno',
streda: 'Dest',
}
def make_table(calendar)
calendar.each_pair.map { |day,weather|
@HakubJozak
HakubJozak / send
Created April 20, 2017 09:00
send
# Priklad:
#
# Zeptejte se uzivatele na
#
# - operaci
# - cislo 'a'
# - cislo 'b'
#
# Provedte s cisly zadanou operaci a vysledek vypiste.
@HakubJozak
HakubJozak / fibo.rb
Created April 20, 2017 08:12
fibonacci
def fibo(n)
vysledky = [ 0,1 ]
if n == 0 or n == 1
n
else
i = vysledky.size
while i <= n
fibonacci = vysledky[i-1] + vysledky[i-2]
@HakubJozak
HakubJozak / hamlet.rb
Created April 19, 2017 12:50
read hamlet
require 'open-uri'
require 'pry'
# {
# 'Hamlet' => 334,
# 'the' 323423535
# #....
# }
#frequency = {}