Skip to content

Instantly share code, notes, and snippets.

View take-five's full-sized avatar

Alexey Mikhaylov take-five

View GitHub Profile
@ayubmalik
ayubmalik / main.go
Last active April 1, 2024 17:08
Golang AWS SSO login from the command line. Will start a new AWS SSO session and retrieve valid access token.
package main
import (
"context"
"log"
"strings"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
@atomkirk
atomkirk / hungarian.ex
Last active January 8, 2023 20:25
Hungarian/Munkres algorithm in Elixir
defmodule Hungarian do
@moduledoc """
Written by Adam Kirk – Jan 18, 2020
Most helpful resources used:
https://www.youtube.com/watch?v=dQDZNHwuuOY
https://www.youtube.com/watch?v=cQ5MsiGaDY8
https://www.geeksforgeeks.org/hungarian-algorithm-assignment-problem-set-1-introduction/
@Clark-G
Clark-G / upgrade-postgres-9.5-to-11.md
Last active September 8, 2023 03:26 — forked from delameko/upgrade-postgres-9.5-to-9.6.md
Upgrading PostgreSQL from 9.5 to 11 on Ubuntu 16.04

TL;DR

Install Postgres 11, and then:

sudo pg_dropcluster 11 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
@NikolayS
NikolayS / howto.md
Last active January 29, 2023 20:25
log_min_duration_statement = 0 and I/O impact

How to get an estimate of the impact of writing Postgres logs with log_min_duration_statement = 0:

  1. Do select pg_stat_statements_reset(); and wait N seconds (where N >> 60 – say 1-24 hours, covering typical busy hours). Remember when it was, and write down somewhere – this timestamp will be needed!

  2. Check if select count(*) from pg_stat_statements is lower than pg_stat_statements.max. If it's equal to it, then raise pg_stat_statements.max and restart with the step 1.

  3. Get the estimate:

\set TS_PGSS_RESET 'XXXX-XX-XX XX:XX:XX';
@hermanbanken
hermanbanken / Dockerfile
Last active July 5, 2024 06:54
Compiling NGINX module as dynamic module for use in docker
FROM nginx:alpine AS builder
# nginx:alpine contains NGINX_VERSION environment variable, like so:
# ENV NGINX_VERSION 1.15.0
# Our NCHAN version
ENV NCHAN_VERSION 1.1.15
# Download sources
RUN wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -O nginx.tar.gz && \
@AtulKsol
AtulKsol / db_backup_commands.md
Last active May 31, 2024 20:19
Commands to backup & restore database
  1. pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
    Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql

    Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql

    -h is for host.
    -p is for port.
    -U is for username.
    -d is for database.

@jonsuh
jonsuh / .bash_profile
Last active February 16, 2024 17:17
Bash echo in color
# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
@markan
markan / vpncfix.md
Created August 21, 2015 17:52
shimo/vpnc "ERROR: can't send packet: Can't assign requested address"

The problem

I've frequently been bit by failures restarting my vpn on my Mac. The connection may appear to start up in Shimo (the menu icon will change) but it looks like vpnc can't connect.

Looking at the log, we see the connection gets stuck

ERROR: can't send packet: Can't assign requested address

This has plagued me for a while, and my only fix has been to restart the machine. I hate restarting my machine. So I finally made time to dig in and find a better solution

@take-five
take-five / gist:5112f12cc23a4001364a
Created March 27, 2015 18:30
Deploy without downtime

Taken from here

Barsoom

Deploy without downtime

We deploy without downtime when we can to avoid user frustration. It's pretty rare that we can't.

There's a great talk/slideshow on this, but no convenient reference that we're aware of – hence this document.

@JunichiIto
JunichiIto / alias_matchers.md
Last active July 18, 2024 15:03
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value