Skip to content

Instantly share code, notes, and snippets.

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

Oto Brglez otobrglez

🏗️
Building.
View GitHub Profile
#!/usr/bin/env python
from pprint import pprint
servers = {
"0.0.1.1": {
"status": "OK"
},
"0.0.1.2": {
"status": "ERROR"
@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. :)
#!/usr/bin/env bash
redis-cli \
-h <host> \
-p <port> \
-a <pass> \
keys \* | sed 's/.*query=//' | sort -u
@otobrglez
otobrglez / little_es6.js
Created February 23, 2016 12:26
Splash of ES6
"use strict";
// Experimenting with ES6 on NodeJS
// node --harmony --harmony_default_parameters ./little_es6.js
var numbers = [1, 1, 2, 5, 3];
var littleSum = numbers.filter(x => x % 2).reduce((s, b) => s + b);
console.log(`Sum is ${littleSum}.`);
numbers.forEach(l => console.log(l));
@otobrglez
otobrglez / RegressionApp.scala
Last active September 11, 2018 17:14
Linear regression with pure Scala
import scala.math.{pow}
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.collection.mutable.ArrayBuffer
object Regression {
def linear(pairs: IndexedSeq[Seq[Double]]) = {
val n = pairs.size
@otobrglez
otobrglez / rethinkdb_requests_second.js
Created November 26, 2015 17:41
Experimenting with map-reduce / aggregation in RethinkDB
// successful jobs grouped by type maped by req/sec
r.db('qm_production').table('jobs')
.filter({'last_event_type': 'success'})
.map(function(doc) {
return {
'ds_type': doc('ds_type'),
'last_event_type': doc('last_event_type'),
'res_sec': doc("stats_event_response_count").div(doc('stats_run_duration')),
'req_sec': doc("stats_event_request_count").div(doc('stats_run_duration'))
};
@otobrglez
otobrglez / keybase.md
Created October 13, 2015 20:12
keybase.md

Keybase proof

I hereby claim:

  • I am otobrglez on github.
  • I am otobrglez (https://keybase.io/otobrglez) on keybase.
  • I have a public key whose fingerprint is 4FE7 0346 C546 B9C0 31D9 B91B 0441 9BCA 2621 C2E3

To claim this, I am signing this object:

@otobrglez
otobrglez / Makefile
Created October 5, 2015 20:47
Playing with static and const in C
run: test
./test
test:
clang -ansi test.c -o test
clean:
rm -rf test
@otobrglez
otobrglez / in_qm
Created September 8, 2015 14:28
Docker helper scripts that I always add to my Docker projects. <3
#!/usr/bin/env bash
docker exec -ti $(docker ps -f 'image=databox/qm' -q | head -n1) bash -lc "cd /home/app/qm; $*"
# Usage:
# ./in_qm uname -a
#!/usr/bin/env python
# http://bogdan-ivanov.com/recipe-text-clustering-using-nltk-and-scikit-learn/
#!/usr/bin/env python
import nltk
import string
import collections
from data.feeds import feed
from math import sqrt, ceil, floor