Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
f="$(dirname $0)/log.txt"
if [ "$1" = "time" ]; then
last="$(cat "$f" | grep "# " | tail -n 1 | sed 's/^.*: //' | cut -d '-' -f 1)"
last=$(date +%s -d "$last")
now=$(date +%s)
diff=$(($now - $last))
@mortie
mortie / mrender
Created September 20, 2017 20:08
#!/bin/bash
#########################################################
## Uses mformat to format text, then feed it to pandoc ##
## to create a pdf. Displays the pdf with zathura if ##
## no output file is specified. ##
#########################################################
TMP=$(mktemp /tmp/mrender.XXXXXXXX.pdf)
DIR=$(pwd)
@mortie
mortie / lsdeps.sh
Created September 26, 2017 13:44
List all .so dependencies recursively
#!/bin/bash
list=""
lsd() {
if echo "$list" | grep -F "$1" >/dev/null; then
return
fi
list=$(printf "%s\n%s" "$list" "$1")
echo "$1"
@mortie
mortie / temp.py
Last active January 13, 2021 19:21
Color a phillips hue light according to your CPU temperature.
import wmi
import time
import phue
import os
hot = 70 # Celsius
cold = 60 # Celsius
timeout = 10
ip = "10.0.101.23"
#include <stdlib.h>
/*
* Defer an expression.
* This requires a block in an outer scope to have called defer_init,
* and the deferred statements will run once defer_run is called.
*/
#define defer(expr) \
do { \
__label__ _defer_label; \
#include "vector.h"
#include <stdio.h>
#include <snow/snow.h>
// Example program which will just put all strings in argv into a vector,
// then loop through and print the arguments
snow_main(int argc, char **argv) {
vector vec;
vector_init(&vec, sizeof(char *));
#!/usr/bin/env python3
###################
# <Configuration> #
###################
# Run 'command' while the temperature is less than 'maxTemp'.
maxTemp = 80 # Celsius
# When the temperature reached 'maxTemp', wait until it reaches 'minTemp'
#!/bin/bash
# Usage: remotedotool.sh [debug]
#
# Enter shell: Ctrl+Y
# All shell commands will be interpreted by your $SHELL, except for:
# * exit, x: Exit the remotedotool process
# * debug: Enable debug mode
# * nodebug: Disable debug mode
#
let fs = require("fs");
let graphviz = require("graphviz");
let graph = graphviz.digraph("G");
let colors = [
"aliceblue", "antiquewhite", "antiquewhite1", "antiquewhite2",
"antiquewhite4", "aquamarine", "aquamarine1", "aquamarine2",
"aquamarine4", "azure", "azure1", "azure2",
"azure4", "beige", "bisque", "bisque1",
@mortie
mortie / main.c
Last active September 10, 2018 21:27
#include "snow.h"
int (*mock_vector_free)(vector *vec);
int (*mock_vector_init)(vector *vec);
int vector_free(vector *vec) {
return mock_vector_free(vec);
}
int vector_init(vector *vec) {
return mock_vector_inti(vec);