Skip to content

Instantly share code, notes, and snippets.

@dstein64
dstein64 / scrollview-gitsigns.lua
Last active June 3, 2023 03:32
Sample code showing how to add gitsigns support to nvim-scrollview
local api = vim.api
local scrollview = require('scrollview')
local group = 'gitsigns'
local add = scrollview.register_sign_spec({
group = group,
highlight = 'GitSignsAdd',
symbol = ' ',
}).name
/*** echo.s ***/
// Description
// echo - print arguments to stdout
// Synopsis
// echo [STRING]...
// Build
// $ as --32 -o echo.o echo.s
// $ ld -m elf_i386 -o echo echo.o
@dstein64
dstein64 / gpu_avail.py
Created April 8, 2022 17:52
Display a table of GPU availability on a Slurm server.
#!/usr/bin/env python3
"""
Display a table of GPU availability on a Slurm server.
Usage:
$ scontrol -M gpu show node | gpu_avail.py
"""
import sys
# fails to properly return true when running sudo -s
function is_ssh_from_env() {
if [ -n "${SSH_TTY}" ] || \
[ -n "${SSH_CONNECTION}" ] || \
[ -n "${SSH_CLIENT}" ]; then
echo "true"
else
echo "false"
fi
}
@dstein64
dstein64 / bezier_neural_walk.py
Last active March 7, 2021 13:19
Random Bézier Walk in a Random Neural Network
#!/usr/bin/env python
from __future__ import print_function
# Images can be converted to video with ffmpeg.
# > ffmpeg -pattern_type glob \
# -i "*.png" \
# -vcodec libx264 \
# output.avi
from distutils.spawn import find_executable
import glob
import os
import random
import shutil
import subprocess
import sys
STYLE_IMAGES_PATH = 'paint-by-numbers/test'
CONTENT_IMAGE_PATH = 'boston.jpg'
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include "revdoor.hpp"
using namespace std;
@dstein64
dstein64 / scrollview_hide.vim
Last active December 24, 2020 03:13
An example script for hiding nvim-scrollview scrollbars shortly after scrolling
" The amount of time, in milliseconds, until scrollbar hides after scrolling.
let s:hide_delay = 800
" Time of the last WinScrolled event
let s:scroll_time = 0
" Keep track of pending updates. Ignore updates if there are already pending
" updates, to prevent lag.
let s:pending = 0
@dstein64
dstein64 / Anagrams.java
Last active October 29, 2020 17:09
Example code for a Stack Overflow comment: https://stackoverflow.com/a/64549281/1509433
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Anagrams {
public static List<String> anagrams(String s) {
List<String> output = new ArrayList<String>();
if (s.length() == 0)
return output;
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>
#include <unordered_map>
using namespace std;
typedef unsigned long ulong;