Skip to content

Instantly share code, notes, and snippets.


Alexander Karlstad carestad

View GitHub Profile
carestad /
Last active Oct 29, 2021
Build DisplayLink docking driver for newer kernel verions

After having the same issue myself by using a mainline 5.13 kernel in Pop OS, I managed to get the monitors working by having a look at the guide for porting the driver to other distros here:

A small summary though (only tested in PopOs, but should probably work in most Debian/Ubuntu based distros):

  1. Make sure you uninstall the current EVDI driver. Do this by calling the currently installed DisplayLink installer file with a "uninstall" argument. For example: sudo ./ uninstall
  2. Extract the content of the installer file. For example: ./ --noexec --keep
  3. A folder will now exist in the same path as your installer file. CD into it like so: (replace x.x.xx with the real numbers) cd ./displaylink-driver-5.4.0-55.153
  4. Replace the evdi.tar.gz file that exists there. I just downloaded a tarball from the latest dev
carestad / LogTrait.php
Created Aug 18, 2021
Laravel console command log trait. This adds a few logXX() methods which will append a timestamp in front of the logged text + take verbosity level into account so -vvv can log more than -v
View LogTrait.php
namespace App\Console\Commands\Traits;
trait LogTrait
public function logDebug(string $text, ?string $dateFormat = 'Y-m-d H:i:s'): void
/** @var \Illuminate\Console\Command $this */
if (! $this->output->isDebug()) {
carestad / TimedTrait.php
Created Aug 18, 2021
Laravel console command timed trait. This will always output how long the execution of a Laravel command takes.
View TimedTrait.php
namespace App\Console\Commands\Traits;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
trait TimedTrait
carestad / Timestamp.php
Last active May 26, 2021
Doctrine DBAL Timestamp type for use with Laravel
View Timestamp.php
namespace Database\Migrations\Types;
use DateTime;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\PhpDateTimeMappingType;
use Doctrine\DBAL\Types\Type;
carestad / FooRequest.php
Last active Dec 8, 2020
[Laravel] Return validation errors as proper object/arrays
View FooRequest.php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class FooRequest extends FormRequest
public function authorize()
carestad /
Last active Nov 18, 2021
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 Jul 22, 2021
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 =