Skip to content

Instantly share code, notes, and snippets.

@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 $@"
@ityonemo
ityonemo / expressive.jl
Last active October 26, 2017 01:42
expressive C++17 in Julia
(length(ARGS) < 4) && (println("error, insufficient arguments"); exit(1))
infile, column, replace, outfile = ARGS
function replace_column(idx)
(idx == 0) && (println("column name doesn’t exist in the input file"); exit(1))
mtx2 = copy(mtx)
mtx2[2:end,idx] = collect(Iterators.repeated(replace,size(mtx,1) - 1))
mtx2
@ityonemo
ityonemo / find first free
Created October 18, 2017 03:08
find_first_free.ex
defmodule T do
def find_first_free(arr), do: find_first_free(arr, 0, [])
def find_first_free([], lowest_free, _leftovers), do: lowest_free
def find_first_free([head | tail], lowest_free, leftovers) do
if (lowest_free == head) do
find_first_free(tail, lowest_free + 1, leftovers)
else
find_first_free(tail, lowest_free, [head | leftovers])
end
end
@ityonemo
ityonemo / algebra.jl
Last active October 9, 2017 16:29
AST-fun with julia
function simplify(e::Expr)
if e.head == :call
if e.args[1] == :+
simplify_add(e)
end
end
end
function simplify_add(e::Expr)
terms = Dict{Symbol, Int}()