Skip to content

Instantly share code, notes, and snippets.

View mikalv's full-sized avatar

Mikal mikalv

View GitHub Profile
@mikalv
mikalv / Proxy.scala
Created November 13, 2017 22:01 — forked from rklaehn/Proxy.scala
Minimal akka http proxy
package akkahttptest
import akka.actor.ActorSystem
import akka.http.Http
import akka.stream.FlowMaterializer
import akka.http.server._
import akka.http.marshalling.PredefinedToResponseMarshallers._
import akka.stream.scaladsl.{HeadSink, Source}
object Proxy extends App {
@mikalv
mikalv / camera.py
Created September 21, 2022 13:30 — forked from alfonsrv/camera.py
Motion detection with OpenCV + grab static snapshot every 1 second from RTSP video stream
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) Rau Systemberatung GmbH (rausys.de)
# MIT License
# credits: https://pyimagesearch.com/start-here/
import argparse
import os
from datetime import datetime, timedelta
@mikalv
mikalv / application.ex
Created August 30, 2022 17:42 — forked from cblavier/application.ex
Cowboy 2.5 proxy, used to bind a single port (on Heroku) for umbrella Phoenix applications. It supports HTTPS and websockets properly.
defmodule MasterProxy.Application do
alias MyApp.Endpoint, as: MyAppEndpoint
alias MyApp.UserSocket, as: MyAppUserSocket
alias MyOtherApp.Endpoint, as: MyOtherAppEndpoint
alias MyOtherApp.UserSocket, as: MyOtherAppUserSocket
alias Phoenix.LiveReloader.Socket, as: LiveReloadSocket
alias Plug.Cowboy
@mikalv
mikalv / datetime_parser.ex
Created August 20, 2022 02:06 — forked from bluzky/datetime_parser.ex
Elixir datetime parser with regex
defmodule DateTimeParser do
@mapping %{
"H" => "(?<hour>\\d{2})",
"I" => "(?<hour12>\\d{2})",
"M" => "(?<minute>\\d{2})",
"S" => "(?<second>\\d{2})",
"d" => "(?<day>\\d{2})",
"m" => "(?<month>\\d{2})",
"y" => "(?<year2>\\d{2})",
"Y" => "(?<year>-?\\d{4})",
nginx conf for proxying the FreeIPA UI. ipa.my.org is the proxy name, realipa.my.org is the master.
server {
listen 443 ssl;
server_name ipa.my.org;
ssl on;
ssl_certificate /etc/nginx/ssl/ipa.crt;
ssl_certificate_key /etc/nginx/ssl/ipa.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AES256+EECDH:AES256+EDH:AES128+EECDH!aNULL;
@mikalv
mikalv / go-switch-bash
Created July 1, 2022 11:11 — forked from AnomalRoil/go-switch-bash
The `go switch` function allows you to easily switch you current Go version
# to add to your ~/.bashrc or your ~/.zshrc file. Usage: $ go switch 1.18.1
function go() {
case $* in
switch* )
shift 1
gobindir=$(go env GOBIN)
# adapt to a valid directory at the beginning of your $PATH if you're not on systemd
homebindir=$(systemd-path user-binaries)
go install golang.org/dl/go"$@"@latest
$gobindir/go"$@" download
@mikalv
mikalv / psql_useful_stat_queries.sql
Created June 30, 2022 02:29 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@mikalv
mikalv / index.html
Created May 24, 2022 19:57
Task Management Dashboard UI
<link href="https://fonts.googleapis.com/css?family=DM+Sans:400,500,700&display=swap" rel="stylesheet">
<div class="task-manager">
<div class="left-bar">
<div class="upper-part">
<div class="actions">
<div class="circle"></div>
<div class="circle-2"></div>
</div>
</div>
<div class="left-content">
@mikalv
mikalv / dark-ui-bank-dashboard-concept.markdown
Created May 24, 2022 19:50
Dark UI - Bank dashboard concept
@mikalv
mikalv / split.zsh
Created April 22, 2022 23:08 — forked from mattmc3/split.zsh.md
ZSH - split string into array
str=part1/part2/part3
# part1
echo ${str%%/*}
# part1/part2
echo ${str%/*}
# part2
echo ${${str%/*}#*/}
# part2/part3
echo ${str#*/}
# part3