Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / rules.txt
Last active November 21, 2023 17:39
Some ublock rules that block elements that match specific pieces of text
! 2022-03-24 https://twitter.com
twitter.*##div[aria-label="Timeline: Trending now"]
twitter.*##div[aria-label="Home timeline"] > div > div article:has(div > div > div > span:has-text(Ad))
! 2022-03-29 https://google.com
google.*##.g:has(a[href*="thetopsites.com"])
google.*##.g:has(*:has-text(/bye topic of noninterest/i))
@james2doyle
james2doyle / main.py
Last active July 18, 2022 17:25
An ESP32 script that connects to WIFI and starts a UDP server
import network
import utime
import socket
import machine
p2 = machine.Pin(2, machine.Pin.OUT) # create input pin on GPIO2 (builtin LED)
p2.off()
def toggle_pin():
p2.value(1) if p2.value() == 0 else p2.value(0)
@james2doyle
james2doyle / .clangd
Last active July 15, 2022 15:28
A .clangd file for clangd language server protocol that works with Arduino .ino files. Requires platformio and Arduino app to be installed. Also assumes leonardo board but you can change that in the list of variants
// need to add the following to define the Serial class:
// #if defined(DEVELOP)
// extern HardwareSerial Serial;
// #endif
CompileFlags:
Add: [-xc++, -Wall, -DDEVELOP=1, -I$HOME/.platformio/packages/toolchain-atmelavr/avr/include/, -I$HOME/.platformio/packages/framework-arduino-avr/cores/arduino/, -I/Applications/Arduino.app/Contents/Java/hardware/tools/avr/lib/gcc/avr/7.3.0/include/, -I/Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/, -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/, -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/, -I/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include/libiberty/, -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard/, -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/leonardo/, -I$HOME/.platformio/packages/toolchain-atmelavr/avr/include/avr/, -I$HOME/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src/, -I$HO
@james2doyle
james2doyle / shortcuts.lua
Created July 14, 2022 17:59
Hammerspoon Keyboard Shortcuts (Toggle Apps/Shortcuts With The Keyboard)
--[[
Name: Shortcuts (Toggle Apps/Shortcuts With The Keyboard)
Author: James Doyle <james2doyle@gmail.com>
Description: Run the shortcut that toggles apps and functions
Demo: <None>
Installation: Just require this file in your Hammerspoon init.lua file
Usage:
Press the keybinding
The shortcut/app will run or focus and there will be a notification
]]--
@james2doyle
james2doyle / Tailwind-LSP-twin-macro.json
Last active June 2, 2022 16:10
Settings for Sublime LSP Tailwind extension so that it works with twin.macro JSX/TSX props
// Settings in here override those in "LSP-tailwindcss/LSP-tailwindcss.sublime-settings"
{
"settings": {
"tailwindCSS.experimental.classRegex": [
["classnames\\(([^)]*)\\)", "'([^']*)'"],
"class=\"([^\"]*)", // <div class="..." />
"tw`([^`]*)", // tw`...`
"tw=\"([^\"]*)", // <div tw="..." />
"tw={\"([^\"}]*)", // <div tw={"..."} />
"tw\\.\\w+`([^`]*)", // tw.xxx`...`
@james2doyle
james2doyle / get-token-from-user-using-uuid-console.php
Last active May 16, 2022 17:55
A Laravel Artisan command to get an auth token from a User using UUID or email of that user. Validates UUID or email. Handy for testing authentication with Postman or CLI
<?php
declare(strict_types=1);
use App\Models\User;
use Illuminate\Support\Facades\Artisan;
use Ramsey\Uuid\Rfc4122\Validator;
/*
|--------------------------------------------------------------------------
@james2doyle
james2doyle / setup-pi-webserver.sh
Last active June 5, 2022 23:02
A series of commands to setup PHP 8.1, composer, and a lighttpd webserver
sudo apt-get update
sudo apt-get install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://origin.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update
sudo apt-get install -y php8.1 php8.1-cli php8.1-cgi php8.1-swoole php8.1-intl php8.1-zip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
@james2doyle
james2doyle / config.txt
Last active May 8, 2022 20:03
Raspberry Pi 4 config for my TV that sets the screen as generic, enables 60fps, sets the display to 1080p, and overclocks the CPU & GPU
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# to disable unused network modules:
#dtoverlay=disable-wifi
#dtoverlay=disable-bt
# set the SSH terminal to use the connected screen on HDMI 0: export DISPLAY=:0.0
@james2doyle
james2doyle / raycast.search-on-brave.sh
Last active May 6, 2022 19:02
Run a query on search.brave.com. Custom command for Raycast
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Search on Brave
# @raycast.mode compact
# @raycast.argument1 { "type": "text", "placeholder": "query", "percentEncoded": true }
# Optional parameters:
# @raycast.icon images/icon-brave.png
@james2doyle
james2doyle / PHP-Clips.json
Last active March 23, 2022 22:02
Nova 9 PHP Clips (completions, snippets) for common flow controls, variables, globals, functions, methods, documentation, and classes
{
"clips": [
{
"content": "/** @var ${1:class/type} ${2:description} */",
"name": "Var Documentation",
"scope": "editor",
"syntax": "php",
"trigger": "@var"
},
{