Skip to content

Instantly share code, notes, and snippets.

@CoryKornowicz
CoryKornowicz / main.py
Created December 2, 2025 10:43
MLX - Intelligent Matrix Exponentiation
import mlx.core as mx
import mlx.nn as nn
import mlx.optimizers as optim
from mlx.data.datasets import load_mnist
@mx.compile
def matrix_exp(M):
"""
Compute matrix exponential using scaling and squaring with Padé approximation.
This implements a simplified version suitable for small matrices.
@TAATHub
TAATHub / ChipsSelection.swift
Last active April 17, 2025 18:21
Responsive Chips Selection
// Responsive Chips Selection
// See Also: https://youtu.be/T82izB2XBMA?si=Cnf6rGdyisG8ZWoX
import SwiftUI
struct Tag: Hashable {
var name: String
var color: Color
}
@komakai
komakai / add.metal
Created December 13, 2024 03:43
Metal compute shader swift
kernel void add_arrays(device const float* inA [[buffer(0)]],
device const float* inB [[buffer(1)]],
device float* result [[buffer(2)]],
uint index [[thread_position_in_grid]])
{
result[index] = inA[index] + inB[index];
}
@matthen
matthen / hello_world.py
Last active November 25, 2024 21:51
Hello world in python, using genetic algorithm
"""Hello world, with a genetic algorithm.
https://twitter.com/matthen2/status/1769368467067621791
"""
import random
import time
from dataclasses import dataclass
from itertools import chain
from typing import Iterable, List
@realvjy
realvjy / ChoasLinesShader.metal
Last active February 17, 2026 04:33
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
@HadrienG2
HadrienG2 / High_Performance_Rust.md
Last active November 13, 2025 22:30
Making Rust a perfect fit for high-performance computations

Hello, Rust community!

My name is Hadrien and I am a software performance engineer in a particle physics lab. My daily job is to figure out ways to make scientific software use hardware more efficiently without sacrificing its correctness, primarily by adapting old-ish codebases to the changes that occured in the software and computing landscape since the days where they were designed:

  • CPU clock rates and instruction-level parallelism stopped going up, so optimizing code is now more important.
  • Multi-core CPUs went from an exotic niche to a cheap commodity, so parallelism is not optional anymore.
  • Core counts grow faster than RAM prices go down, so multi-processing is not enough anymore.
  • SIMD vectors become wider and wider, so vectorization is not a gimmick anymore.
@PatWalters
PatWalters / split_complex_v2.py
Created October 2, 2018 01:20
An improved script to extract a ligand from a protein-ligand complex and assign bond orders
#!/usr/bin/env python
import sys
from prody import *
from rdkit import Chem
from rdkit.Chem import AllChem
from io import StringIO
import pypdb
@GeauxEric
GeauxEric / dockedpose.py
Last active February 7, 2022 03:46 — forked from baoilleach/dockedpose.py
Using Open Babel to calculate the symmetry-corrected RMSD of a docked pose from a crystal structure
import math
import pybel
def squared_distance(coordsA, coordsB):
"""Find the squared distance between two 3-tuples"""
sqrdist = sum((a - b)**2 for a, b in zip(coordsA, coordsB))
return sqrdist
@platinhom
platinhom / 0-AmberScripts.md
Last active February 8, 2024 02:24
Some scripts for Amber

This gist contains some scripts for Amber.

  • anteligand.sh: Use antechamber to prepare a ligand for Amber
  • complex_tleap.sh: Use tleap to prepare a ligand-protein complex input parameter file (Amber14)
  • checkPDBID_MDprep.sh: After running many preparation jobs for PDB ligand-protein complexes, you should check whether the preparation is done.
  • rename_water.py: rename water to HOH O,H1,H2 for PDB/PQR

Maybe need some other tools installed, such as pdb2pqr and g09 and so on.