Skip to content

Instantly share code, notes, and snippets.

[
// When no terminals are open, open a new terminal
{
"key": "ctrl+`",
"command": "workbench.action.terminal.new",
"when": "!terminalCount"
},
// When at least one terminal is open, focus on the terminal
{
"key": "ctrl+`",
@adduc
adduc / docker-compose.yml
Last active May 30, 2023 01:02
Script to provision a forgejo / woodpecker CI setup and a token to interact with Woodpecker's services
services:
forgejo:
image: codeberg.org/forgejo/forgejo:1.19.3-0
tmpfs: ["/data"]
stop_signal: SIGKILL
ports: [ "3000:3000", "8000:8000" ]
environment:
# @see https://docs.gitea.com/next/administration/config-cheat-sheet
GITEA__database__DB_TYPE: sqlite3
@adduc
adduc / Todo.php
Last active May 19, 2022 04:23
Laravel Eloquent PoC: Use existing PDO connection in standalone application
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Todo extends Model
{
@adduc
adduc / gist:d58a33c899cf078006b7f00291668477
Created November 9, 2021 05:45
stacktrace-on-sighup.php
<?php
declare(strict_types=1);
pcntl_async_signals(true);
pcntl_signal(SIGHUP, function ($signal) {
echo "HUP! {$signal} \n";
error_log((new Exception())->getTraceAsString());
});
@adduc
adduc / script.sh
Created February 10, 2021 19:50
Bash: Load config without overwriting existing env variables
# export current environment
EXISTING_ENV=$(export -p)
# import variables from file
. config.env
# import previous environment
source <(echo "$EXISTING_ENV")
# At this point, only variables from config.env that did
@adduc
adduc / find-unused.sh
Created October 11, 2020 18:01
Naive approach to finding unused files, classes, and functions
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <dir>"
exit 1
fi
DIR="$(realpath $1)"
find_unused_classes()
@adduc
adduc / install.sh
Last active August 24, 2021 09:23
My installation of mercurial, tortoisehg, and hg-git on Ubuntu 20.04 and newer
#!/bin/bash
TARGET_DIR=/opt/repos/third-parties
HG_GIT_VERSION=${1:-default}
HG_RELEASE_VERSION=${2:-5.5.2}
HG_REPO_VERSION=${3:-stable}
TORTOISEHG_VERSION=${4:-stable}
update() {
# Update packages
#cloud-config
# https://cloudinit.readthedocs.io/en/latest/topics/modules.html#users-and-groups
users:
- name: ansible
uid: 999
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh_authorized_keys:
- '[REDACTED]'
@adduc
adduc / .hgrc
Created March 31, 2020 06:14
hgrc for hg-git
[extensions]
git =
[alias]
npull = !$HG git; $HG nukebookmarks; $HG pull
nukebookmarks = !$HG bookmarks -q | xargs -r $HG bookmark -d
locals {
ami_ubuntu_1804 = "ami-06397100adf427136"
ssh_public_key = "ssh-rsa ABCD...asdfasdf"
}
provider "aws" {
profile = "default"
region = "us-west-1"
}