Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Kristofer silverbeak

🏠
Working from home
Block or report user

Report or block silverbeak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@silverbeak
silverbeak / Dockerfile
Created Jun 19, 2019
I use this script to create a bunch of fake docker images, so I can test my (upcoming) CLI app for removing them
View Dockerfile
FROM hello-world
ARG FAKE_VALUE=DEFAULT
ENV FAKE_VALUE=$FAKE_VALUE
@silverbeak
silverbeak / itt-to-srt.xslt
Last active Mar 7, 2019
An XSLT transform I use for converting itt-formatted subtitles to srt-formatted subtitles
View itt-to-srt.xslt
<?xml version="1.0"?>
<!--
This will convert itt-formatted subtitles to srt-formatted subtitles (or captions, if you prefer that)
Use it like so (using xsltproc in this example, feel free to use whatever engine you like):
# xsltproc itt-to-srt.xslt input_in_itt.itt > output_in_srt.srt
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ttp="http://www.w3.org/ns/ttml#parameter"
xmlns:tt_feature="http://www.w3.org/ns/ttml/feature/"
@silverbeak
silverbeak / rmhost
Created Jan 15, 2019
At work, we keep reinstalling our test servers. I use this script to remove outdated known_host keys
View rmhost
#!/bin/sh
# When the error message says something to the effect of
# Offending ECDSA key in /Users/xxx/.ssh/known_hosts:52
# Use the script like this:
# > rmhost 52
# to remove line 52 from the known_hosts file
# NB! Naturally, make sure to KNOW that the key is ok to be removed. Like the warning says
# IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
@silverbeak
silverbeak / ReadResource.scala
Created Mar 5, 2018
Read resource file using Scala
View ReadResource.scala
/**
* I do this often enough to merit a Gist, but not often enough to remember by heart. Maybe someone else has the same problem.
* The ".mkstring" part can of course be altered to something else as needed, if you don't want a String
*/
import scala.io.Source
val jsonMsg: String = Source.fromURL(getClass.getResource("/json/test1.json")).mkString
@silverbeak
silverbeak / YearDiff.groovy
Last active Dec 30, 2015
There was a question on SO on how to calculate someones current age in years. It's a simple enough operation using Joda-time (http://joda.sourceforge.net/). I thought I'd turn my example into a gist, if anyone else is interested. It's easy to turn this into something that would calculate the age in days or months or whatever... Please tell me if…
View YearDiff.groovy
import org.joda.time.DateTime
import org.joda.time.Years
def calculateAgeInYears(int year, int monthOfYear, int dayOfMonth) {
def yob = new DateTime(year, monthOfYear, dayOfMonth, 0, 0).toDateMidnight()
def now = DateTime.now().toDateMidnight()
return Years.yearsBetween(yob, now).getYears()
}
def years = calculateAgeInYears(1983, 12, 10)
You can’t perform that action at this time.