Skip to content

Instantly share code, notes, and snippets.

View karlosmid's full-sized avatar

Karlo Smid karlosmid

View GitHub Profile
@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 / 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 / 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 / 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

testers.each {|tester| print tester}
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
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 Testivator.CRM.DataFile do
@moduledoc """
DataFile schema
"""
use Testivator.Web, :model
use Arc.Ecto.Schema
alias Testivator.CRM.Charter
alias Testivator.CRM.DataFile
schema "datafiles" do
defmodule Testivator.CRM.DatafileSpec do
@moduledoc """
This module holds espec spec demonstrations for CRM.Datafile module.
"""
use ESpec.Phoenix, async: false, model: DataFile
alias Testivator.CRM.DataFile
alias Testivator.File
import Mock
context "Changeset" do
@karlosmid
karlosmid / application.ex
Created July 13, 2020 06:48
Phoenix Swagger validation in production
def start(_type, _args) do
if Application.fetch_env!(:your_app_name, :production) do
PhoenixSwagger.Validator.parse_swagger_schema(
Path.join(["#{:code.priv_dir(:your_app_name)}", "static", "swagger.json"])
)
else
PhoenixSwagger.Validator.parse_swagger_schema("priv/static/swagger.json")
end
// ... rest of your Phoenix Application start up code.