Skip to content

Instantly share code, notes, and snippets.

@mjones129
mjones129 / CaptureScroll.js
Created February 9, 2020 08:25
capture how much a user has scrolled
//converts scroll data to +1 or -1 and prints to the console
window.addEventListener("wheel", event => {
const delta = Math.sign(event.deltaY);
console.info(delta);
});
@mjones129
mjones129 / killsnaps.sh
Created December 13, 2023 22:15
Remove old versions of snaps
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@mjones129
mjones129 / instructions.md
Created December 30, 2023 15:22 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@mjones129
mjones129 / turn-on-internet.sh
Created January 5, 2024 16:20
Enable (or re-enable) internet access in WSL2 after reboot
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
@mjones129
mjones129 / functions.php
Created January 18, 2024 01:52
Enable ES6 Modules for WordPress Themes JS
//load as ES6
function load_as_ES6($tag, $handle, $source) {
if('some-script-handle' === $handle) {
$tag = '<script src="' . $source . '" type="module" ></script>';
}
return $tag;
}
add_filter('script_loader_tag', 'load_as_ES6', 10, 3);
@mjones129
mjones129 / WP_Query_Args.php
Created January 29, 2024 19:19 — forked from fazlurr/WP_Query_Args.php
WP_Query arguments list
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@mjones129
mjones129 / config
Created January 29, 2024 23:57
Example SSH config
#This is a fake config for demonstration purposes only. This hostname isn't real.
Host hostname-staging
User user-2flis9vgsdf
Hostname 9v0asdles.hostname.io
IdentityFile ~/.ssh/hostname
IdentitiesOnly yes
@mjones129
mjones129 / some-page.php
Last active January 30, 2024 19:42
Exclude posts from WP_QUERY
<?
$args = [
'post_type' => 'any',
'post_status' => 'publish',
'order' => 'ASC',
'post__not_in' => [253, 236]
];
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
@mjones129
mjones129 / functions.php
Created February 5, 2024 14:36
Load JS modules as ES6 in WordPress
<?
//load as ES6
function load_as_ES6($tag, $handle, $source) {
if('tagname' === $handle) {
$tag = '<script src="' . $source . '" type="module" ></script>';
}
return $tag;
}
add_filter('script_loader_tag', 'load_as_ES6', 10, 3);
@mjones129
mjones129 / installTerminus.sh
Last active April 16, 2024 21:01
Install Terminus
#!/bin/bash
#update all the things
sudo apt update &&
sudo apt upgrade -y &&
#install all the dependencies