Skip to content

Instantly share code, notes, and snippets.

View squatto's full-sized avatar
🤓
Geeking out

Scott Carpenter squatto

🤓
Geeking out
View GitHub Profile
@squatto
squatto / .enable_sudo_touchid.zsh
Created September 8, 2023 06:49
Ensure that Touch ID for sudo auth is enabled whenever the shell is loaded
# Ensure that Touch ID for sudo auth is enabled whenever the shell is loaded.
#
# IMPORTANT: This script will only work on macOS.
#
# [Description]
# macOS versions prior to Sonoma (released late 2023) overwrite
# the PAM configuration file for sudo (/etc/pam.d/sudo) every time the OS is updated.
# This means that any changes that you manually make to the file are lost,
# and you are reverted back to Touch ID for sudo auth being disabled.
# This script will automatically enable Touch ID for sudo auth whenever the shell is loaded.
@squatto
squatto / multiply-blending-mode-to-png.md
Created November 4, 2022 16:06 — forked from magicznyleszek/multiply-blending-mode-to-png.md
Multiply blending mode to PNG in Photoshop
  1. copy your image (Ctrl+A and Ctrl+C)
  2. make a new document-sized pure-black layer behind it
  3. group the black layer and yor image together
  4. add mask to the group
  5. enter mask edit mode (alt+click on the mask icon/thumbnail)
  6. paste your image in the mask (b/w) and then invert it.
  7. save it as a 24-bit transparent PNG

TabSwitcher Extreme JetBrains Plugin

TabSwitcher Extreme plugin details

Preferences

These preferences are specifically for a Laravel project

Preferences > Other Settings > TabSwitcher Extreme

@squatto
squatto / CanSaveQuietly.php
Last active December 24, 2022 22:52
CanSaveQuietly Laravel model trait - save or update models without firing any model events
<?php
namespace App\Models\Traits;
/**
* @mixin \Eloquent
*/
trait CanSaveQuietly
{
/**
@squatto
squatto / .php_cs
Last active February 21, 2020 20:16
PHP CS Fixer configuration file
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => ['=>' => 'align_single_space'], // changed by Scott Carpenter
@squatto
squatto / Automatically Join Borderlands 3 Twitch ECHOcast Rare Chest Events.md
Last active May 22, 2022 11:35
Automatically Join Borderlands 3 Twitch/ECHOcast Rare Chest Events

Automatically Join Borderlands 3 Twitch/ECHOcast Rare Chest Events

I got sick of having to push the "Join Event" button so I spent some time figuring out how to automatically join the events and wrote up these instructions.

DIRECT LINK TO THIS GUIDE: http://bit.ly/BL3AutoJoinChestEvents


These instructions reference the Dev Tools in Chrome, but you can do this in any browser! You just need to do the same process but in your browser's developer tools.

@squatto
squatto / osascript.applescript
Last active September 8, 2020 20:47
LastPass CLI Alfred Workflow - change /usr/bin/osascript step to work with Alfred 4
--display notification "Please wait... preparing login process..." with title "LastPass Login"
--Kill any previous login process as sometimes they hang or a user may interrupt them, if there are none (which there often are...) we will get an error response which we ignore.
try
do shell script "killall -9 lpass > /dev/null 2>&1"
end try
try
set login_email to do shell script "`perl -e 'use strict; use warnings; my $emailAddress =`security find-generic-password -w -s \"alfred-lastpass-email-address\"`; chomp $emailAddress; print $emailAddress;'`"
on error
@squatto
squatto / Autonomous Desk Control Panel Reset.txt
Created October 14, 2019 21:07 — forked from benjamincharity/autonomous.txt
Instructions on how to reset the autonomous desk. This fixes a problem where the desk will not lower (also reportedly fixes incorrectly reported heights).
> Thank you for reaching out to Autonomous! I am sorry to hear that you are having some trouble with your SmartDesk
> but I will be glad to assist. It sounds like your system needs a "hard reset" can I please have you follow these
> steps thoroughly.
Reset Steps:
1. Unplug the desk for 20 seconds. Plug it back in. Wait a full 20 seconds.
2. Press the up and down buttons until the desk lowers all the way and beeps or 20 seconds pass.
3. Release both buttons.
4. Press the down buttons until the desk beeps one more time or 20 seconds pass.

Server side printing with Google Cloud Print API from a PHP application

It took me quite some time to figure out how to print properly from a web application. I will explain here how I did it, so you don't have to spend the same time.

Authorization

Google Cloud Print API uses OAuth 2.0 for authorization.

As explained [here][1] on the Google Developer page, the best way to use OAuth with the Google API is with a Google service account. Create a service account as explained on the Google Developer page.

To use OAuth a library is required. Google has published the [Google API PHP client library][2]. If you want to use the examples from the Developer pages, you need to use version 1 of the library. In this article I use version 2 of the library.

#!/usr/bin/env ruby
require 'open-uri'
require 'pathname'
require 'json'
def strip_hash(f)
ext = f.extname
if ext.include?("?")