Skip to content

Instantly share code, notes, and snippets.

View Nastaliss's full-sized avatar
🍄

Stanislas Bruhière Nastaliss

🍄
View GitHub Profile
@Nastaliss
Nastaliss / generate_github_access_token.sh
Last active October 12, 2023 15:07
Login with a github app and get an access token for ci purpose. This is useful for cloning repository outside of the default scope of the ci github account (e.g. for recursing submodules).
#!/usr/bin/env bash
# Inspired by implementation by Will Haley at:
# http://willhaley.com/blog/generate-jwt-with-bash/
# Stolen from
# https://stackoverflow.com/questions/46657001/how-do-you-create-an-rs256-jwt-assertion-with-bash-shell-scripting
# and simplified to suit our needs
set -euo pipefail
from enum import Enum
import sys
from typing import Tuple
class LetterColor(Enum):
WHITE = 'white'
YELLOW = 'yellow'
class SentenceColor(Enum):
@Nastaliss
Nastaliss / combinations.py
Created December 11, 2019 15:32
Find all unique combinations of a given length for an input of a given size
def find_combinations(input_size=3, output_size=3):
return find_combinations_in_array(
list(range(1, input_size+1)), [], [], output_size)
def find_combinations_in_array(remaining_digits, combinations, combination, combination_length):
print('IN', remaining_digits, combination, combination, combination_length)
# exit strategy
# If the combination is already *combination_length* long
if len(combination) == combination_length:
@Nastaliss
Nastaliss / k_means.py
Created October 7, 2019 14:45
This is an example of a simple implementation of the k means algorithm. Please tweak the constatns as you like :)
from copy import deepcopy
from math import ceil, sqrt
from random import randint
import numpy as np
from matplotlib import pyplot as plt
class Point(object):
def __init__(self, x, y):
@Nastaliss
Nastaliss / k_means.py
Created October 7, 2019 14:44
This is an example of a simple implementation of the k means algorithm.
from copy import deepcopy
from math import ceil, sqrt
from random import randint
import numpy as np
from matplotlib import pyplot as plt
class Point(object):
def __init__(self, x, y):
# -*- coding: utf-8 -*-
import copy
from copy import deepcopy
from functools import reduce
import cv2
import numpy as np
from matplotlib import pyplot as plt
@Nastaliss
Nastaliss / Colorizer.ts
Created May 20, 2019 14:39
High volume color picker
enum Color {
aqua= '#00ffff',
azure= '#f0ffff',
beige= '#f5f5dc',
black= '#000000',
blue= '#0000ff',
brown= '#a52a2a',
cyan= '#00ffff',
darkblue= '#00008b',
darkcyan= '#008b8b',