Skip to content

Instantly share code, notes, and snippets.

View antonioshadji's full-sized avatar

Antonios Hadjigeorgalis antonioshadji

View GitHub Profile
@antonioshadji
antonioshadji / postman-signed-headers.js
Last active August 30, 2024 21:22
Postman pre-request code that works with localhost server to include signed header in request
// This script reqires a local server to be running at localhost:3000
// to handle the cryptographic signature.
// store your signing key in your enviroment
const signingKey = pm.environment.get("signing_key");
// javascript Date.now() returns unix timestamp in ms, convert to s
const timestamp = Math.floor(Date.now() / 1000)
const method = pm.request.method.toString();
// Postman does not substitute URL parameters before running this script
@antonioshadji
antonioshadji / postmanCdn.js
Created August 29, 2024 13:04
Example of loading library from CDN in postman.
// The example at https://blog.postman.com/adding-external-libraries-in-postman/
// was failing for me due to exports, for this particular library stripping the last 3 lines loaded the library successfully.
// NOTE: this particular library does not work in Postman due to missing dependencies from node/browser
function removeLastLines(text, num) {
// Split the text into lines
const lines = text.split('\n');
// Remove the last two lines
lines.splice(-num);
@antonioshadji
antonioshadji / draw.io.py
Created July 27, 2024 20:13
Generate evenly spaced connection points for rectangular draw.io diagram shapes
""" Place the resulting output into the style of a draw.io shape.
Edit Style -> paste output at end.
"""
import numpy as np
# generate connection points for draw.io shapes
hnum=16 # sections along the horizontal
vnum=4 # sections along the vertical
precision=4
points=[]
@antonioshadji
antonioshadji / tax_calc.py
Created May 1, 2024 21:26
Calculate income tax on taxable income
# tiers are for married filing jointly 2024
over = [
0,
23200,
94300,
201050,
383900,
487450,
731200
]
@antonioshadji
antonioshadji / Dockerfile.user
Created March 23, 2023 13:25
Dockerfile create and use non-root user inside container
ARG UNAME=antonios
ARG UID=1000
ARG GID=1000
RUN groupadd -g $GID -o $UNAME
RUN useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
RUN usermod -aG sudo $UNAME
USER $UNAME
@antonioshadji
antonioshadji / kyc.mermaid
Created July 26, 2022 17:54
Mermaid code for KYC sequence Diagram
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am antonioshadji on github.
  • I am antonioshadji (https://keybase.io/antonioshadji) on keybase.
  • I have a public key ASAqQHrfa898wvvQfSnZggzRQzIwBT4d_4QA6CdB_MBHcAo

To claim this, I am signing this object:

@antonioshadji
antonioshadji / main.c
Created April 11, 2019 00:18
test c program for testing python subprocess
#define _POSIX_C_SOURCE 199309L
#include <stdio.h>
#include <time.h>
int main(int argc,char* argv[])
{
time_t now;
time(&now);
printf("Today is: %s", ctime(&now));
@antonioshadji
antonioshadji / log_path.py
Last active April 11, 2019 00:15
archive log files
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from pathlib import Path
import datetime
import time
print(os.path.dirname(__file__))
print(type(os.path.dirname(__file__)))
print(os.path.dirname(os.path.abspath(__file__)))
@antonioshadji
antonioshadji / benchmark.py
Created March 8, 2019 02:29
Using timeit as library
import timeit
import random
def test(setup, cmd):
repeat = 3
precision = 3
t = timeit.Timer(stmt=cmd, setup=setup)
number, _ = t.autorange()
r = t.repeat(repeat, number)