Skip to content

Instantly share code, notes, and snippets.

View johnstcn's full-sized avatar
🏳️‍🌈

Cian Johnston johnstcn

🏳️‍🌈
  • Ireland
  • 07:52 (UTC +01:00)
View GitHub Profile
@johnstcn
johnstcn / csvmerge.py
Created April 11, 2014 02:30
Tool to merge csv files given a commonly named column header
#!/usr/bin/env python
import csv
import argparse
import sys
from collections import defaultdict
helptext = """Merge multiple CSV files using a commonly named column.
CSV files must have column headings, but do not need to be sorted.
@johnstcn
johnstcn / multiget.py
Created November 12, 2016 04:20
Get a list of URLs, run a regex on the content and output the match. In parallel.
#!/usr/bin/env python
import argparse
import re
import grequests
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
@johnstcn
johnstcn / country_count.py
Created January 10, 2017 10:07
Print a frequency distribution of countries for a list of IP addresses using a local GeoIP database
#!/usr/bin/env python
import argparse
import json
import re
import sys
import GeoIP
from collections import Counter
#!/usr/bin/env python
# Author: Cian Johnston <johnstcn@gmail.com>
import argparse
import itertools
def distance(s1, s2):
out = abs(len(s1) - len(s2))
for c1, c2 in zip(s1, s2):
#!/usr/bin/env python
import fileinput
notes = [' '] + ('A Bb B C C# D Eb E F F# G G#'.split() * 2)
chars = ' abcdefghijklmnopqrstuvwy'
mapping = dict(zip(chars, notes))
def normalize(c):
return c.lower()

Keybase proof

I hereby claim:

  • I am johnstcn on github.
  • I am cianjohnston (https://keybase.io/cianjohnston) on keybase.
  • I have a public key ASDp1RugXYlzG-JhqP7WCi5z3MeOeIGApgo6KEdM31CRKgo

To claim this, I am signing this object:

@johnstcn
johnstcn / ethminer_ubuntu_nvidia.md
Last active October 1, 2022 16:34
NVIDIA/CUDA ethminer setup under Ubuntu Server 16.04

Headless Ethminer (nVidia) Setup Guide

Cian Johnston, July 2017

WARNING: THESE WORDS ARE OLD AND MAY NOT WORK FOR YOU IN THESE NEW AND INTERESTING TIMES.

A couple of weeks ago, I decided I should put my gaming rig to work crypto mining. I did not expect to make any significant profit on this, it was more of a fun project to set up. However, there were a large number of tutorials and guides already out there, and many were more than a year out of date.

This guide assumes the reader already has a crypto wallet set up, is comfortable with Linux and the command line, and knows how to use Google if they run into problems.

The end result is an Ubuntu 16.04 LTS headless server running CUDA ethminer via systemd.

@johnstcn
johnstcn / Vagrantfile
Last active April 10, 2021 15:12
provision sumo + veins on ubuntu 20.04
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2004"
config.vm.provision "shell" do |shell|
shell.privileged = false
shell.path = "provision.sh"
end
end
@johnstcn
johnstcn / foundry-vtt-macro-crossfade.js
Last active November 10, 2023 21:41
Foundry VTT Macro: Cross-fade Playlists
(function({fadeIn="", fadeDuration=5000}={}) {
function fadeInPlaylist(playlist, fadeDuration) {
playlist.playAll().then(function(p) {
let globalVol = game.settings.get("core", "globalPlaylistVolume");
p.sounds.filter(s => s.playing).find(_ => true)
.sound
.fade(globalVol, { duration: fadeDuration, from: 0});
});
}
(function({fadeDuration=5000}={}) {
function fadeOutPlaylist(playlist, fadeDuration) {
if (!playlist.playing) return;
let playingSound = playlist.sounds.filter(s => s.playing).find(_ => true).sound;
if (!!!playingSound) return; // should not happen
let currVol = playingSound.volume;
let globalVol = game.settings.get("core", "globalPlaylistVolume");
if (currVol == 0) return;
playingSound.fade(0, { duration: fadeDuration, from: currVol})
setTimeout(() => playlist.stopAll(), fadeDuration);