Skip to content

Instantly share code, notes, and snippets.


Oto Brglez otobrglez

View GitHub Profile
otobrglez / jaccard_recommendation.rb
Last active Aug 7, 2020
Simple recommendation system written in Ruby based on Jaccard index.
View jaccard_recommendation.rb
# Simple Recommendation Engine in Ruby
# Visit:
# Author: Oto Brglez <>
class Book <
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
otobrglez / Article.rb
Created Jul 12, 2011
Finding related articles using Jaccard index and tags
View Article.rb
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info:
class Article < ActiveRecord::Base
def related(limit=10)
( SELECT array_agg( FROM taggings tg, tags t
otobrglez / NodeApp.scala
Last active Jul 9, 2020
Simple Akka Cluster with decline and Akka Typed.
View NodeApp.scala
* Author: Oto Brglez - <>
import akka.cluster.ClusterEvent.MemberEvent
import akka.cluster.typed._
import com.monovore.decline._
otobrglez / casting_types.rb
Created Mar 12, 2015
unknown OID 705: failed to recognize type of '<field>'. It will be treated as String.
View casting_types.rb
#!/usr/bin/env ruby
# If you get "unknown OID 705: failed to recognize type of '<field>'. It will be treated as String."
# it probably means that type of column could not be identified when retriving records
# Example
User.where("'something' as something")
# Will results in unknown OID. However doing this:
View adb-completion.bash
# /* vim: set ai ts=4 ft=sh: */
# Copyright 2011, The Android Open Source Project
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
otobrglez /
Created Jun 3, 2016
YAML to JSON - one-liner with Ruby
# Single line of Ruby <3.
ruby -rjson -ryaml -e "puts YAML.load_file('my_file.yml').to_json"
# You can also pipe it to Python to get pretty ouput
ruby -rjson -ryaml -e "puts YAML.load_file('my_file.yml').to_json" | \
python -mjson.tool
# Thats all. :)
View Boot5.scala
package com.examples.streaming_one
import akka.Done
import slick.jdbc.JdbcBackend.Database
import slick.jdbc.PostgresProfile.api._
import slick.jdbc.{ResultSetConcurrency, ResultSetType}
otobrglez / as3.rake
Created Jun 29, 2011
Rake task for uploading Rails 3.1 compiled assets to Amazon S3 storage
View as3.rake
# 1) Put 's3' gem in Gemfile.
# 2) Create as3.yml configuration for S3
# 3) Create initializer for as3.yml
# 4) Make "assets" folder inside your bucket
# 5) After running task run "RAILS_ENV=production rake assets:precompile"
# 6) Invoke task by running "rake as3:upload"
namespace :as3 do
desc "Uploads compiled assets (public/assets) to Amazone AS3"
task :upload do
otobrglez / car.rb
Created Aug 23, 2011
Experimenting with observer pattern (publish/subscribe pattern) in Ruby
View car.rb
# Simple Car class. Nothing special here...
class Car
attr_accessor :brand
attr_accessor :model
attr_accessor :year
def initialize(brand, model, year=2011)
@brand, @model, @year = brand, model, year
otobrglez / RegressionApp.scala
Last active Sep 11, 2018
Linear regression with pure Scala
View RegressionApp.scala
import scala.math.{pow}
import scala.concurrent._
import scala.concurrent.duration._
import scala.collection.mutable.ArrayBuffer
object Regression {
def linear(pairs: IndexedSeq[Seq[Double]]) = {
val n = pairs.size
You can’t perform that action at this time.