Skip to content

Instantly share code, notes, and snippets.

View delijati's full-sized avatar

Josip Delić delijati

  • Potsdam (Berlin)
View GitHub Profile
@delijati
delijati / ec2-fingerprint-key
Created May 29, 2020 09:31 — forked from jtriley/ec2-fingerprint-key
Simple Python script that computes both public and private RSA key fingerprints as used by Amazon EC2
#!/usr/bin/env python
import hashlib
import optparse
import paramiko
from Crypto.PublicKey import RSA
def insert_char_every_n_chars(string, char='\n', every=64):
return char.join(
@delijati
delijati / structlog_render_level_in_uppercase.py
Last active September 14, 2020 10:44 — forked from mauler/structlog_render_level_in_uppercase.py
Renders log entry level in uppercase when using structlog library
import structlog
def _add_log_level_upper(logger, method_name, event_dict):
event_dict["level"] = method_name.upper()[0]
return event_dict
level_styles = structlog.dev.ConsoleRenderer.get_default_level_styles()
new_styles = {}
@delijati
delijati / h5.py
Created December 7, 2021 13:00
Safe metadata and multiple datasets
import numpy as np
import h5py
SIZE = 500000
with h5py.File("test.hdf", "w") as f:
f["first"] = np.random.random(SIZE)
f["first"].attrs["git id"] = "yay this is a string"
f["second"] = np.random.random(SIZE)
f["second"].attrs["git id"] = "yay this is a string"
@delijati
delijati / savez.py
Created December 7, 2021 13:01
Safe metadata and multiple datasets (pure numpy basiclly pickle)
import numpy as np
SIZE = 500000
meta = {}
first = np.random.random(SIZE)
meta["first"] = {"git id": "yay this is a string"}
second = np.random.random(SIZE)
meta["second"] = {"git id": "yay this is a string"}
third = np.random.random(SIZE)
@delijati
delijati / bio
Created March 24, 2022 13:08
bio
function bionifyPage(){
function bionifyWord(word) {
if (word.length == 1) {
return word;
}
var numBold = Math.ceil(word.length * 0.3);
// return "<div class=\"bionic-highlight\">" + word.slice(0, numBold) + "</div>" + + "<div class=\"bionic-rest\">" + word.slice(numBold) + "</div>";
return "<b>" + word.slice(0, numBold) + "</b>" + "<span>" + word.slice(numBold) + "</span>";
}
@delijati
delijati / hw.cpp
Created November 22, 2022 12:21
cuDNN on manjaro
#include <iostream>
#include <cuda_runtime.h>
#include <cudnn.h>
/**
* Minimal example to apply sigmoid activation on a tensor
* using cuDNN.
**/
int main(int argc, char** argv)