Skip to content

Instantly share code, notes, and snippets.

@carlfriess
carlfriess / bitmap.h
Created October 3, 2022 22:05
Simple bitmap data structure
#ifndef BITMAP_H
#define BITMAP_H
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
typedef uint32_t bitmap_t;
@carlfriess
carlfriess / pushover-countdown.js
Last active July 31, 2022 19:14
Sends countdown notifications via Pushover (usage example: `./pushover-countdown.js ./z-events.json`).
#!/usr/bin/env node
const https = require("https");
const config = require(process.argv[2]);
function durationString(target) {
const msPerMinute = 60 * 1000;
const msPerHour = msPerMinute * 60;
const msPerDay = msPerHour * 24;
@carlfriess
carlfriess / monitor.sh
Created March 31, 2022 23:15
Monitors a web page and sends a Pushover notification if it changes.
#!/bin/bash
# monitor.sh - Monitors a web page for changes
# sends a Pushover notification if it changes
if [[ $# -ne 3 ]]; then
echo "Usage: $0 <url> <token> <user>" >&2
exit 2
fi
@carlfriess
carlfriess / DPHPC-HW1.c
Last active October 18, 2021 15:55
DPHPC Homework 1
#include <mpi.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SIZEX 2000
#define SIZEY 2000
#define IDX(a, x, y) a[(x) + (y) * (size_x + 2)]
@carlfriess
carlfriess / ISL-module-02-tips.py
Last active October 14, 2021 13:52
Tips and tricks to help you with module 02 of Information Security Lab
# Encoding and parsing integers
# https://docs.python.org/3/library/stdtypes.html#int.to_bytes
# https://docs.python.org/3/library/stdtypes.html#int.from_bytes
bytes = (42).to_bytes(2, 'big') # 16-bit integer, big-endian
num = int.from_bytes(bytes, 'big') # Notice: length is implicit
# Encoding and parsing strings
# https://www.programiz.com/python-programming/methods/string/encode
bytes = "Hello, World!".encode()
string = b"Hello, World!".decode()
@carlfriess
carlfriess / AOS.css
Created March 3, 2021 15:00
A beautiful Markdown CSS Theme for scientific documents
html, body {
padding: 2.5em;
margin: auto;
max-width: 48em;
}
body {
font: 0.8em Palatino, Times;
color: #333;
line-height: 1.3;
@carlfriess
carlfriess / SPCA-assignment3-cheatsheet.c
Last active October 11, 2017 12:09
SPCA: Cheatsheet for Assignment 3
/*
* =================================
* SPCA: Cheatsheet for Assignment 3
* Carl Friess
* =================================
*/
// Reading arguments
// Example: $ nano myfile.txt
@carlfriess
carlfriess / subtitles.js
Created April 10, 2016 17:41
Node.js script to add a subtitles track to a mp4 from an srt file.
#!/usr/local/bin/node
const readline = require('readline');
var exec = require('child_process').exec;
var path = require('path');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
@carlfriess
carlfriess / update.js
Last active January 24, 2016 02:10
Function to update javascript object with contents of another object
function update(obj) {
for (var i=1; i<arguments.length; i++) {
for (var prop in arguments[i]) {
var val = arguments[i][prop];
if (Object.prototype.toString.call(val) === '[object Array]') { //Array
obj[prop] = [];
update(obj[prop], val);
}
else if (typeof val == 'object' && !(val instanceof Date) && val != null) { //Object
if (typeof obj[prop] != 'object' || obj[prop] == null) {