Skip to content

Instantly share code, notes, and snippets.

@ityonemo
ityonemo / res_net_block.py
Last active January 20, 2021 03:17
Testing ResNet Components
import torch
import torch.nn as nn
class ResNetBlock(nn.Module):
def __init__(self, input_channel_count, internal_channel_count, downsampler = None, stride=1, layers = 'all'):
# input_channel_count: An image tensor is a h*w*k tensor where k is represents
# how many channels, naively, groups of features discovered by the ml model.
# the shape of the input tensor is h*w*input_channel.
# internal_channel_count: like above, but the shape of the output tensor is
# h*w*internal_channel_count. In a typical convnet strategy, you will want the
@ityonemo
ityonemo / test.md
Last active April 2, 2025 19:48
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@ityonemo
ityonemo / algebra.zig
Last active January 4, 2021 13:54
Strategy for composable Algebra in Zig
const std = @import("std");
pub fn Algebra(comptime fields: []const type) type {
return struct{
pub fn @"<+>"(a: anytype, b: anytype) FieldFor(@TypeOf(a), @TypeOf(b)).Type {
const F: type = FieldFor(@TypeOf(a), @TypeOf(b));
return F.@"<+>"(a, b);
}
pub fn FieldFor(comptime AType: type, comptime BType: type) type {
@ityonemo
ityonemo / awaiting_resumed.zig
Created December 6, 2020 00:41
awaiting resumed ??? example
const std = @import("std");
const print = std.debug.print;
var yielded = false;
fn yield() void {
yielded = true;
suspend;
}
@ityonemo
ityonemo / lisp.ex
Created September 20, 2020 06:41
Lisp in Elixir
defmodule Lisp do
@type ast :: [String.t | number | ast]
@type token :: :lp | :rp | number | String.t
@letters Enum.concat(?a..?z, ?A..?Z)
@numbers ?0..?9
@operators [?+]
@doc """
@ityonemo
ityonemo / gromacs.md
Last active July 30, 2020 19:40
gromacs installation on lambda v100

Gromacs on Lambda V100 nodes

Installation

  1. Install singularity
sudo apt-get update && sudo apt-get install -y build-essential libssl-dev uuid-dev \
  libgpgme11-dev squashfs-tools libseccomp-dev wget pkg-config git cryptsetup
@ityonemo
ityonemo / itinerary.jl
Created June 30, 2020 16:10
itinerary code
using JSON
#make sure we have what we're looking for.
(length(ARGS) == 0) && throw(ErrorException("needs a file name"))
###################################
#rows iterator
type rows; tgt::Matrix; end
Base.start(r::rows) = 1
Base.next(r::rows, idx) = (r.tgt[idx, :], idx + 1)
Base.done(r::rows, idx) = idx > size(r.tgt, 1)
@ityonemo
ityonemo / nbody-zig.zig
Last active June 17, 2020 02:40
benchmarks game: zig
//! The Computer Language Benchmarks Game
//! https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
//!
//! This implementation is written in simple and idiomatic Zig.
//! The only optimization is using SIMD vector intrinsics.
const std = @import("std");
/////////////////////////////////////////////////////////////////////////
// important constants. ALLCAPS constants are not idiomatic Zig, but it's
{
"Inspect": {
"prefix": "ins",
"body": "|> IO.inspect(label: \"$0$TM_LINE_NUMBER\")",
"description": "Adds a pipeline with a labelled `IO.inspect`",
}
}
@ityonemo
ityonemo / gist:4036b50fff8dcf373872440d3eee122b
Created May 22, 2020 22:19
make-podman-like-singularity
#!/bin/sh
IMAGE=<your image id>
CMD=<your cmd>
podman run --net host -v $HOME:$HOME -e HOME="$HOME" -w$(PWD) -it $IMAGE "$CMD $@"