Skip to content

Instantly share code, notes, and snippets.

Avatar
🏗️
Building.

Oto Brglez otobrglez

🏗️
Building.
View GitHub Profile
@otobrglez
otobrglez / Rakefile
Last active Aug 29, 2015
Rake task to execute RSpec suite for each "project" inside its own folder (RVM)
View Rakefile
# 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 Jun 10, 2014
Before I forget about C# ;)
View Makefile
# Users mono
# Install mono via Homebrew
# brew install mono
hello.exe:
gmcs hello.cs
clean:
rm -rf *.exe
@otobrglez
otobrglez / test_cors.sh
Created Jul 29, 2014
How to test if your CORS configuration works?
View test_cors.sh
#!/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 Aug 13, 2014
Validating ZZZS number from command-line
View zzzs-validator.sh
#!/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 Aug 26, 2014
Fetching all my photos from Facebook
View fetcher.rb
#!/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 Aug 29, 2014
ElasticSearch - Mapping / Settings example
View film_search.rb
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 Aug 29, 2015
FizzBuzz in C# w/ bit of Linq and generics (v2)
View FizzBuzz.cs
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
Last active Aug 29, 2015
FizzBuzz in C# with Mono for Friday
View FizzBuzz.cs
/*
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 Sep 5, 2014
FizzBuzz in C# w/ bit of Linq and generics
View FizzBuzz.cs
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
Created Sep 6, 2014
FizzBuzz in C# w/ bit of Linq and generics (v3)
View FizzBuzz.cs
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
You can’t perform that action at this time.