Skip to content

Instantly share code, notes, and snippets.

View Linux-cpp-lisp's full-sized avatar

Alby M. Linux-cpp-lisp

View GitHub Profile
@Linux-cpp-lisp
Linux-cpp-lisp / torch-neighbors.py
Created April 15, 2022 02:45
translating ASE periodic neighborlist into TorchScript compatible PyTorch (MOSTLY UNTESTED)
# Author: https://gist.github.com/Linux-cpp-lisp
from typing import Tuple, List
import numpy as np
import torch
@torch.jit.script
def torch_divmod(a, b) -> Tuple[torch.Tensor, torch.Tensor]:
@Linux-cpp-lisp
Linux-cpp-lisp / diffusion.pyx
Created May 13, 2020 16:11
Finite-difference method for evolution under the heat equation (diffusion) with periodic boundary conditions (Cython)
# Finite-difference method from http://www.cosy.sbg.ac.at/events/parnum05/book/horak1.pdf
# Parallel Numerical Solution of 2-D Heat Equation, Verena Horak & Peter Gruber (Parallel Numerics ’05, 47-56)
@cython.boundscheck(False)
def diffuse(initial_condition, int nstep, double c = 1.0, double delta_t_factor = 0.5):
"""Evolve `initial_condition` according to the 2D heat (diffusion) equation under periodic boundary conditions."""
# Short circut
if nstep == 0:
return initial_condition
@Linux-cpp-lisp
Linux-cpp-lisp / spiral.md
Last active May 29, 2019 20:58
Flexible, configurable generation of natural numbers in a spiral

 Generate and print a spiral of natural numbers up to N with fully configurable shape and spacing.

Examples:

$ python3 spiral.py 50 square 2 
                                     
                                     
     32 31 30 29 28 27 26 25         
     33                   24         
@Linux-cpp-lisp
Linux-cpp-lisp / midi_translation_table.lua
Last active February 14, 2019 05:38
MIDI Node Mapping Plugin -- Ardour Lua DSP Script
ardour {
["type"] = "dsp",
name = "MIDI Remap Notes",
category = "Utility", -- "Utility"
license = "MIT",
author = "Alby Musaelian",
description = [[Map arbitrary MIDI notes to others. Affects Note On/Off and polyphonic key pressure.]]
}
N_REMAPINGS = 10
@Linux-cpp-lisp
Linux-cpp-lisp / boxes.py
Last active October 12, 2017 16:36
A memory-optimized algorithm for computing N(epsilon) when finding the capacity dimension of a dataset
#boxes.py: Compute N(epsilon) for the "box-counting" or capacity dimension of a data set.
# Alby Musaelian, 12/2016.
import numpy as np
import warnings
def memory_optimized_n_eps(traj,
eps,
memory_slot_limit=100*1024*1024,
@Linux-cpp-lisp
Linux-cpp-lisp / DTXPLORER MIDI Map.md
Last active June 15, 2023 00:16
MIDI behavior and notes for the Yamaha DTXPLORER drum trigger module.

MIDI Map for Yamaha DTXPLORER Drum Brain

Note: The DTXPLORER has some odd MIDI behaviour. For example, when a drum is triggered, a Note On is sent with the velocity, and moments later, another Note On is sent with a velocity of zero as some kind of note off.

MIDI Notes

Drum Pad MIDI Note
Snare 31
High Tom 48
@Linux-cpp-lisp
Linux-cpp-lisp / num_range_shrink.c
Created January 6, 2014 19:39
A little function to take a value in the range 0-x and convert them to values in a different, smaller range.
unsigned int num_range_shrink(unsigned int orig, unsigned int old_limit, unsigned int new_upper) {
float interval = old_limit / new_upper;
for(int i = 1; i <= new_upper; i++) {
if(orig < i*interval) {
return i-1;
}
}
return 0;
}
@Linux-cpp-lisp
Linux-cpp-lisp / gist:3861582
Created October 9, 2012 21:28
Some Basic HTML, CSS, and JavaScript
HTML:
<button id="b1" onclick="click()">Hi!</button>
JS:
function click() {
alert("Hi!");
}
@Linux-cpp-lisp
Linux-cpp-lisp / main.c
Created July 21, 2012 15:13
Basic C Hello world with stdio.
#include <stdio>
int main(int argv, char**argc) {
printf("Hello, world");
}
@Linux-cpp-lisp
Linux-cpp-lisp / gist:3011405
Created June 28, 2012 13:30
How to make Ruby class methods private
class Foo
class << self
private
def private_class_method; end
protected
def protected_class_method; end
end
end