Skip to content

Instantly share code, notes, and snippets.

View alexandrubagu's full-sized avatar
:octocat:

Alexandru Bogdan Bâgu alexandrubagu

:octocat:
View GitHub Profile
defmodule ListTesting do
def append([]), do: []
def append([head | tail]), do: append(head) ++ append(tail)
def append(head) when is_integer(head), do: [transform(head)]
def prepend_and_reverse(list), do: do_prepend(list, [])
defp do_prepend([], acc), do: Enum.reverse(acc)
defp do_prepend([head | tail], acc), do: do_prepend(tail, [transform(head) | acc])
defp transform(x), do: x * 2
WITH constants AS (
-- define some constants for sizes of things
-- for reference down the query and easy maintenance
SELECT current_setting('block_size')::numeric AS bs, 23 AS hdr, 8 AS ma
),
no_stats AS (
-- screen out table who have attributes
-- which dont have stats, such as JSON
SELECT table_schema, table_name,
n_live_tup::numeric as est_rows,
@alexandrubagu
alexandrubagu / gist:3227318d816cfe77d5310a75e29366f2
Created October 14, 2020 21:52
godot shader draw lines triangle
shader_type canvas_item;
const float Thickness = 0.003;
float drawLine(vec2 uv,vec2 f, vec2 p1, vec2 p2) {
float a = abs(distance(p1, uv.xy));
float b = abs(distance(p2, uv.xy));
float c = abs(distance(p1, p2));
shader_type canvas_item;
render_mode unshaded, blend_disabled;
vec3 random3(vec3 c) {
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
vec3 r;
r.z = fract(512.0*j);
j *= .125;
r.x = fract(512.0*j);
j *= .125;
sysctl -w fs.file-max="9999999"
sysctl -w fs.nr_open="9999999"
sysctl -w net.core.netdev_max_backlog="4096"
sysctl -w net.core.rmem_max="16777216"
sysctl -w net.core.somaxconn="65535"
sysctl -w net.core.wmem_max="16777216"
sysctl -w net.ipv4.ip_local_port_range="1025 65535"
sysctl -w net.ipv4.tcp_fin_timeout="30"
sysctl -w net.ipv4.tcp_keepalive_time="30"
sysctl -w net.ipv4.tcp_max_syn_backlog="20480"
@alexandrubagu
alexandrubagu / website
Created May 8, 2018 08:09
systemd service
[Unit]
Description=personal_website
After=network.target
[Service]
WorkingDirectory=/home/alexandrubagu/apps/personal_website
ExecStart=/home/alexandrubagu/apps/personal_website/bin/personal_website start
ExecStop=/home/alexandrubagu/apps/personal_website/bin/personal_website stop
Environment="PORT=7000"
Environment=LANG=en_US.UTF-8
@alexandrubagu
alexandrubagu / website_virtualhost
Last active June 13, 2020 11:48
nginx & ssl letsencrypt virtualhost
# extract Phoenix app upstream for better readability
upstream app {
server localhost:5000;
}
# hide server information
http {
server_tokens off;
}
@alexandrubagu
alexandrubagu / metrics.ex
Last active May 8, 2018 08:11 — forked from anonymous/mtrics.ex
elixir plug metrics
defmodule Mtrics do
@behaviour Plug
import Plug.Conn
def init(opts \\ []), do: opts
def call(conn, opts) do
start = System.monotonic_time()
register_before_send(conn, fn conn ->