Skip to content

Instantly share code, notes, and snippets.

View karlosmid's full-sized avatar

Karlo Smid karlosmid

View GitHub Profile
defmodule Testivator.File do
@moduledoc """
Arc.Ecto definition for charter data files upload
"""
use Arc.Definition
use Arc.Ecto.Definition
# Include ecto support (requires package arc_ecto installed):
# use Arc.Ecto.Definition
defmodule FizzBuzz do
def up_to(n) when n > 0, do: 1..n |> Enum.map(&fizz_buzz/1)
def fizz_buzz(n) do
case {rem(n,3),rem(n,5),n} do
{0,0,_} -> FizzBuzz
{0,_,_} -> Fizz
{_,0,_} -> Buzz
{_,_,_} -> n
end
end
testers.each {|tester| print tester}
@karlosmid
karlosmid / git_cheatsheet.md
Last active August 1, 2019 14:09
git cmd cheatsheet

Full history for file:

git log --follow -p -- file_name

See repo commits in simpe UI orderd by date for specific branch:

gitk --full-history --date-order --branches master

@karlosmid
karlosmid / sed_refactor.sh
Created July 13, 2019 08:27
sed command that I use for refactoring Python package paths that contain dot character.
sed -i -- 's/from tentamen\.tests\.models\./from tentamen\.tests\.database\.local\.models\./g' *.py
@karlosmid
karlosmid / birthdays.rb
Last active February 11, 2022 11:41
birthdays manipulation
def reverse_birthdays birthdays
result = {}
birthdays.map { |day,names| names.map { |name| result[name] = day } }
result
end
actual = {"2019-01-01"=>["karlo01", "karlo02"], "2019-01-02"=>["ben01", "ben02"]}
expected = {"karlo01"=>"2019-01-01", "karlo02"=>"2019-01-01", "ben01"=>"2019-01-02", "ben02"=>"2019-01-02"}
expected == reverse_birthdays(actual)
@karlosmid
karlosmid / jenkins_nexus_same_nginx.conf
Created January 27, 2018 09:50
Jenkins and nexus behind same nginx reverse proxy
server {
listen 80 default_server;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
}
server {
# SSL configuration
#
listen 443 ssl default_server;
@karlosmid
karlosmid / elixir_phoenix_cheat_sheet.md
Last active December 19, 2016 15:02
Cheat sheet for elixir language and phoenix web framework, a reminder for an old man!

Elixir

Install on OsX with brew

brew update
brew upgrade elixir
elixir --version

hex packet manager

<html>
<h1>Test!</h1>
<script>
window.opener.location.replace("http://www.tentamen.hr");
</script>
</html>
@karlosmid
karlosmid / youtube_subtitles.rb
Last active February 27, 2016 21:10
Get youtube video subtitles
Then /^I see lessons with albanian subtitle$/ do
HOST = 'www.googleapis.com'
PATH = '/youtube/v3/captions'
PART = 'snippet'
on(YoutubePage).first_lesson_in_grid_element.when_visible(@app['PAGE_TIMEOUT']).click
youtube_video_id = @browser.element(:tag_name, 'iframe').attribute_value('data-video-id')
youtube_client = HTTPClient.new
response = JSON.parse youtube_client.get("https://#{HOST}#{PATH}?key=#{@app['GOOGLE_API_KEY']}&part=#{PART}&videoId=#{youtube_video_id}").body
pass = false
response['items'].each {|item|