Skip to content

Instantly share code, notes, and snippets.

View georgepadayatti's full-sized avatar

George J Padayatti georgepadayatti

View GitHub Profile
@georgepadayatti
georgepadayatti / generate_totp.py
Created May 4, 2023 07:00
Generate Time-based One-time Password
#!/usr/bin/env python3
import base64
import hmac
import struct
import sys
import time
def hotp(key, counter, digits=6, digest='sha1'):
@georgepadayatti
georgepadayatti / instructions.md
Last active May 2, 2023 17:44
Integrate iGrant.io Data Pod to an application

1.0 Authentication

1.1 Obtain the DataPod URL from the Individual

An application can ask the user to the enter the URL of their datapod. for e.g. this would look like https://george.datapod.igrant.io

If the individual provides a URL that doesn't end with /profile/card#me path then, append that to the provided URL.

1.2 Obtain the OIDC issuer URL for DataPod

@georgepadayatti
georgepadayatti / setup-pipenv.md
Created April 11, 2023 10:20
Setup Pipenv in project path

Setup Pipenv in project

Add the following to the ~/.zshrc file

export PIPENV_VENV_IN_PROJECT=1

Create an empty .venv folder in the project path

@georgepadayatti
georgepadayatti / snippet.md
Last active March 25, 2022 11:45
JSON-LD context cache in pyld (Python)

JSON-LD context cache in PyLD

Problem

When performing canonization of a JSON-LD document, it is necessary to perform compact, expand and normalise operations. This would involve resolving multiple remote contexts. Since the contexts are located in a remote host, the availability of the resource cannot be garunteed. Fetching a remote resource adds significant latency if the remote server doesn't respond fast.

Solution

Implement a cache for remote contexts. This can be done by caching the responses from the document loader used by PyLD. A simple cache snippet using python dictionary for PyLD is given below.

@georgepadayatti
georgepadayatti / openssl_m1.md
Created August 22, 2021 14:52
Compile OpenSSL to Apple silicon arm architecture

For compiling OpenSSL to Apple silicon, follow the below instructions:

  1. cd ~
  2. wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
  3. tar -xvzf openssl-1.1.1k.tar.gz
  4. cd openssl-1.1.1k
  5. ./Configure shared enable-rc5 zlib darwin64-arm64-cc --prefix=/usr/local/ssl --openssldir=/usr/local/ssl
  6. make -j$(($(nproc)+1))
  7. sudo make install
  8. export OPENSSL_DIR=/usr/local/ssl/
@georgepadayatti
georgepadayatti / decode_keycloak_jwt.py
Last active August 30, 2020 15:40
Decoding RSA 256 JWT from keycloak in python
import base64
from codecs import encode
import jwt
from Crypto.PublicKey import RSA
n = "<BASE64 RSA MODULUS>"
e = "<BASE64 RSA EXPONENT>"
# fixing the padding and base64 decoding