Skip to content

Instantly share code, notes, and snippets.

View andriisoldatenko's full-sized avatar
🏠
Working from home

Andrii Soldatenko andriisoldatenko

🏠
Working from home
View GitHub Profile
@bessarabov
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active August 23, 2024 19:11
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@m-aciek
m-aciek / check.py
Created May 10, 2019 22:00
Alembic database freshness check.
from alembic import config
from alembic import script
from alembic.runtime import migration
import sqlalchemy
import exceptions
engine = sqlalchemy.create_engine(DATABASE_URL)
alembic_cfg = config.Config('alembic.ini')
@andriisoldatenko
andriisoldatenko / windows.md
Last active April 17, 2019 14:51
Run Astronomer CLI on Windows

Run Astronomer CLI on Windows

Make sure you have Windows 10 and Docker installed

  1. Download latest release of astro-cli using this link
  2. Extract astro_0.8.2_windows_386.zip and move astro.exe somewhere in your %PATH%
  3. Open cmd or PowerShell console and run:
C:\Windows\system32>astro version
Astro CLI Version: 0.8.2
Git Commit: f5cdab8f832da3c6184a7ac167b491e3bac3c022
@andriisoldatenko
andriisoldatenko / interesting_twitter_golang.md
Last active October 4, 2024 17:52
Interesting twitter accounts to follow about go (goalng)

Interesting twitter accounts to follow about Go programming language

Made with ❤️and golang tools 🛠 by @a_soldatenko

People

Interesting bloggers in twitter

  • @rob_pike - Rob Pike author of Go programming language.
  • @francesc - Francesc Campoy is Gopher, Developer Advocate, Good Guy.
@andriisoldatenko
andriisoldatenko / fopen.py
Last active November 20, 2018 05:42
This function helps you do not see errors during upload solutions, because you forget to switch back to sys.stdin and also you can easily debug your code with ipdb or another python debuggers
def fopen(filename, default=sys.stdin):
"""
This function helps you do not see errors during upload solutions
because you forget to switch back to sys.stdin and also you can easily
debug your code with ipdb or another python debuggers
"""
try:
f = open(filename)
except FileNotFoundError:
f = default
@sdboyer
sdboyer / goslowtests.bash
Created October 30, 2017 01:57
Figure out which of your go (sub)tests are slow
# This will sort go test -v output in ascending order of time to complete the test
$ go test -v | sed -n 's#.*PASS: \([^ ]*\) (\([0-9]*\.[0-9]\{2\}\)s)#\2 \1#p' | sort -g
# Add this to e.g. ~/.bashrc, ~/.zshrc, then you can pipe to it: `go test -v | goslowtests`
function goslowtests {
sed -n 's#.*PASS: \([^ ]*\) (\([0-9]*\.[0-9]\{2\}\)s)#\2 \1#p' | sort -g
}
@mrw34
mrw34 / postgres.sh
Last active October 16, 2024 22:51
Enabling SSL for PostgreSQL in Docker
#!/bin/bash
set -euo pipefail
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req -keyout privkey.pem
openssl rsa -in privkey.pem -passin pass:abcd -out server.key
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod 600 server.key
test $(uname -s) = Linux && chown 70 server.key
docker run -d --name postgres -e POSTGRES_HOST_AUTH_METHOD=trust -v "$(pwd)/server.crt:/var/lib/postgresql/server.crt:ro" -v "$(pwd)/server.key:/var/lib/postgresql/server.key:ro" postgres:12-alpine -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key
@troyfontaine
troyfontaine / 1-setup.md
Last active November 15, 2024 05:51
Signing your Git Commits on MacOS

Methods of Signing Git Commits on MacOS

Last updated March 13, 2024

This Gist explains how to sign commits using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

Additionally, 1Password now supports signing Git commits with SSH keys and makes it pretty easy-plus you can easily configure Git Tower to use it for both signing and ssh.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

@icambridge
icambridge / Dockerfile
Created February 4, 2017 12:33
Go dep in docker
FROM golang:1.7
# Set go bin which doesn't appear to be set already.
ENV GOBIN /go/bin
# build directories
RUN mkdir /app
RUN mkdir /go/src/app
ADD . /go/src/app
WORKDIR /go/src/app
@jordifebrer
jordifebrer / oauth2.md
Last active October 24, 2023 07:59
Simplified OAuth 2 workflow for dummies (me!)

Simplified OAuth 2 workflow for dummies (me!)

User case

A user wants profile data from an app.

Workflow

  1. User makes a request to a client (website, mobile app, etc).
  2. Client (may) redirect the user to auth server login form.
  3. User logs into the auth server.
  4. Auth server validates previous credentials and returns an access token to the client.