Skip to content

Instantly share code, notes, and snippets.

View bartekupartek's full-sized avatar

Bartłomiej Różański bartekupartek

View GitHub Profile
@talyguryn
talyguryn / wildcard-ssl-certificate.md
Last active October 29, 2023 08:57
How to get a wildcard ssl certificate and set up Nginx.

How to get and install a wildcard SSL certificate

In this guide you can find how to resolve the following issues.

Feel free to ask any questions in the comments section below.

@hauleth
hauleth / pg_graph.sh
Created April 17, 2018 17:22
Script to generate DOT graph of dependencies between tables in PostgreSQL
#!/bin/sh
psql -qX "$@" <<EOF
\t on
\timing off
\echo 'Digraph F{'
\echo 'ranksep=1.0; size="18.5, 15.5"; rankdir=LR;'
SELECT
@tamas-molnar
tamas-molnar / kubectl-shortcuts.sh
Last active June 19, 2024 14:10
aliases and shortcuts for kubectl
alias kc='kubectl'
alias kclf='kubectl logs --tail=200 -f'
alias kcgs='kubectl get service -o wide'
alias kcgd='kubectl get deployment -o wide'
alias kcgp='kubectl get pod -o wide'
alias kcgn='kubectl get node -o wide'
alias kcdp='kubectl describe pod'
alias kcds='kubectl describe service'
alias kcdd='kubectl describe deployment'
alias kcdf='kubectl delete -f'
@narrowtux
narrowtux / collection.ex
Last active November 15, 2016 08:04
remove and difference functions for Enum
defmodule Coll do
@doc """
Removes all values from the subject
iex> Coll.remove([1, 2, 3], [2, 3])
[1]
iex> Coll.remove([1, 2], [2, 3, 4])
[1]
"""
@ahmadshah
ahmadshah / README.md
Last active January 6, 2021 15:21
Ecto Soft Delete

Soft Delete Ecto Repo

The goal is to support soft delete functionality in Ecto.Repo. With the suggestion by @imranismail, another repo is created and the remaining functionalities are delegate to the original MyApp.Repo.

The new repo get/2 and all/1 functions will exclude the soft deleted record by default. delete/1 and delete_all/1 will update the delete_at column by default instead of deleting.

Example

MyApp.Repo.get(MyApp.User, 1) //will return nil if record is in soft delete state
@henrik
henrik / poolboy_demo.ex
Last active December 16, 2020 13:56 — forked from sasa1977/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000
@pete2786
pete2786 / project_comment.rb
Last active May 30, 2016 08:38
Slack Notifiable and Example
class ProjectComment < ActiveRecord::Base
include SlackNotifiable
belongs_to :user
belongs_to :project
has_one :organization, through: :project
def slack_message
"#{user.name} has commented on #{project.title}: #{description}"
end
@omegahm
omegahm / fizzbuzz.rb
Last active November 9, 2015 13:53
Fizzbuzz in Ruby
class Fiznum
attr_accessor :num
def initialize(num)
self.num = num
end
def fizzbuzz?
num % 15 == 0
end
@omegahm
omegahm / fizzbuzz.ex
Created May 19, 2015 16:23
FizzBuzz in Elixir
defmodule FizzBuzz do
def fizzbuzz(n) do
whichfizz(rem(n, 3), rem(n, 5), n)
end
defp whichfizz(0, 0, _), do: "FizzBuzz"
defp whichfizz(0, _, _), do: "Fizz"
defp whichfizz(_, 0, _), do: "Buzz"
defp whichfizz(_, _, n), do: n
end
@prio
prio / server.ex
Created January 6, 2014 22:16
Elixir gen_server example
defmodule Tcprpc.Server do
use GenServer.Behaviour
defrecord State, port: nil, lsock: nil, request_count: 0
def start_link(port) do
:gen_server.start_link({ :local, :tcprcp }, __MODULE__, port, [])
end
def start_link() do