Skip to content

Instantly share code, notes, and snippets.

@jonshipman
jonshipman / ScrollToTop.js
Created May 27, 2020 16:25
Scroll to top on internal navigation | React Component
// React Component
// Navigation within app will scroll to top.
import { Component } from 'react';
import { withRouter } from 'react-router-dom';
class ScrollToTop extends Component {
componentDidUpdate(prevProps) {
if (this.props.location !== prevProps.location) {
window.scrollTo(0, 0);
@jonshipman
jonshipman / Animate.js
Last active June 5, 2020 15:32
Animate React Component
import React, { Component, createRef } from 'react';
class _sharedScrollHandler {
functions = []
attached = false;
constructor() {
this.boundHandler = this.handleScroll.bind(this);
this.addFun = this.add.bind(this);
this.removeFun = this.remove.bind(this);
const keyGeneration = ({ loading, value }) => {
return loading
? `loading-${value}-${new Date().getTime()}`
: `loaded-${value}-${new Date().getTime()}`;
};
const Select = forwardRef(function Select(
{
id,
label,
@jonshipman
jonshipman / thememods-gql.php
Last active November 19, 2020 15:54
Adds themeMods to WP-Graphql
<?php
/**
* Registers the field ThemeMod
*
* @return void
*/
function gql_theme_mod() {
$_mods = get_theme_mods();
$config = array();
@jonshipman
jonshipman / docker-compose.yml
Created March 11, 2021 16:19
WordPress Docker-compose
version: '3.7'
services:
db:
image: mariadb:10.1.41
restart: always
environment:
MYSQL_DATABASE: WORDPRESS
MYSQL_USER: WORDPRESS
MYSQL_PASSWORD: WORDPRESS
@jonshipman
jonshipman / wc-product-attributes-dedupe.php
Created April 7, 2021 18:32
Woocommerce Product Attribute Dedupe
<?php
/**
* Product Attribute DeDupe
*
* @package Divide
*/
/**
* Product Attributes in Woocommerce are only checked in this tables for "register_taxonomy" loop.
* Deleting duplicates in this table does not require reassigning IDs. Terms are related to taxonomies by name only.
@jonshipman
jonshipman / Disconnect RDP and Restart Gamestream.BAT
Created May 18, 2021 14:59
Restart NVIDIA Gamestream after RDP session
@echo off
REM kill the RDP clipboard to prevent errors...
taskkill /f /t /im rdpclip.exe
REM disconnects all active RDP sessions...
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
@jonshipman
jonshipman / screenfetch.txt
Created November 6, 2021 18:15
Gateway Screenfetch
./+o+- jon@Gateway
yyyyy- -yyyyyy+ OS: Ubuntu 21.04 hirsute
://+//////-yyyyyyo Kernel: x86_64 Linux 5.11.0-37-generic
.++ .:/++++++/-.+sss/` Uptime: 2h 4m
.:++o: /++++++++/:--:/- Packages: 1656
o:+o+:++.`..```.-/oo+++++/ Shell: bash 5.1.4
.:+o:+o/. `+sssoo+/ Resolution: 1280x800
.++/+:+oo+o:` /sssooo. DE: Xfce
/+++//+:`oo+o /::--:. WM: Xfwm4
\+/+o+++`o++o ++////. WM Theme: Greybird
@jonshipman
jonshipman / .gitalb-ci.yml
Created November 16, 2021 17:23
Add cwebp to a gitlab runner ci yaml (docker image)
before_script:
- apt-get update -y
- apt-get install curl -y
- curl https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.4.1-linux-x86-64.tar.gz -o cwebp.tar.gz
- tar -zxvf cwebp.tar.gz
- export PATH="$PATH:$(realpath libwebp-0.4.1-linux-x86-64/bin)"
# Set these as "RUN" commands and you can use these in any dockerfile.
@jonshipman
jonshipman / Set-ScreenResolution.ps1
Created February 7, 2022 13:59
Change Screen resolution with powershell.exe (not pwsh.exe core!)
# REF: https://kindleit.blogspot.com/2012/09/changing-screen-resolution-with.html
# Execute via ``powershell.exe -File .\path-to-script.ps1 1920 1080``
param (
[Parameter(Mandatory=$true, Position = 0)]
[int]
$Width,
[Parameter(Mandatory=$true, Position = 1)]
[int]
$Height