Skip to content

Instantly share code, notes, and snippets.

@barak
barak / find-gpu
Last active March 4, 2022 16:02
use nvidia-smi to find available GPU(s)
#! /bin/bash -f
set -e
k=1
s=1
function usage() {
echo "find-gpu [K [SECS]]"
echo " Prints the indices of the K (default: ${k}) least-used"
echo " GPUs, as a comma-separated list. Symmetries broken"
@barak
barak / zoom-up
Created December 17, 2020 20:40
Shell script to check and possibly upgrade zoom package under Debian or derivative GNU/Linux distribution
#!/usr/bin/bash
# Check available version and upgrade zoom if possible.
set -f
set -u
set -e
if [ $# != 0 ]; then
echo "Download and install zoom package. Abort if it does not supersede currently installed version."
(ns newton-raphson.core)
;;utility function for list manipulation
(defn keep-list [expr]
(if (and (coll? expr) (not (= 1 (count expr)))) (list expr) expr))
(defn to-list [expr]
(cond (list? expr) expr
(coll? expr) (seq expr)
@barak
barak / suffix-primes.hs
Last active December 25, 2020 22:56
suffix primes in haskell
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE ParallelListComp #-}
{-# LANGUAGE BangPatterns #-}
-- A suffix prime is a prime number all of whose suffixes are also
-- prime. No zero digits allowed. Here we find all, in a given base.
import Prelude.Unicode
import Data.List (intersperse, foldl')
@barak
barak / csu-netlogin.sh
Created August 7, 2012 08:28
Trivial script to log in to Colorado State University (CSU) guest WiFi system instead of manual laborious form filling.
#! /bin/sh
set -e
# Set these appropriately. I had two, so I made a way to get either. You probably only need one.
case "${1}" in
d*)
user="vpsa22638"
password="A34ks52f"
;;