Skip to content

Instantly share code, notes, and snippets.

View jwscook's full-sized avatar

James Cook jwscook

View GitHub Profile
@huytd
huytd / wordle.md
Last active March 17, 2024 20:51
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@gramian
gramian / build_oct.sh
Last active January 5, 2023 14:37
Build Octave and numerical dependencies from source in Ubuntu 20.04
#!/bin/bash
# project: build_oct
# version: 1.12 (2023-01-01)
# authors: C. Himpe (0000-0003-2194-6754), M. Koehler (0000-0003-2338-9904)
# license: BSD-2-Clause License (opensource.org/licenses/BSD-2-Clause)
# summary: Build Octave and numerical dependencies from source (in Ubuntu 20.04 with GCC >= 10.3).
# requires hardware: either X86-64 with AVX2 or ARM64 with NEON.
# requires software packages: octave libpcre2-dev libreadline-dev libgmp3-dev libmpfr-dev libfreetype6-dev libgl2ps-dev libfontconfig1-dev libglu1-mesa-dev
@Luthaf
Luthaf / build.jl
Last active January 3, 2023 01:21
Using pip to install python dependencies for Julia.
using PyCall
# Change that to whatever packages you need.
const PACKAGES = ["pyyaml"]
# Import pip
try
@pyimport pip
catch
# If it is not found, install it
using Cassette, ReplMaker
Cassette.@context NoNaN
nonnan(s, x::Number) = (@assert(!isnan(x), string(s, " returned NaN")); x)
nonnan(s, A::AbstractArray) = (foreach(x->nonnan(s, x), A); A)
nonnan(s, x) = x
Cassette.overdub(::NoNaN, f, args...) = nonnan("$f$args", f(args...))
# Here I store more data as I go,
# which I could use to plot figures comparing methods
# the convergence speed of different methods
# I use the Rosenbrock classic example and
# Optim.jl as an iterative process which will
# call f multiple times to find its minimum
# and I plot the convergence vs time
using Optim, Cassette
@Roger-luo
Roger-luo / hoist.jl
Created August 16, 2019 20:39
Alloc.jl in Cassette
module HoistMem
export hoist_alloc, Buffer
using Cassette, LinearAlgebra
using Cassette: @context, overdub
@context BuffCtx
mutable struct Buffer
using Cassette, Test
using Cassette: @context, enabletagging, @overdub, overdub, recurse,
hasmetadata, metadata, tag, untag
using ChainRules: frule, Zero, extern
@context DiffCtx
Cassette.metadatatype(::Type{<:DiffCtx}, ::Type{T}) where {T<:Real} = T
function D(f, x)
@JeffreySarnoff
JeffreySarnoff / expmatrix.jl
Last active April 8, 2019 07:35
ArbNumerics supports `exp(matrix)`
#=
These examples use ArbNumerics v0.4.4, no earlier version supports `exp(matrix)`.
So, either first do `pkg> up` or do `pkg> rm ArbNumerics` then `pkg> add ArbNumerics`.
Sometimes, rebuilding with `pkg> build ArbNumerics` cleans up after itself.
All the matrix handling is new code, the examples here are working as of now.
If you find anything unclear or something awry, post an issue and
please use slack's direct message to draw my attention.
=#
#=