Skip to content

Instantly share code, notes, and snippets.

View originalsouth's full-sized avatar
🐺

originalsouth

🐺
View GitHub Profile
@originalsouth
originalsouth / Makefile
Created October 11, 2019 13:14
Emscripten bug
OPTLEVEL=3
bug.js: bug.c
emcc -Wall -Wextra -flto -O$(OPTLEVEL) -s ENVIRONMENT=worker -o $@ $<
clean:
-rm -rf bug.js bug.wasm
@originalsouth
originalsouth / pdf2websvg.zsh
Last active July 27, 2019 11:42
pdf2websvg.zsh: mobile browsers do not support rendering PDFs but they do render SVGs so why not convert? (Oy! think about the bandwidth; httpd compression?)
#!/usr/bin/env zsh
function convert
{
PDF=$1
FNAME=$(echo $PDF | cut -d\. -f1)
OUTPUT=$(echo $FNAME.svg)
PAGES=$(pdftk $PDF dump_data | grep NumberOfPages| awk '{print $2}')
for i in $(seq 1 $PAGES)
do
pdf2svg $PDF $FNAME-$i.svg $i
@originalsouth
originalsouth / alacritty.yml
Last active November 14, 2024 09:34
alacritty.yml
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
#env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
@originalsouth
originalsouth / boggle.cc
Created August 7, 2018 11:59
Volitile fun in C++
#include <cstdio>
#include <cstdlib>
template<class X> void boggle(X _)
{
printf("%d:%d:%d\n",_,++_*_++,_);
}
int main()
{
@originalsouth
originalsouth / average.awk
Created March 22, 2018 13:27
Takes the averages of multiple csv files (using gawk)
#!/bin/gawk -f
BEGIN{
FS=";"
}
{
if($0 ~ /^[[:space:]]*#/) {FNR--}
for(i=1;i<=NF;i++) buf[ARGIND][i][FNR]=$i
}
END{
for(k=1;k<=FNR;k++)
@originalsouth
originalsouth / splitter.cc
Last active February 19, 2018 10:38
Split a delimited string into a vector of strings and apply a search and replace all on it
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
using namespace std;
vector<string> splitter(const string &input,char delim=',')
{
vector<string> retval;
@originalsouth
originalsouth / htoprc
Created November 20, 2017 07:13
Configuration file for htop
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
fields=3 0 48 17 18 38 39 40 2 37 46 47 49 109 110 1
sort_key=46
sort_direction=1
hide_threads=0
hide_kernel_threads=0
hide_userland_threads=0
shadow_other_users=1
show_thread_names=0
#!/usr/bin/env python2
import numpy as np
x,y,z,Ek=np.loadtxt('hist.dat',delimiter=';',usecols=(0,1,2,3),unpack=True)
from enthought.mayavi import mlab
mlab.options.offscreen=True
mlab.figure(1,fgcolor=(0,0,0),bgcolor=(1,1,1),size=(1280,1024))
pts=mlab.points3d(x,y,z,Ek,scale_mode='none',scale_factor=0.0)
mesh=mlab.pipeline.delaunay2d(pts)
surf=mlab.pipeline.surface(mesh,colormap='jet')
mlab.colorbar(orientation='vertical')
@originalsouth
originalsouth / barflood.zsh
Created August 6, 2017 16:56
Flood the main bar screen at SHA2017 with a monochrome image
#!/usr/bin/env zsh
DATA=$(for point in $(convert $1 txt: | grep black | cut -d":" -f 1 );do echo "PX $point 000000" | sed 's/,/ /'; done)
yes $DATA | pv | netcat barflood.sha2017.org 2342
@originalsouth
originalsouth / LaTeX-Makefile
Last active July 31, 2017 11:23
Generic LaTeX project Makefile
file.pdf: file.tex
-@latexmk -logfilewarninglist -use-make -pdf -norc -f -latexoption=-shell-escape -interaction=nonstopmode file.tex
@echo " "
rubber-info --check file.tex
@echo " "
rubber-info --boxes file.tex
-@pdftotext file.pdf - | wc
@date
cp: file.pdf