Skip to content

Instantly share code, notes, and snippets.

Avatar
🤠

Alexander Karlstad carestad

🤠
View GitHub Profile
@carestad
carestad / guide.md
Last active Oct 29, 2021
Build DisplayLink docking driver for newer kernel verions
View guide.md

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: https://support.displaylink.com/knowledgebase/articles/679060-porting-the-displaylink-ubuntu-driver-to-other-lin

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 ./displaylink-driver-5.4.0-55.153.run uninstall
  2. Extract the content of the installer file. For example: ./displaylink-driver-5.4.0-55.153.run --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
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
<?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
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
<?php
namespace App\Console\Commands\Traits;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
trait TimedTrait
{
/**
@carestad
carestad / Timestamp.php
Last active May 26, 2021
Doctrine DBAL Timestamp type for use with Laravel
View Timestamp.php
<?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
carestad / FooRequest.php
Last active Dec 8, 2020
[Laravel] Return validation errors as proper object/arrays
View FooRequest.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class FooRequest extends FormRequest
{
public function authorize()
{
@carestad
carestad / github-app-jwt.sh
Last active Nov 18, 2021
Script to generate JWT for use with Github apps
View github-app-jwt.sh
#!/usr/bin/env bash
# Generate JWT for Github App
#
# Inspired by implementation by Will Haley at:
# http://willhaley.com/blog/generate-jwt-with-bash/
# From:
# https://stackoverflow.com/questions/46657001/how-do-you-create-an-rs256-jwt-assertion-with-bash-shell-scripting
thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@carestad
carestad / apt-slack.sh
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.
View apt-slack.sh
#!/bin/bash
#
# Author: Alexander Karlstad <carestad@github>
# Updated: 2019-07-17
# Configurable variables
slack_channel="@alexander"
slack_icon=":information_source:"
slack_user="apt@$(hostname -f)"
slack_webhook=""
View keybase.md

Keybase proof

I hereby claim:

  • I am carestad on github.
  • I am karlstad (https://keybase.io/karlstad) on keybase.
  • I have a public key ASBdjb4nFyklP4MvxzxDntz8_HIN-VFz1SKRfFHtBqUJbAo

To claim this, I am signing this object:

@carestad
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
<?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
carestad / vuejs.amsterdam.2019.slides.md
Last active Jul 22, 2021
Collection of slides from #vuejsamsterdam 2019
View vuejs.amsterdam.2019.slides.md

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 =