Skip to content

Instantly share code, notes, and snippets.

View otobrglez's full-sized avatar
🏗️
Building.

Oto Brglez otobrglez

🏗️
Building.
View GitHub Profile
@otobrglez
otobrglez / ure_minute.rb
Created December 5, 2013 14:58
NauciMe - Pretvarjanje minut
#!/usr/bin/env ruby -w
# Resitev naloge: http://wiki.fmf.uni-lj.si/wiki/Naloga:_program_Pretvarjanje_minut
stevilo = ARGV[0].to_i
ure = stevilo / 60
minute = stevilo % 60
puts "#{stevilo} min = #{ure} h #{minute} min"
@otobrglez
otobrglez / kalkulator.rb
Created December 12, 2013 16:53
#2 Kalkulator
#!/usr/bin/env ruby -w
operacija = ARGV[0]
a = ARGV[1].to_i
b = ARGV[2].to_i
if operacija == "sestej"
rezultat = a+b
elsif operacija == "odstej"
@otobrglez
otobrglez / dbload
Created December 12, 2013 19:04
Little script
#!/usr/bin/env bash
S_COMMAND_A=$1
S_COMMAND_B=$2
S_COMMAND_C=$3 # token
echo $S_COMMAND_A
echo $S_COMMAND_B
echo $S_COMMAND_C
#!/usr/bin/env ruby -w
sirina = ARGV[0].to_i
visina = ARGV[1].to_i
if sirina == 0 or visina == 0
puts "Manjkajo dimenzije pravokotnika"
exit
end
@otobrglez
otobrglez / jaccard_recommendation.rb
Last active April 2, 2024 17:51
Simple recommendation system written in Ruby based on Jaccard index.
# Simple Recommendation Engine in Ruby
# Visit: http://otobrglez.opalab.com
# Author: Oto Brglez <otobrglez@gmail.com>
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end
@otobrglez
otobrglez / Rakefile
Last active August 29, 2015 14:01
Rake task to execute RSpec suite for each "project" inside its own folder (RVM)
# By Oto Brglez - <otobrglez@gmail.com>
#
# Problem: Sometimes you have project that is build out of many "sub-projects",
# sub-project, can be anything, gem, rails app to single page app. And then you
# want to run specs for each of this project to see if everything works. Then what?
#
# Solution: On your "root" folder create Rake task that goes and executes test suite
# for each project and summers everything into report. Well... At least thats what this is. ;)
#
# Cheers,
@otobrglez
otobrglez / Makefile
Created June 10, 2014 09:24
Before I forget about C# ;)
# Users mono
# Install mono via Homebrew
# brew install mono
hello.exe:
gmcs hello.cs
clean:
rm -rf *.exe
@otobrglez
otobrglez / test_cors.sh
Created July 29, 2014 10:24
How to test if your CORS configuration works?
#!/usr/bin/env bash
# Target host: http://aioo-api.dev
# Testing from origin: http://aioo-spa.dev
# Method: "POST"
curl --verbose --request OPTIONS http://aioo-api.dev \
--header 'Origin: http://aioo-spa.dev' \
--header 'Access-Control-Request-Headers: Origin, Accept, Content-Type' \
--header 'Access-Control-Request-Method: POST'
@otobrglez
otobrglez / zzzs-validator.sh
Created August 13, 2014 23:13
Validating ZZZS number from command-line
#!/usr/bin/env bash
# 1. Make it executable 'chmod +x zzzs-validator.sh'
# 2. Use it './zzzs-validator.sh <ZZZV NUMBER>
HOST="https://zavarovanec.zzzs.si"
ANOY_SEC="/!ut/p/b1/lY_bboMwEES_JV_gtcHGeXQNKfcmITjBL4jeIhCBkkZI4evrRn1Ib6q60mq10hnNDNKoIBzsObcY2iHdVWO9r05131Xt-69ZySARfgDY50IyCOJcKU85AA4xQHEN3NmKGsCz3DBhGCT8U8_tUEBAWUwdOicA-C_9Fu3ALrOGvyTn0y6e5LhpptX51WzSyCl1JU7T5fJRrfMbIW-TY0dQiPS-7e9NvS3Snw1-yP8lwfeAFwB-GQEo9fvDEyoM5lwZycg0sSDHVEpsDtp8NGHDMNRHEnGcZrWVNVMmxYgf1qAWIiIFKfkMHXS7iGnoPbur2RveW3Gk/dl4/d5/L0lDU0lKSmdwcG1BIS9JTFNBQ0lpTXlDb2tBRUFtaWdiaVFDQUEvNEczYUQyZ2p2eWhEVXdnIS9aN182ME1BSEkwMUhPQ0s2MEkzMFUxNUNDMTBVMS8wLzI2OTIyMDY5MzkzOQ!!/"
ENDPOINT_URL="${HOST}/wps/portal/portali/azos/status_zavarovanja${ANOY_SEC}"
curl -si -X POST \
@otobrglez
otobrglez / fetcher.rb
Created August 26, 2014 16:26
Fetching all my photos from Facebook
#!/usr/bin/env ruby
# Use it like this:
# token=access_token_here ./fetcher.rb
require 'bundler/setup'
require 'koala'
require 'chronic'
class Fetcher