Skip to content

Instantly share code, notes, and snippets.

Verifying that +quasimondo is my openname (Bitcoin username). https://onename.io/quasimondo
@Quasimondo
Quasimondo / parseafpk.py
Created August 10, 2017 09:35
Parse *.afpk file and extract peaks, landmarks and hashes
import struct
import numpy as np
def afpk2peaks(peakfilename):
PEAK_FMT = '<2i'
PEAK_MAGIC = 'audfprintpeakV00' # 16 chars, FWIW
""" Read back a set of (time, bin) pairs written by peaks_save """
peaks = []
fmtsize = struct.calcsize(PEAK_FMT)
import os
import numpy as np
import threading
from imageio import imwrite,imread
from scipy.ndimage import zoom
class Corona():
def __init__(self):
self.infectionProbability = 0.02
self.lethalProbability = 0.02
import numpy as np
import cv2
import time
import torch
import torch.nn.functional as F
kernel = np.ones((41, 41) ).astype(np.float32)
cv_input = (np.random.random(size=(500,500))>0).astype(np.float32)
kernel_tensor = torch.Tensor(kernel).cuda().unsqueeze(0).unsqueeze(0)
@Quasimondo
Quasimondo / LeakySine.py
Last active December 26, 2020 14:08
A self-adjusting blend between Sine and LeakyRelu activation. No idea if this makes any sense.
import torch
import torch.nn as nn
import torch.nn.functional as F
class LeakySine(nn.Module):
def __init__(self, w0 =30.0, blend=0.75, slope = 0.2):
super().__init__()
self.blend = nn.Parameter(torch.ones(1, 1)*blend)
self.slope = nn.Parameter(torch.zeros(1, 1)+slope)
self.w0 = w0
'''
Usage:
python quickwatermark.py [path to folder that contains images to waternark]
This will go through all the files in that folder, try to open them and add
the filename as text on top of the image. The watermarked images will be stored
in a subfolder of the chosen folder called "watermarked"
'''
@Quasimondo
Quasimondo / hic_et_nunc_get_all_token_data.py
Created April 2, 2021 12:03
Some basic code to retrieve hic et nunc token data from better-call.dev
import os
import pickle
import requests
#download cached token data here:
#https://drive.google.com/file/d/1g_4w_Re5Y0NmcS2Y55WQzESWDeL2dey6/view?usp=sharing
#and put it into the same folder as this file
cachedTokenData = {"maxTokenID":-1,"knownTokenIds":{},"data":[]}
if os.path.exists("cached_token_data.pickle"):
@Quasimondo
Quasimondo / hic_et_nunc_basic_scraper.py
Created March 10, 2021 11:23
This is a very basic no-frills scraper to retrieve the metadata and digital assets from all tokens minted on hicetnunc.xyz. I share this as a starting point for people who want to experiment with building alternative views on the works created on the platform or preserve the data. Feel free to improve upon this or add additional features.
import requests
import os
import ipfsApi
api = ipfsApi.Client(host='https://ipfs.infura.io', port=5001)
url = "https://better-call.dev/v1/contract/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton/tokens"
r = requests.get(url)
data = r.json()
40,5.770906432748538
78,5.923830409356725
83,7.939619883040936
87,5.833187134502924
118,5.39122807017544
125,5.565643274853802
196,7.127046783625732
200,5.97953216374269
250,5.631140350877193
254,7.2331871345029235
I am attesting that this GitHub handle quasimondo is linked to the Tezos account tz1hb9PiWxQEf6J9xevPsUM6dkuCLnhDMvsp for tzprofiles
sig:edsigtoekSaBkHWoVT4WcedEWrgHS2jfG1tsaqUGH3o9ULoFn8yzEMsAa7JsZbXwu4iKPepv98hKX2QSwi1KMkn1YX8B3tSC4be