Skip to content

Instantly share code, notes, and snippets.

View dominics's full-sized avatar

Dominic Scheirlinck dominics

View GitHub Profile
@dominics
dominics / webpack.config.ts
Last active July 6, 2020 11:15
Individual webpack stats per entrypoint
const path = require('path')
const slsw = require('serverless-webpack')
const { StatsWriterPlugin } = require('webpack-stats-plugin')
const yaml = require('js-yaml')
const fs = require('fs')
require('events').EventEmitter.defaultMaxListeners = 20 // default: 10, using 11 at the moment
/**
* slsw.lib.entries is used when invoking webpack from serverless, e.g. `serverless package`
$ CREATE FUNCTION sanitize_dates() RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'INSERT' THEN
NEW.created_on := now();
NEW.last_modified := NULL;
ELSIF TG_OP = 'UPDATE' THEN
NEW.created_on := OLD.created_on;
NEW.last_modified := now();
END IF;
RETURN NEW;
@dominics
dominics / ykaws-helpers.sh
Last active November 14, 2019 23:06 — forked from chtorr/helpers.sh
aws-vault yubikey bash/zsh helpers
# Helper script providing `ykaws-auth <profile>` and `ykaws-login <profile>` helpers
#
# Initial Yubikey setup:
# - Install and configure Yubico Authenticator, ykman, AWS Vault
# - Configure your AWS MFA device to be stored in your Yubikey
# - Set a YKAWS_PROFILE environment variable to the TOTP profile name (list with `ykman oath list`) in your shell startup scripts
# - You'll know you're ready when `ykman oath code --single "$YKAWS_PROFILE"` returns an MFA code
#
# Installing this helper:
# - Put it somewhere
@dominics
dominics / AWSAssumedRoleCredentialsProvider.scala
Created October 26, 2018 05:15
AWSAssumedRoleCredentialsProvider
import com.amazonaws.auth.{ AWSCredentials, AWSCredentialsProvider }
import com.amazonaws.auth.profile.internal._
import com.amazonaws.auth.profile.internal.securitytoken.STSProfileCredentialsServiceLoader
import com.amazonaws.profile.path.AwsProfileFileLocationProvider
import scala.collection.JavaConverters._
object AWSAssumedRoleCredentialsProvider {
lazy private val profileName = AwsProfileNameLoader.INSTANCE.loadProfileName()
@dominics
dominics / CustomExecutorJdbcBackend.scala
Created July 31, 2018 22:02
Custom AsyncExecutor for Database.forConfig
package foo.bar
import java.sql.{ Array => _, _ }
import com.typesafe.config.{ Config, ConfigFactory }
import slick.jdbc.{ JdbcBackend, JdbcDataSource }
import slick.util.ConfigExtensionMethods._
import slick.util.{ AsyncExecutor, ClassLoaderUtil }
trait CustomExecutorJdbcBackend extends JdbcBackend {
@dominics
dominics / disque-commands.md
Last active April 24, 2017 13:07
Undocumented disque commands

Debug

DEBUG FLUSHALL Resets all queues, jobs

MONITOR Works like its Redis counterpart

Cluster

@dominics
dominics / OomSnag.php
Created April 10, 2017 00:12
Report PHP OOM errors in Bugsnag
<?php
namespace Foobar\Bugsnag;
use Bugsnag\Client;
class OomSnag
{
private const REGEX = '/^Allowed memory size of ([0-9]+) bytes exhausted/';
@dominics
dominics / CommandTestCase.php
Created March 29, 2017 04:41
Testing a Knp ConsoleServiceProvider Command
<?php
namespace MyApp\Test;
use Knp\Console\ConsoleEvent;
use Knp\Console\ConsoleEvents;
use Silex\Application;
use Knp\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;
@dominics
dominics / test.php
Last active February 28, 2017 01:10
Redbean issue #544
<?php
require_once __DIR__ . '/vendor/autoload.php';
use RedBeanPHP\Facade as R;
// Start setup
R::setup(getenv('REDBEAN_DSN'), getenv('REDBEAN_USERNAME'), getenv('REDBEAN_PASSWORD'));
R::exec('DROP TABLE child');
@dominics
dominics / aws-alias-host
Last active February 7, 2017 02:32
"hostfile" an AWS ALB
#!/bin/bash
set -e
set -o pipefail
if [ $EUID -ne 0 ]; then
exec sudo "$0" "$@"
fi
readonly hostname=$1