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 / Application.scala
Created September 10, 2014 21:08
FizzBuzz in Scala w/ lists, tuples and magic
object Application {
def fizzBuzzMega(e: Int): List[String] = {
var big = (1 to e).toList.map (i => i.toString)
val m = List(
(3, ((1 to e).toList zip List.range(0, e+3, 3)).drop(1).map (_._2)),
(5, ((1 to e).toList zip List.range(0, e+5, 5)).drop(1).map (_._2)),
(3*5, ((1 to e).toList zip List.range(0, e+3*5, 15)).drop(1).map (_._2))
).map(p =>
p._2.map (n =>
big = big.updated(n-1,
@otobrglez
otobrglez / .bash_profile
Last active August 29, 2015 14:07
Open continuous integration server at current build from command line (w/ github/hub)
# Install https://github.com/github/hub
# Add alias to your ~/.bash_profile (or somewhere alike)
alias ci-open='open `hub ci-status -v | grep -oE "[^\ ]+$"`'
Use it with your normal workflow...
git push ...
ci-open
# and see your CI pass. ;)
@otobrglez
otobrglez / open_close_panels.haml
Created October 16, 2014 17:04
Collapsable Bootstrap Panels
- I18n.available_locales.each_with_index do |locale,i|
- ulocale = locale.to_s.underscore
- show_expanded = [:'en-US', I18n.locale].include?(locale)
.panel.panel-default{id: ulocale}
%a.panel-default{"data-toggle" => "collapse", "data-parent" => "##{ulocale}", "href" => "#panel-#{ulocale}"}
.panel-heading
.panel-title= CONFIG[:display_locales][locale]
@otobrglez
otobrglez / cache_buster_expression.rb
Created October 27, 2014 12:23
Regex - Anything before "cache-buster"
# Regular expression that
# 1. Finds host name
# 2. Finds path name
# 3. Ignores first optional numeric 'cache-buster' parameter
xp = %r{^http:\/\/([a-z0-9\.]+)\/([a-z_]+)\/(.*?)(?:\?|$)}
@otobrglez
otobrglez / rails-ujs-patch.js
Last active August 29, 2015 14:10
Patching Rails UJS
/*
When tinymce f* u over!
*/
jQuery.rails.href = function(element) {
var href = element.attr('href');
if(typeof(href) == "string") {
return href;
}
@otobrglez
otobrglez / log.py
Last active August 29, 2015 14:14
Rollbar log observer for Scrapy / Python
import rollbar
import logging
# Needed if you use rollbar.report_exc_info
import sys
class RollbarLogObserver(object):
def __init__(self, rollbar_access_token, env="development", level=logging.INFO):
self.level = level
rollbar.init(rollbar_access_token, env)
@otobrglez
otobrglez / pprint.py
Created February 18, 2015 09:33
Pretty printing with Python
import pprint
# Something like this:
pprint.pprint some_object.__dict__
@otobrglez
otobrglez / errors.log
Created March 11, 2015 21:23
slovene_lemmatizer - warnings
g++ -O3 -fPIC -fomit-frame-pointer -ffast-math -I./src -I./bindings/java/headers -I./bindings/java/headers/linux -c ./bindings/java/headers/sl_lemmatizer_java.cpp -o ./src/sl_java_headers.o
In file included from ./bindings/java/headers/sl_lemmatizer_java.cpp:23:
./src/RdrLemmatizer.h:122:21: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
char *acParSufx = "", char *acParDev = "", char cNewChar=NULL) const;
^
./src/RdrLemmatizer.h:122:42: warning: conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]
char *acParSufx = "", char *acParDev = "", char cNewChar=NULL) const;
^
./src/RdrLemmatizer.h:122:60: warning: implicit conversion of NULL constant to 'char' [-Wnull-conversion]
char *acParSufx = "", char *acParDev = "", char cNewChar=NULL) const;
#!/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
@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