Skip to content

Instantly share code, notes, and snippets.

View Izzette's full-sized avatar
🌱
spring has sprung

Isabelle COWAN-BERGMAN Izzette

🌱
spring has sprung
View GitHub Profile
#include <stdio.h>
#include <assert.h>
#include <netdb.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@Izzette
Izzette / iloveyou.c
Created April 5, 2018 23:41
true == I<3U
// iloveyou.c
#include <stdio.h>
int main () {
for (unsigned int I = 0; I<3U; ++I)
puts("true == I<3U");
}
// vim: set ts=4 sw=4 noet syn=c:
@Izzette
Izzette / ring_buffer.c
Last active May 26, 2017 14:51
Lock-free ring-buffer for single reader/writer without atomic primitives.
// ring_buffer.c
// ring_buffer -- Trivial lock-free (wait-free) ring-buffer for use in
// single-reader/single-writer scenarios without using atomic primitives.
// Copyright (C) 2017 Isabell Cowan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
@Izzette
Izzette / blockstatd.py
Created February 19, 2017 06:38
Send Linux block device statistics to graphite
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# blockstatd.py
# The graphite-blockstat daemon
# graphite-blockstat -- Send Linux blockstat metrics to Graphite
# Copyright (c) 2017 Bodhi Digital LLC., Isabell Cowan
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@Izzette
Izzette / cryptpass.py
Created February 19, 2017 06:36
Create encrypted Unix password in Python
#!/usr/bin/env python
import string
from random import SystemRandom
from crypt import crypt
from getpass import getpass
def get_salt(saltlen):
copts = string.ascii_letters + string.digits
sysrand = SystemRandom()
@Izzette
Izzette / dhcp_dup_reservations.py
Last active February 25, 2017 00:33
Clone DHCP reservations to a secondary fallback server using the Foreman DHCP Smart Proxy API
#!/usr/bin/env python3
import json
from urllib.request import Request, urlopen
from sys import argv, stderr
def pp_json(data):
pretty_json = json.dumps(data, sort_keys=True, indent=2, separators=(",", ": "))
@Izzette
Izzette / calc_uptime.sh
Last active March 8, 2017 06:28
Calculate up time percentage using journalctl
#!/bin/bash
function get_stime() {
head -n 2 <<< "$1" | tail -n 1 | cut -d ' ' -f 1-3 | date --date="$(cat /dev/fd/0)" +%s
}
function get_etime() {
tail -n 1 <<< "$1" | cut -d ' ' -f 1-3 | date --date="$(cat /dev/fd/0)" +%s
}