Skip to content

Instantly share code, notes, and snippets.


Alexander Karlstad carestad

View GitHub Profile
carestad /
Last active Aug 8, 2019
Script to generate JWT for use with Github apps
#!/usr/bin/env bash
# Generate JWT for Github App
# Inspired by implementation by Will Haley at:
# From:
thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
carestad /
Last active Jul 17, 2019
Script to notify on Slack when updates are available in APT. Logs already reported packages on a $0.log file.
# Author: Alexander Karlstad <carestad@github>
# Updated: 2019-07-17
# Configurable variables
slack_user="apt@$(hostname -f)"

Keybase proof

I hereby claim:

  • I am carestad on github.
  • I am karlstad ( on keybase.
  • I have a public key ASBdjb4nFyklP4MvxzxDntz8_HIN-VFz1SKRfFHtBqUJbAo

To claim this, I am signing this object:

carestad / convert-first-page-pdf-to-jpg.php
Created Feb 22, 2019
Convert first page of PDF to JPG thumbnail in PHP
View convert-first-page-pdf-to-jpg.php
$file = '/foo/bar/document.pdf';
$im = new \Imagick($file);
$im->setIteratorIndex(0); // just use first page
$im->setImageAlphaChannel(\Imagick::VIRTUALPIXELMETHOD_WHITE); // Other alpha options are available, see Imagick PHP documentation
$im->setImageColorspace(\Imagick::COLORSPACE_SRGB); // Other colorspaces are available, see Imagick PHP documentation
$im->setImageBackgroundColor('white'); // Set transparent background elements to this color
$im->setFormat('JPG'); // Format, a wide variety is supported
carestad /
Last active Mar 9, 2020
Collection of slides from #vuejsamsterdam 2019

Day 1

Time Speaker(s) Title
08:45 Evan You State of the Vuenion (Founder of Vue.js)
09:00 Sarah Drasner
Guillaume Chau
Advanced Animations with Vue.JS (Vue.js Core Team)
SSR revolution with Vue 2.6
09:35 Tim Benniks Vue.js for L'oreal, a case study (Director of Frontend @Valtech Paris)
10:45 Jen Looper NativeScript-Vue + ML = The Great MiniBar Challenge: MixoLogy (Developer Advocate at Progress)
11:15 Filip Rakowski Modern Web Apps Performance Tricks with PWA and Vue.js (Founder Vue Storefront)
11:50 Sara Vieira [GraphQL + Apollo + Vue.js =
carestad / DataUriToFile.php
Last active Nov 6, 2019
Middleware to detect if a POST parameter of a given type is present, and if it is a data URI string we convert it to an instance of UploadedFile and make it accessible via Laravel's Request class and the file handling methods there.
View DataUriToFile.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\UploadedFile;
class DataUriToFile
carestad / laravel-superglobals-cheat-sheet.php
Last active Dec 13, 2018
Laravel superglobals cheat sheet
View laravel-superglobals-cheat-sheet.php
$_SERVER['HTTP_HOST'] = Request::getHttpHost();
$_SERVER['HTTP_HOST'] = request()->getHttpHost();
// Alternative could be to use URL::previous(), but this will always return current URL if no referer is present.
// @see
$_SERVER['HTTP_REFERER'] = Request::header('referer', 'default');
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = Request::getPreferredLanguage();
carestad / .bash_completion.jotta
Created Apr 23, 2018
Bash completion for jotta-cli
View .bash_completion.jotta
function _jottacli() {
local config_params cmds cur first params prev second
carestad /
Last active Apr 4, 2017
Skyss travel planner [Bash style]
# By: Alexander Karlstad <>
# Requires 'jq' and 'curl'
# To install (on Ubuntu):
# sudo apt install jq curl
function halp() {
carestad /
Last active Aug 24, 2020
TTML to SRT conversion. Written in PHP.


This is a simple script for converting TTML subtitle files to SRT ones. Tested with TTML files on

It assumes the data is structured like this:

You can’t perform that action at this time.