Skip to content

Instantly share code, notes, and snippets.

View kumo's full-sized avatar

Robert Clarke kumo

View GitHub Profile
@kumo
kumo / monitor.rb
Created December 9, 2020 22:00
Ruby version of a simple monitoring web app
require 'sinatra'
get '/hello' do
# Update the 'last modified' time of a specific file to the current time
FileUtils.touch('status')
"Hello to you too!"
end
get '/check/:minutes' do |minutes|
@kumo
kumo / monitor.py
Last active December 9, 2020 21:05
Python version of a simple monitoring web app
#!/usr/bin/env python3
import os
import time
from pathlib import Path
import telegram_send
from bottle import Bottle, route, run
@kumo
kumo / monitor.rs
Last active December 14, 2020 21:44
Rust version of a simple monitoring web app
use actix_web::{get, web, App, HttpResponse, HttpServer, Responder};
use std::fs;
use std::time::SystemTime;
use std::env;
use dotenv::dotenv;
// This struct represents state
struct AppState {
token: String,
alert_chat_id: i32,
@kumo
kumo / arabic.hs
Last active April 5, 2019 04:47
Second version of arabic to roman numerals converter
arabic :: String -> Int
arabic "" = 0
arabic (x:y:xs)
| x == 'C', y == 'M' = 900 + arabic xs
| x == 'C', y == 'D' = 400 + arabic xs
| x == 'I', y == 'X' = 9 + arabic xs
| x == 'I', y == 'V' = 4 + arabic xs
arabic (x:xs)
| x == 'M' = 1000 + arabic xs
| x == 'D' = 500 + arabic xs
@kumo
kumo / Stats.py
Last active May 20, 2019 09:22
Python script to generate stats for a collection of files with the format DATE - Author 1, Author 2-Editor.doc
import glob
import re
from collections import Counter
import datetime
import csv
files = glob.glob('*.*')
print "There are ", len(files), " files."
@kumo
kumo / lrc.py
Created January 4, 2018 14:16
Python script to show lyrics from a .lrc file whilst playing an .mp3
import pylrc
import sys
import time
import vlc
import pathlib
import signal
# Check that the user has specified the .lrc file
if (len(sys.argv) != 2):
exit(0)
I II III, IV V, VI VII, VIII, IX X, XI XII XIII XIV XV. XVI XVII XVIII, XIX, XX XXI, "XXII, XXIII, XXIV XXV!" XXVI XXVII XXVIII XXIX XXX XXXI, XXXII, XXXIII?
XXXIV XXXV XXXVI XXXVII XXXVIII XXXIX XL, XLI, XLII XLIII XLIV XLV. XLVI XLVII, XLVIII XLIX, L LI LII LIII LIV, LV, LVI LVII LVIII LIX LX! LXI LXII, "LXIII LXIV LXV LXVI LXVII LXVIII LXIX LXX LXXI?" LXXII LXXIII, LXXIV, LXXV LXXVI LXXVII, LXXVIII LXXIX LXXX LXXXI, LXXXII LXXXIII, LXXXIV, LXXXV LXXXVI, LXXXVII LXXXVIII LXXXIX XC XCI, XCII, XCIII, XCIV. XCV, XCVI XCVII XCVIII XCIX, C CI CII CIII CIV CV CVI CVII CVIII CIX CX CXI, "CXII CXIII CXIV CXV." CXVI CXVII, CXVIII CXIX CXX CXXI CXXII CXXIII CXXIV CXXV, CXXVI CXXVII, CXXVIII CXXIX, CXXX, CXXXI CXXXII CXXXIII CXXXIV, CXXXV CXXXVI CXXXVII, CXXXVIII CXXXIX, CXL? CXLI CXLII CXLIII CXLIV CXLV CXLVI! CXLVII, CXLVIII CXLIX CL CLI CLII CLIII CLIV CLV CLVI CLVII, "CLVIII!"
CLIX, CLX? CLXI CLXII CLXIII CLXIV CLXV, CLXVI CLXVII CLXVIII, CLXIX CLXX CLXXI, CLXXII CLXXIII CLXXIV CLXXV CLXXVI CLXXVII CLXXVIII CLXX
@kumo
kumo / RomanWords.swift
Last active November 17, 2015 16:55
Sketching out my #nanogenwri contribution
//: Playground - noun: a place where people can play
import UIKit
enum SentenceEnd: String {
case FullStop = "."
case QuestionMark = "?"
case ExclamationMark = "!"
}
@kumo
kumo / Colouring Sketch.js
Created October 3, 2015 13:00
Playing with Sketch colours and plugins
var doc = context.document
var selectionCount = context.selection.count()
if (selectionCount == 0) {
doc.showMessage("Nothing selected.")
return
}
var tile = context.selection[0]
@kumo
kumo / DateOrder.swift
Last active June 29, 2022 16:29
Checking the date order of the current locale
extension Locale {
enum DateOrder {
case DayFirst, MonthFirst, YearFirst
}
func dateOrder() -> DateOrder {
guard let formatter = DateFormatter.dateFormat(fromTemplate: "MMMMdY", options: 0, locale: self) else {
return .DayFirst
}