Skip to content

Instantly share code, notes, and snippets.

@nkorth
nkorth / check_rpi_temperature
Created July 18, 2017 16:54
Nagios plugin to check core temperature of Raspberry Pi
#!/usr/bin/python2.7
import argparse
def get_temperature():
with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f:
return float(f.read()) / 1000.0
def celsius_to_fahrenheit(c):
return 32 + 1.8*c
@nkorth
nkorth / fetch.py
Last active December 9, 2020 02:56
KHInsider batch soundtrack downloader
from bs4 import BeautifulSoup
import os, requests, sys, urllib.parse
def get_landing_links(url):
r = requests.get(url)
r.raise_for_status()
html = BeautifulSoup(r.text, features="html.parser")
table = html.find("table", id="songlist")
links = []
for row in table.findAll("tr")[1:-1]:
@nkorth
nkorth / click.m
Created September 16, 2015 19:02
// File:
// click.m
//
// Found at:
// http://hints.macworld.com/article.php?story=2008051406323031
//
// Compile with:
// gcc -o click click.m -framework ApplicationServices -framework Foundation
//
// Usage:
@nkorth
nkorth / wave.c
Last active November 20, 2017 21:05
Wave generator
/*
* Wave generator
* by Nathan Korth
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
@nkorth
nkorth / mystify.htm
Created April 22, 2014 04:55
Mystify in 509 bytes
<!DOCTYPE html><canvas id="c"><script>var c=document.getElementById("c"),g=c.getContext("2d"),s=c.width=c.height=600,a=[],r=Math.random,v=["#f80","#0ff","#f5f"],f=function(){g.clearRect(0,0,s,s);if(a.length<12)a.push([r()*s,r()*s,r()*4-2,r()*4-2]);for(var i=0;i<a.length;i++){var j=a[i];if((i+1)%4==0){g.closePath();g.strokeStyle=v[(i-3)/4];g.stroke();g.beginPath();g.moveTo(j[0],j[1])}j[0]+=j[2];j[1]+=j[3];if(j[0]<1||j[0]>s)j[2]*=-1;if(j[1]<1||j[1]>s)j[3]*=-1;g.lineTo(j[0],j[1])}};setInterval(f,9)</script>