Skip to content

Instantly share code, notes, and snippets.

View bserem's full-sized avatar

Bill Seremetis bserem

View GitHub Profile
Running bash [-c /tmp/test_ddev.sh]
======= Existing project config =========
These config files were loaded for project p-ci: [/home/bserem/Development/anrt/p-ci/.ddev/config.yaml /home/bserem/Development/anrt/p-ci/.ddev/config.hooks.yaml]
name: p-ci
type: drupal9
docroot: web
php_version: 8.1
webserver_type: nginx-fpm
webimage: drud/ddev-webserver:v1.21.5
router_http_port: 80
@bserem
bserem / pre-commit
Created April 10, 2021 10:54
Run phpcs in ddev with Drupal standard on pre-commit.
#!/usr/bin/php
<?php
/**
* @file
* A Git pre-commit hook script to check files for PHP syntax errors and Drupal
* coding standards violations. Requires phpcs and Coder Sniffer:
*
* @see https://drupal.org/node/1419988
*
@bserem
bserem / door_lever.scad
Created June 28, 2022 09:07
Boorman tools insect mesh spacers (openscad)
translate([0,0,0]) {
difference() {
cylinder(h=14, d=30, $fn=360);
translate([-4,-4,2.52])
cube([8, 8, 100]);
}
translate([-10, 10, 0]) {
cube([18, 70, 14]);
}
}
@bserem
bserem / pdfcompress.sh
Last active June 8, 2022 06:13
Batch compress PDF files like invoices (especially made for timologio by AADE that produces huge files)
#! /bin/bash
for f in *.pdf
do
fbname=$(basename "$f" .pdf)
fbname_safe="${fbname// /_}"
mv "$fbname".pdf $fbname_safe.temp.pdf
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$fbname_safe.pdf $fbname_safe.temp.pdf
# To also change PDF title (untested):
# gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$fbname_safe.pdf $fbname_safe.temp.pdf -c "[ /Title (My New Title) /DOCINFO pdfmark"
@bserem
bserem / your.module
Created May 10, 2022 11:04
Conditional no results text based on exposed filter values (bypass drupal core bug related to https://www.drupal.org/project/drupal/issues/3024467)
<?php
/**
* Implements hook_views_pre_execute().
*/
function HOOK_views_pre_execute(ViewExecutable $view) {
if (empty($view->exposed_raw_input['title']) && ($view->query->getPluginId() === "search_api_query")) {
$view->query->abort();
}
}
OS Information: Linux dragoon 5.16.0-1-amd64 #1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09) x86_64 GNU/Linux
User information: uid=1000(bserem) gid=1000(bserem) groups=1000(bserem),4(adm),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),112(bluetooth),116(scanner),119(lpadmin),131(i2c),997(docker),998(nordvpn)
ITEM VALUE
DDEV version v1.18.2
architecture amd64
db drud/ddev-dbserver-mariadb-10.3:v1.18.2
dba phpmyadmin:5
ddev-ssh-agent drud/ddev-ssh-agent:v1.18.0
docker 20.10.12
docker-compose v2.2.2
@bserem
bserem / commit-msg
Created January 20, 2022 11:53
Commit msg hook in PHP that follow https://cbea.ms/git-commit
#!/usr/bin/php
<?php
$message = file_get_contents($argv[1]);
checkMessage($message);
exit(0);
function checkMessage($message) {
if (strlen($message) < 10) {
@bserem
bserem / prepare-commit-msg
Created May 4, 2021 14:02
Git hook to automatically add [skip ci] to commit message.
#!/bin/bash
exec < /dev/tty
read -n 1 -p "Would you like to run CI? (y/N) " ans;
ans=${ans:-n} # Default is no, always add [skip ci]
echo # Just add a new line
case $ans in
y|Y)
exit;;
n|N|*)
sed -i '$s/$/ [skip ci]/' $1;;
@bserem
bserem / ini
Created January 15, 2014 10:47
Midnight Commander (MC) solarized colors. Add this in ~/.config/mc/ini
[Colors]
base_color=lightgray,green:normal=green,default:selected=white,gray:marked=yellow,default:markselect=yellow,gray:directory=blue,default:executable=brightgreen,default:link=cyan,default:device=brightmagenta,default:special=lightgray,default:errors=red,default:reverse=green,default:gauge=green,default:input=white,gray:dnormal=green,gray:dfocus=brightgreen,gray:dhotnormal=cyan,gray:dhotfocus=brightcyan,gray:menu=green,default:menuhot=cyan,default:menusel=green,gray:menuhotsel=cyan,default:helpnormal=cyan,default:editnormal=green,default:editbold=blue,default:editmarked=gray,blue:stalelink=red,default
@bserem
bserem / update_mixxx_paths.sql
Created April 28, 2018 15:14
Change paths of files in MIXXX sqlite dabatase
/**
*Looks for directory *750GB* in the path and removes it for paths.
* Based on that you can do any replacements.
*/
UPDATE track_locations
SET location = replace (location, '750GB/', '')
where
location LIKE '%750G%';