Skip to content

Instantly share code, notes, and snippets.

View patricknelson's full-sized avatar
Pushing 1's and 0's.

Patrick Nelson patricknelson

Pushing 1's and 0's.
View GitHub Profile
patricknelson /
Created August 21, 2023 22:15
Unshittify Reddit Images

Unshittify Reddit Images

This reverts the shitty wrapper that Reddit forces on you when you try to view images on their website. This is done via a bookmarklet (see URL below).

Create a new bookmark, copy/paste this code into it and then whenever you visit an image link and get redirected, this will fix the page so that it's just the image. Saving you from the varous bugs/issues induced by their platform (such as the header or footer overlapping the image itself when you attempt to zoom in on the image).

patricknelson /
Last active November 12, 2022 22:34
Full Screen Bookmark / Bookmarklet

Full Screen Bookmark / Bookmarklet

Can't go to full screen easily? On a website and hate their customized version of a video player and just wish you could use the one built into your device or browser? It turns out there's a solution: In many cases, you can actually bypass this by simply taking the <video> element on the page and forcing it to go to full screen immediately with a single press using a simple bookmark (or, a bookmarklet to be precise).


Create a bookmark, call it Full screen and copy/paste the following into the URL field:

javascript:(function()%7Bvar fsvs %3D document.getElementsByTagName('video')%3Bfor(i%3D0%3B i < fsvs.length%3B i%2B%2B) %7Bvar vid %3D fsvs%5Bi%5D%3Bwindow.fsv %3D window.fsv %7C%7C vid%3Bvar playing %3D !!(vid.currentTime > 0 %26%26 !vid.paused %26%26 !vid.ended %26%26 vid.readyState > 2)%3Bif (playing) %7Bwindow.fsv %3D vid%3Bbreak%3B%7D%7Dif (window.fsv) window.fsv.webkitEnterFullscreen()%7D)()
patricknelson / memcache-get-keys.php
Last active October 1, 2021 18:24
List all keys in older Memcache PHP extension
* Goes through all configured memcached slabs on the provided pre-configured Memcache object
* IMPORTANT: This is for the older and more limited (no "d" suffix) and
* NOT for (has the "d" suffix)!
* Inspired by (and modified from):
patricknelson / .bash_profile
Last active December 14, 2020 10:05
My personal .bash_profile script 🎉
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
# Launches ssh-pageant.exe (instead of ssh-agent) to connect to PuTTY's pageant.exe, an SSH key management process for Windows.
if [ -x /usr/bin/ssh-pageant ]; then
eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")
patricknelson /
Last active March 12, 2020 07:14
PHP function to split arrays up into chunks to do work on (basically pagination for callbacks).


Very simple but useful PHP function for performing work on large arrays of information. Basically, it's like pagination for callbacks. For example, this can be used for performing bulk database INSERT operations (instead of inserting each item individually). See below for a quick real world example.

Example Usage

patricknelson / - Using Xdebug in
Last active October 15, 2023 19:59
Using Xdebug in Docker (works with PhpStorm)

Using Xdebug in Docker

Getting setup and running with Xdebug in a docker container these days is now fairly simple and is composed of two main steps:

  1. Ensure you've got XDebug installed and enabled in your PHP docker image, for example:
    # Installing Xdebug with PHP 7.3 images:
    RUN pecl install xdebug \
      && docker-php-ext-enable xdebug
patricknelson / silverstripe-versioned-helpers.php
Last active December 29, 2018 02:05
Helper functions to cleanly alter versioned objects in SilverStripe
* Helper functions to cleanly alter versioned objects in SilverStripe.
* Usage:
* whileDraft(function() {
* $page = Page::get()->byId(123);
* // ... with great power comes great responsibility...
* });
patricknelson / OverrideControllerMaterial.cs
Last active May 15, 2021 22:08
Override the material and texture of default SteamVR HTC Vive controllers in Unity.
using UnityEngine;
using Valve.VR;
/// <summary>
/// Override the material and texture of the HTC Vive controllers, with your own material after SteamVR has loaded and
/// applied the original material. This is useful to help preserve interactions in the model itself.
/// NOTE: This is only compatible with the default HTC vive controllers (see UpdateControllerMaterial() below).
/// Modified by Patrick Nelson / chunk_split ( from original "OverrideControllerTexture" class
patricknelson / Quaternion.shader
Last active July 17, 2024 05:19 — forked from nkint/pointTowards.vertex
Shader functions to facilitate rotation of vertex around point with a quaternion (Unity / HLSL / Cg)
// Full shader example demonstrating how to use a quaterionion to rotate a vertex around a specific point. Note that this is just a plain
// vanilla unlit shader which includes the necessary functions (see section below) and example code in the vertex shader.
// Forked from
// Converted from GLSL to Cg. For help with that, see
// quaternion code from
// rotation from
Shader "Unlit/Quaternion"
class Injector extends Nestception {
// ... rest of class...
public static function unnestTemp($callable) {
// Retain current instance so we can revert back to it momentarily.
$revertTo = self::inst();