Skip to content

Instantly share code, notes, and snippets.

@mikeybeck
mikeybeck / views_migration.patch
Last active November 2, 2023 02:35
Drupal views migration patch
diff --git a/src/Plugin/migrate/source/d7/ViewsMigration.php b/src/Plugin/migrate/source/d7/ViewsMigration.php
index 7c8f3e8..e78a407 100644
--- a/src/Plugin/migrate/source/d7/ViewsMigration.php
+++ b/src/Plugin/migrate/source/d7/ViewsMigration.php
@@ -7,6 +7,7 @@
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\views_migration\Plugin\migrate\source\BaseViewsMigration;
+use Drush\Drush;
@mikeybeck
mikeybeck / lnav_laravel.json
Last active July 29, 2022 05:55
Laravel format for LNAV
{
"laravel_log": {
"title": "Laravel log format",
"description": "Log format used by Laravel",
"url": "https://laravel.com/",
"regex": {
"laravel": {
"pattern": "^\\[(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})\\] local\\.(?<level>.*?)\\: (\\[(?<supplier>.*)\\] )?(?<body>.*?)\\s?(\\[stacktrace\\](?<stacktrace>(.|\\s)*))?$"
}
},
@mikeybeck
mikeybeck / checkInMeeting.sh
Created May 22, 2022 04:39
HomeAssistant light toggle based on camera/microphone status
#!/bin/bash
# Taken with thanks from https://hansenji.medium.com/linux-triggers-for-in-meeting-indicator-ea06cdbe41bd,
# with minor modifications for sending notification to HA.
# Camera status can be monitored with incron &
# `/dev/video* IN_OPEN,IN_CLOSE,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE *PATH*/checkInMeeting.sh`
# Before running this, remember to insert HA address and auth key here,
# and update the entity ID and RGB colour in the cURL requests further down.
@mikeybeck
mikeybeck / delete-remote-branches.sh
Last active April 16, 2021 05:43
Deletes my production-merged remote git branches for a given date period (2020-08) in an extremely inefficient manner
git for-each-ref --format=' %(authorname) %09 %(committerdate:short) %09 %(refname)' --sort=committerdate --sort=authorname --merged production | grep "refs/remotes/origin/" | sed 's/refs\/remotes\/origin\///g' | grep Mike | grep mikeybeck | grep 2020-08 | awk '{ print $4 }' | while read x; do echo "deleting $x"; git push origin --delete $x; done
@mikeybeck
mikeybeck / git-bisect.sh
Last active November 22, 2018 02:00
[git bisect] #shell
git bisect start
git bisect bad # Current commit is broken
git bisect good HEAD~100 # Commit at HEAD~100 is good
# Then input `git bisect good` or `git bisect bad` for each provided commit, until you find the commit which introduced the bug.
@mikeybeck
mikeybeck / git-search-log.sh
Created October 8, 2018 04:10
[Find string in git log] #git #find #search
git log --all -p --reverse --source -S 'SEARCH_STRING'
@mikeybeck
mikeybeck / Tinker SQL query to get rows from table
Last active September 30, 2018 22:39
[Get rows from database table in Tinker] #SQL #tinker
DB::select('SELECT * FROM table WHERE column = 'value' ORDER BY id LIMIT limit')
@mikeybeck
mikeybeck / tinker-search
Created September 30, 2018 22:33
[search Tinker history] #artisan #tinker
@mikeybeck
mikeybeck / hammerspoon - URL handler alert.lua
Last active September 29, 2018 09:42
[URL handler alert] #hammerspoon
hs.urlevent.bind("someAlert", function(eventName, params)
hs.alert.show("Hey there alert")
end)
-- After having this line in init.lua
-- you can then call it from the shell like so
open -g hammerspoon://someAlert
@mikeybeck
mikeybeck / hammerspoon - Bind function to hotkey.lua
Last active September 29, 2018 09:41
[Bind function to hotkey] #hammerspoon
hs.hotkey.bind("ctrl", "return", function()
hs.notify.new({title="Hammerspoon", informativeText="Hello World"}):send()
end)