Skip to content

Instantly share code, notes, and snippets.

View spacecowboy's full-sized avatar

Jonas Kalderstam spacecowboy

View GitHub Profile
@spacecowboy
spacecowboy / README.md
Last active February 26, 2024 08:59
Systemd timer to restart systemd services on a schedule

First copy the files

Place the .timer and .service file in the /etc/systemd/system/ folder.

How to use

To use, let's assume I want to restart nginx every night. Then I'd do:

systemctl enable --now restart_nightly@nginx.timer
@spacecowboy
spacecowboy / cartesianProduct.kt
Last active May 13, 2020 08:41
Calculates the cartesian product of an arbitrary number of lists
/**
Calculates the cartesian product of an arbitrary number of lists.
Given `[[1, 2, 3], ["a", "b"]]`, it will produce
```
[
[1, "a"],
[2, "a"],
[3, "a"],
@spacecowboy
spacecowboy / opml_to_org.pl
Created February 23, 2017 22:31
Naive OPML to Orgmode converter
#!/usr/bin/env perl
print "* Blogs\n";
while (<>) {
if (/text="(.*?)">/) {
print "** $1 :$1:\n";
}
if (/text="(.*?)" type=".*?" xmlUrl="(.*?)"/) {
print "*** [[$2][$1]]\n"
@spacecowboy
spacecowboy / markverified.py
Created February 8, 2017 16:34
Script which outputs a key list with 'X'-es on the keys you've verified.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Usage: {} <ksp-fosdem.txt> <result.txt>
Marks which keys you have verified from a keysigning party.
Tested on FOSDEM keysigning party 2017.
'''

Keybase proof

I hereby claim:

  • I am spacecowboy on github.
  • I am spacecowboy (https://keybase.io/spacecowboy) on keybase.
  • I have a public key whose fingerprint is 3270 DC43 5A7D 604F 5B06 3521 987C 54AB 0D44 51ED

To claim this, I am signing this object:

@spacecowboy
spacecowboy / ghosttohugo.py
Last active July 17, 2016 18:48
Python script to migrate a Ghost blog to Hugo, including tags and banner images
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
A simple program which migrates an exported Ghost blog to Hugo.
It assumes your blog is using the hugo-icarus theme, but should
work for any theme. The script will migrate your posts, including
tags and banner images. Furthermore, it will make sure that
all your old post urls will keep working by adding aliases to them.
The only thing you need to do yourself is copying the `images/`
@spacecowboy
spacecowboy / hphosts_pfsense.sh
Created August 25, 2015 14:58
Download hphosts file and convert it to squidGuard formatting.
#!/bin/bash
TEMPDIR=/tmp/hphostspfsense
# Move to temporary directory
mkdir -p $TEMPDIR
rm -rf $TEMPDIR/*
cd $TEMPDIR
:: Required: git, Visual Studio 10.0 Express, Visual Studio 9 Express,
:: Windows 7 SDK (.NET 4), Windows 7 SDK (.NET 3.5), Anaconda/Miniconda
:::::::::::::::::::::::::::::::::::
:: User configurable stuff start ::
:::::::::::::::::::::::::::::::::::
:: These depends on where you installed Anaconda.
:: Python2 or Python3 doesn't matter but you need both 32bit and 64bit versions.
set ANACONDA_BASE=C:\Users\YOURUSERNAME\Anaconda
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
@spacecowboy
spacecowboy / master.py
Created September 8, 2011 16:04
A simple proof of concept for building your own super computer in python, assuming you have access to many machines.
from multiprocessing.managers import BaseManager
from mathenate import mathenate
#Define manager
class QueueManager(BaseManager): pass
QueueManager.register('get_job_queue')
QueueManager.register('get_result_queue')
#Connect to server
m = QueueManager(address=('my.computer.org', 50000), authkey='password')