Skip to content

Instantly share code, notes, and snippets.

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

Oto Brglez otobrglez

🏗️
Building.
View GitHub Profile
# Oto Brglez - <otobrglez@gmail.com>
echo 'public class Main {public static void main(String[] args){ System.out.println(System.getProperty("java.home"));}}' > /tmp/Main.java && \
javac /tmp/Main.java && cd /tmp && java Main && rm Main.java && cd -
@otobrglez
otobrglez / my-project-dev.sh
Last active November 16, 2020 16:33
My "micro" wrapper for docker-compose
#!/usr/bin/env bash
set -e
# Author: Oto Brglez, <otobrglez@gmail.com>
# "MY_PROJECT_HOME" - is environment variable, usually set with
# something like direnv (via .env) or let to developer
if [[ -z "${MY_PROJECT_HOME}" ]]; then
echo "MY_PROJECT_HOME environment variable is not set!" && exit 255
fi
@otobrglez
otobrglez / post2pdf.sh
Last active November 13, 2020 21:53
Markdown notes to PDFs with Pandoc (post2pdf.sh)
#!/usr/bin/env bash
# Author: Oto Brglez
# Mail: otobrglez@gmail.com
# Version: 0.0.2
# LICENCE: MIT
# Install:
# - https://pandoc.org/
# - https://github.com/Wandmalfarbe/pandoc-latex-template
# - https://www.overleaf.com/learn/latex/XeLaTeX
# - https://github.com/be5invis/Iosevka
// Live is to short to not have fun.
// Oto Brglez
// @otobrglez
object Main extends App {
type `🐰` = String
type `👨‍💼` = `🐰`
type `💯` = Int
val (`n🆕`: `🐰`, `s👽`: `🐰`) = ("\n", " ")
val `👋`: (`👨‍💼`, `🐰`) => `🐰` = { (`👶`, `🐇`) =>
@otobrglez
otobrglez / yaml_to_json.sh
Created June 3, 2016 13:37
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. :)
class WebHookNode
has_many: :web_hook_expressions
has_many: :expression, thought: :web_hook_expressions
has_many :query_parameters, type: ....
has_many :body_parameters, type: ....
has_many :header_parameters, type: ...
end
package com.opalab.experimental
import java.io.File
import cats.data.NonEmptyChain
import cats.implicits._
import io.circe.syntax._
import scala.io.Source
import scala.util.Using
@otobrglez
otobrglez / Article.rb
Created July 12, 2011 20:51
Finding related articles using Jaccard index and tags
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info: http://en.wikipedia.org/wiki/Jaccard_index
class Article < ActiveRecord::Base
def related(limit=10)
Article.find_by_sql(%Q{
SELECT
a.*,
( SELECT array_agg(t.name) FROM taggings tg, tags t
@otobrglez
otobrglez / NodeApp.scala
Last active July 9, 2020 22:18
Simple Akka Cluster with decline and Akka Typed.
/**
* Author: Oto Brglez - <otobrglez@gmail.com>
*/
package com.pinkstack.realestate.clustering4
import akka.actor.typed._
import akka.actor.typed.scaladsl._
import akka.cluster.ClusterEvent.MemberEvent
import akka.cluster.typed._
import com.monovore.decline._
@otobrglez
otobrglez / casting_types.rb
Created March 12, 2015 10:55
unknown OID 705: failed to recognize type of '<field>'. It will be treated as String.
#!/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: