Skip to content

Instantly share code, notes, and snippets.

View directionforward's full-sized avatar

Direction Forward directionforward

View GitHub Profile
@directionforward
directionforward / update_printer_settings.ps1
Last active April 13, 2023 15:24
Change print default to B&W for all printers using Powershell
$action = New-ScheduledTaskAction -Execute "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Argument "&{ echo 'Setting print defaults to BandW...'; `$Printers = Get-Printer; Foreach(`$Printer in `$Printers){Set-PrintConfiguration -PrinterName `$Printer.name -Color `$False}; }";
$trigger = New-ScheduledTaskTrigger -AtStartup;
$trigger.Repetition = (New-ScheduledTaskTrigger -Once -At 12am -RepetitionInterval (New-TimeSpan -Minutes 60)).repetition;
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries;
$settings.CimInstanceProperties.Item('MultipleInstances').Value = 3;
$principal = $principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest;
$task = New-ScheduledTask -Trigger $trigger -Action $action -Settings $settings -Principal $principal;
Register-ScheduledTask "Update printer settings" -InputObject $task;
@directionforward
directionforward / recursive-chmod.md
Last active November 22, 2022 23:11 — forked from bzerangue/recursive-chmod.md
Scripts for recursively chmod directories only and recursively chmod files only

Useful commands

You may find these commands useful when adjusting file and directory permissions.

To recursively chmod directories only for single user permissions:

find /your/site/root -type d -exec chmod 755 {} \;

To recursively chmod directories only for group users permissions:

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@directionforward
directionforward / functions.php
Created September 6, 2021 17:43
Add custom CSS to WordPress admin via functions.php
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
/* styles here */
}
</style>';
}
@directionforward
directionforward / forEach-ie.js
Created June 30, 2021 19:15
Fix forEach for ES6 in IE
if (typeof NodeList.prototype.forEach !== 'function') {
NodeList.prototype.forEach = Array.prototype.forEach;
}
if (window.document.documentMode) {
// Do IE stuff
}
@directionforward
directionforward / jquery-passive-scroll.js
Created June 21, 2021 10:42
Passive scrollers for jQuery
// Passive event listeners
jQuery.event.special.touchstart = {
setup: function( _, ns, handle ) {
this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") });
}
};
jQuery.event.special.touchmove = {
setup: function( _, ns, handle ) {
this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") });
}
@directionforward
directionforward / colliding.js
Last active January 27, 2021 01:08 — forked from jtsternberg/colliding.js
Detect if two elements are colliding/overlapping
var is_colliding = function($div1, $div2) {
// Div1 data
var d1_offset = $div1.offset();
var d1_height = $div1.outerHeight( true );
var d1_width = $div1.outerWidth( true );
var d1_distance_from_top = d1_offset.top + d1_height;
var d1_distance_from_left = d1_offset.left + d1_width;
// Div2 data
@directionforward
directionforward / detect-ios.js
Created January 21, 2021 11:53 — forked from codearryaas/detect-ios.js
JavaScript: How to detect if device is iOS?
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if (isIOS) {
console.log('This is a IOS device');
} else {
console.log('This is Not a IOS device');
}
/**
Squarespace essentially doesn't really document their breakpoints.
This can be quite annoying to not have when doing custom CSS.
Most themes use essentially one breakpoint. Mobile and not mobile; anything 750 and below is considered mobile.
You can use these to write your own CSS and simply use the "Style Editor" to inject your compiled CSS in the event
you are not using "Developer Mode" in your site.
Enjoy!