Skip to content

Instantly share code, notes, and snippets.

View hubertlepicki's full-sized avatar

Hubert Łępicki hubertlepicki

View GitHub Profile
@hubertlepicki
hubertlepicki / Dockerfile
Created June 13, 2017 08:51
Ruby 2.4.1, Rails 5.1.1, PostgreSQL, Docker + docker-compose config files
FROM phusion/baseimage:0.9.22
CMD ["/sbin/my_init"]
RUN add-apt-repository -y ppa:brightbox/ruby-ng
RUN apt-get update
RUN apt-get install -y libpq-dev git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs wget autoconf tzdata ruby2.4 ruby2.4-dev rubygems ruby-switch
RUN ruby-switch --set ruby2.4
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@hubertlepicki
hubertlepicki / config.lua
Created January 16, 2024 13:24
My LunarVim config.lua file
-- Read the docs: https://www.lunarvim.org/docs/configuration
-- Example configs: https://github.com/LunarVim/starter.lvim
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6
-- Forum: https://www.reddit.com/r/lunarvim/
-- Discord: https://discord.com/invite/Xb9B4Ny
--
-- Additional NeoVim plugins:
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 4.0"
gem "railties", "~> 4.0"
gem "tzinfo"
# Let's use thin
defmodule UI.Application do
use Application
def start(_type, _args) do
# List of children to be started when checks succeed
delayed_children = [
UI.Endpoint,
{Absinthe.Subscription, UI.Endpoint}
]
@hubertlepicki
hubertlepicki / benchmark.ex
Last active March 15, 2019 10:54
benchmark
query = "query {
project(id: 1389) {
id,
slices {
id,
todos {
id,
title,
description,
progress,
class HelloWorldController < AbstractController::Base
include AbstractController::Rendering
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::AssetPaths
include ActionController::UrlWriter
# Uncomment if you want to use helpers defined in ApplicationHelper in your views
# helper ApplicationHelper
For 2 people will need:
1. Spices
- 1 table spoon of red curry paste
- 2 anise stars
- 3 cardamom seeds
- 3 cloves
- 1 piece of cinnamon bark
- 1 long pepper
- 2 table spoons of garam masala
@hubertlepicki
hubertlepicki / irb
Created September 29, 2017 11:43
Strings vs Symbols ruby hash
irb(main):029:0> Benchmark.bm do |x|
irb(main):030:1* x.report("Strings: ") { 10000000.times {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".hash} }
irb(main):031:1> x.report("Symbols: ") { 10000000.times {:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.hash} }
irb(main):032:1> end
user system total real
Strings: 1.290000 0.000000 1.290000 ( 1.282911)
Symbols: 0.450000 0.000000 0.450000 ( 0.458915)
@hubertlepicki
hubertlepicki / db_connection_dies
Last active October 13, 2017 08:03
Phoenix stacktraces
09:46:57.136 [error] #PID<0.600.0> running Todos.UI.Endpoint terminated
Server: localhost:4001 (http)
Request: POST /login
** (exit) an exception was raised:
** (DBConnection.ConnectionError) connection not available because of disconnection
(db_connection) lib/db_connection.ex:926: DBConnection.checkout/2
(db_connection) lib/db_connection.ex:742: DBConnection.run/3
(db_connection) lib/db_connection.ex:584: DBConnection.prepare_execute/4
(ecto) lib/ecto/adapters/postgres/connection.ex:73: Ecto.Adapters.Postgres.Connection.prepare_execute/5
(ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6
@hubertlepicki
hubertlepicki / gracefully_shutdown_process_tree.exs
Last active May 18, 2017 07:45
Gracefully shut down the process tree with name registration
defmodule ParentServer do
use GenServer
import Supervisor.Spec
def start_link() do
GenServer.start_link(__MODULE__, nil, name: __MODULE__)
end
def init(_) do
Process.flag(:trap_exit, true)