Skip to content

Instantly share code, notes, and snippets.

View V0XNIHILI's full-sized avatar
🎯
Focusing

Douwe den Blanken V0XNIHILI

🎯
Focusing
View GitHub Profile
@fayalalebrun
fayalalebrun / quantize_posit.py
Created March 2, 2024 07:13
Simulate posit quantization using JAX
import unittest
import jax
import jax.numpy as jnp
from functools import partial
def decompose(x: jnp.float32) -> tuple[jnp.int32, jnp.int32, jnp.int32]:
"""decomposes a float32 into negative, exponent, and significand"""
negative = x < 0
n = jnp.abs(x).view(jnp.int32)
exponent = (n >> 23) - 127
@fgolemo
fgolemo / autobot_omniglot.ipynb
Created March 1, 2022 22:28
Omniglot toy example for Autobots: Latent Variable Sequential Set Transformers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@urbanij
urbanij / gtkwave_macOS_cli_instructions.md
Created November 26, 2021 21:05
Invoke gtkwave from CLI on macOS (Catalina)

GTKWave from CLI on macOS (Catalina)

based on this article https://ughe.github.io/2018/11/06/gtkwave-osx (which does not work for me, as is)

  • Motivation

While installing and running GTKWave is straightforward on macOS, it is slightly more difficult to get the command line tool running properly:

$ /Applications/gtkwave.app/Contents/Resources/bin/gtkwave
Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.4 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at /Applications/gtkwave.app/Contents/Resources/bin/gtkwave line 2.
@jonatasrenan
jonatasrenan / python-json-types.py
Created June 12, 2021 01:43
A comparison between python's dict libraries to read and write naturally as a JSON parsing.
"""
A comparison between python's dict libraries to read and write naturally as a JSON parsing.
Based on: https://gist.github.com/NelsonMinar/28c5928adbe1f4502af8
Installation:
pip install pypi-search addict easydict attrdict dotted-dict dotmap munch python-box
"""
from typing import Any
@vadimkantorov
vadimkantorov / sincconv.py
Last active September 26, 2023 21:49
Sinc convolution module in PyTorch (adapted and simplified from the original SincNet codebase)
# Sinc learned filter banks were proposed in "Speaker Recognition from raw waveform with SincNet", Ravanelli and Bengio, http://arxiv.org/abs/1808.00158
# Code is simplified and adapted from https://github.com/mravanelli/SincNet/blob/master/dnn_models.py
import math
import torch
class SincConv1d(torch.nn.Conv1d):
def __init__(self, in_channels, out_channels, kernel_size, stride = 1, padding = 0, dilation = 1, groups = 1, bias = False, padding_mode = 'zeros', sample_rate = 16_000, min_low_hz = 50, min_band_hz = 50, low_hz = 30):
assert in_channels == 1 and kernel_size % 2 == 1 and bias is False and groups == 1
super().__init__(in_channels, out_channels, kernel_size, stride = stride, padding = padding, dilation = dilation, groups = groups, bias = bias, padding_mode = padding_mode)
/* ESP32-S2 (beta) "dedicated GPIO" peripheral example */
#include <stdio.h>
#include "sdkconfig.h"
#include "soc/system_reg.h"
#include "esp32s2beta/rom/gpio.h"
#include "soc/gpio_sig_map.h"
#include "driver/gpio.h"
/* The header file is not yet in IDF; however this is the only register we need. */
@ayyybe
ayyybe / ccdl.command
Last active May 20, 2024 22:48
Adobe Offline Package Builder v0.1.2 (macOS only) --- No longer being maintained.
#!/bin/bash
CYAN="$(tput bold; tput setaf 6)"
RESET="$(tput sgr0)"
clear
if command -v python3 > /dev/null 2>&1; then
if [ $(python3 -c "print('ye')") = "ye" ]; then
clear
@slikts
slikts / advanced-memo.md
Last active April 27, 2024 02:40
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@JiamingSuen
JiamingSuen / ray_caster.py
Created October 15, 2019 06:38
Ray casting in python with Trimesh and pyembree
"""
Adapted from trimesh example raytrace.py
----------------
Install `pyembree` for a speedup (600k+ rays per second)
"""
import PIL.Image
import trimesh
import numpy as np
from typing import List
@rotu
rotu / CMakeLists.txt
Last active May 2, 2024 23:20
CLion top level ROS2 Workspace CMakeLists
cmake_minimum_required(VERSION 3.14)
project("ROS2 Master")
# usually I put this in a separate file include("/opt/ros/_common/Colcon.cmake")
function(colcon_add_subdirectories)
cmake_parse_arguments(PARSE_ARGV 0 "ARG" "" "BUILD_BASE;BASE_PATHS" "")
message("search criteria: ${ARGV}")
execute_process(COMMAND colcon list