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 / 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)
@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 / 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 / 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 / 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 / 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 / ecs.py
Created May 14, 2020 14:42 — forked from schlarpc/ecs.py
from troposphere import \
AWSHelperFn, Base64, Cidr, Condition, Equals, GetAtt, Join, Not, Output, Parameter, Ref, \
Region, Select, Split, StackName, Sub, Tags, Template
from troposphere.autoscaling import \
AutoScalingGroup, LaunchTemplateSpecification, LifecycleHookSpecification
from troposphere.awslambda import \
Code, Function, Permission
from troposphere.ec2 import \
CreditSpecification, IamInstanceProfile, InternetGateway, LaunchTemplate, LaunchTemplateData, \
Route, RouteTable, SecurityGroup, SecurityGroupRule, Subnet, SubnetRouteTableAssociation, VPC, \
@delijati
delijati / cfn_run.sh
Created May 14, 2020 09:52 — forked from gcchaan/cfn_run.sh
troposphere runner
#!/bin/bash
# https://gist.github.com/gcchaan/ad8fd83a68467503ec3e6392ebbd519a
set -ef -o pipefail
function message(){
echo 🍣 "$1"
}
function help(){
@delijati
delijati / Dockerrun.aws.json.template
Created July 24, 2019 14:36 — forked from mool/Dockerrun.aws.json.template
Elastic Beanstalk deploy
{
"AWSEBDockerrunVersion": "1",
"Authentication": {
"Bucket": "bucket_name",
"Key": "docker/dockercfg"
},
"Image": {
"Name": "company/<image>"
},
"Ports": [
@delijati
delijati / dump.py
Last active April 17, 2019 15:14
dump all models when load sqlalchemy
import os
import json
import hashlib
import datetime
from database import db
from sqlalchemy import event
def literal_sql(context):