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 / 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
@otobrglez
otobrglez / film_search.rb
Created August 29, 2014 19:19
ElasticSearch - Mapping / Settings example
module FilmSearch
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
mapping do
indexes "title", type: 'string', analyzer: 'snowball'
indexes "signing.starts_at", type: 'date', format: 'basic_date'
@otobrglez
otobrglez / FizzBuzz.cs
Last active August 29, 2015 14:06
FizzBuzz in C# with Mono for Friday
/*
By Oto Brglez - <otobrglez@gmail.com>
What is FizzBuzz? http://en.wikipedia.org/wiki/Fizz_buzz
Requirements: Mono & Make
Compile with: make
Run with: mono ./FizzBuzz.exe
*/
using System;
@otobrglez
otobrglez / FizzBuzz.cs
Created September 5, 2014 19:47
FizzBuzz in C# w/ bit of Linq and generics
using System;
using System.Linq;
using System.Collections.Generic;
public class FizzBuzz {
public static IEnumerable<String> FizzBuzzMe(int to){
return Enumerable.Range(1, to).Select(j =>
j % 3 == 0 && j % 5 == 0 ? "Fizz Buzz" : (
j % 3 == 0 ? "Fizz" : (
j % 5 == 0 ? "Buzz" : j.ToString()
@otobrglez
otobrglez / FizzBuzz.cs
Last active August 29, 2015 14:06
FizzBuzz in C# w/ bit of Linq and generics (v2)
using System;
using System.Linq;
using System.Collections.Generic;
public class FizzBuzz {
public static List<String> FizzBuzzMe2(int to){
List<String> list = new List<String>();
int i = 1;
for(; i<=to; list.Add(i.ToString()), i++);
@otobrglez
otobrglez / FizzBuzz.cs
Created September 6, 2014 08:48
FizzBuzz in C# w/ bit of Linq and generics (v3)
using System;
using System.Linq;
using System.Collections.Generic;
public class FizzBuzz {
public static List<String> FizzBuzzMe3(int to){
return Enumerable.Range(1, to).Select(i =>
new Dictionary<int, String>(){
{1, i.ToString()}, {5, "Buzz"}, {3, "Fizz"}, {3*5, "Fizz Buzz"}
}.Last(a => i % a.Key == 0).Value