Skip to content

Instantly share code, notes, and snippets.

View asgrim's full-sized avatar
😈
Doing evil things, probably. Sorry...

James Titcumb asgrim

😈
Doing evil things, probably. Sorry...
View GitHub Profile
@asgrim
asgrim / do-not-truncate-github-actions.user.js
Last active October 30, 2023 10:15
greasemonkey script to remove the job name truncation of GH Actions jobs
// ==UserScript==
// @name Fix GH Actions Left Column width
// @match *://github.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// ==/UserScript==
console.log('GM script to fix GH Actions left column width');
// thanks https://phpc.social/@art4@youthweb.social/111323319571716871
  • If you use Slack via Snap, uninstall it and use the DEB version
  • Edit /usr/share/applications/slack.desktop (likely with sudo)
  • Replace the Exec=/usr/bin/slack %U line with:
Exec=env SLACK_DEVELOPER_MENU=true /usr/bin/slack %U
  • Launch it using the launcher as usual and right click somewhere (e.g. top left) and "Inspect element"
  • Go to the "Console" tab
Me:
Pretend you are a MySQL service, starting from a blank server. My input should be parsed as a direct MySQL query. You should check my syntax against MySQL 8 syntax rules. Your responses should be the result of the query, with no context.
ChatGPT:
Sure, I can help you with that! Please provide your MySQL query and I will run it against the database.
Me:
Show databases
ChatGPT:
@asgrim
asgrim / lolwat.php
Last active September 5, 2022 05:58
<?php
$thingsToBind = [
[
'value' => '123',
'param' => 'first',
],
[
'value' => '321',
'param' => 'second',
@asgrim
asgrim / gitlab-checkout.sh
Last active February 1, 2022 08:38
GitLab checkout process - example of how to replicate a git checkout that GitLab does (more or less)
mkdir project-checkout
cd project-checkout
# https://gitlab.com/gitlab-org/gitlab-runner/-/blob/b41ed180/shells/abstract.go#L353
git init
# https://gitlab.com/gitlab-org/gitlab-runner/-/blob/b41ed180/shells/abstract.go#L357
git remote add origin <remote_url>
# https://gitlab.com/gitlab-org/gitlab-runner/-/blob/b41ed180/shells/abstract.go#L366
$ composer create-project laravel/laravel:6.* test-app --prefer-dist
Creating a "laravel/laravel:6.*" project at "./test-app"
Installing laravel/laravel (v6.20.1)
- Installing laravel/laravel (v6.20.1): Extracting archive
Created project in /tmp/laravel-create-test/test-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 93 installs, 0 updates, 0 removals
- Locking doctrine/inflector (2.0.4)
@asgrim
asgrim / DisallowBlacklistedClassUsage.php
Last active May 1, 2020 15:31
Simplified plugin for Psalm that does (part of) what I wanted in this Tweet: https://twitter.com/asgrim/status/1256181096938647555
<?php
declare(strict_types=1);
namespace StaticAnalysisPlugin;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use Psalm\Codebase;
<?php
final class BookHandler
{
public function __construct(AggregateRepository $bookLibrary) {}
public function handleCheckInBook(CheckInBook $command) {}
public function handleCheckOutBook(CheckOutBook $command) {}
}
@asgrim
asgrim / test.php
Created April 2, 2019 12:03
Get all the classes and functions in a file
<?php
declare(strict_types=1);
use Roave\BetterReflection\BetterReflection;
use Roave\BetterReflection\Reflector\ClassReflector;
use Roave\BetterReflection\Reflector\FunctionReflector;
use Roave\BetterReflection\SourceLocator\Type\SingleFileSourceLocator;
$fileName = 'my-file-with-stuff.php';
@asgrim
asgrim / stream-ips.sh
Created March 2, 2018 18:22
Used to use this on browscap-site to watch for IP abuse and block them
#!/bin/bash
set -uox pipefail
RUN=true
TIMEOUT=60
trap 'kill -INT -$PID; RUN=false' INT
file="/tmp/ips"
# varnishncsa > $file