Skip to content

Instantly share code, notes, and snippets.

View gMagicScott's full-sized avatar

Scott Lesovic gMagicScott

View GitHub Profile
@gMagicScott
gMagicScott / caps-lock-remap.ahk
Created April 24, 2020 20:31
Using AutoHotKey, remap Caps Lock to be <Esc> when tapped (under 400ms), acts as <Ctrl> when used in combo shortcuts
*CapsLock::
Send {Blind}{Ctrl Down}
cDown := A_TickCount
Return
*CapsLock up::
If ((A_TickCount-cDown)<400) ; Modify press time as needed (milliseconds)
Send {Blind}{Ctrl Up}{Esc}
Else
Send {Blind}{Ctrl Up}
@gMagicScott
gMagicScott / install-cgr.sh
Last active July 18, 2017 02:14
Migrate Composer Globals to CGR
#!/usr/bin/env bash
# Helper script to help migrate Composer (https://getcomposer.org/)
# global scripts to being managed by CGR (https://github.com/consolidation/cgr)
#
# Copyright (c) 2017 Scott Lesovic
# Released under the MIT License
# Sanity check Composer
which composer
<?php
//* Do NOT include the opening php tag
//* Add JS to allow elements to be faux anchors
add_action( 'wp_footer', 'bg_script_clickable' );
function bg_script_clickable() {
echo '<script type="text/javascript">jQuery(document).ready(function($){$(".content .entry").click(function(){window.open($("a",this).attr("href"), "_blank");});});</script>';
}
@gMagicScott
gMagicScott / vagrant-box-update-all.sh
Last active August 9, 2018 15:40 — forked from thom8/vagrant-box-update-all.sh
Update all your vagrant base boxes
#!/bin/bash
# Find all boxes which have updates
AVAILABLE_UPDATES=`vagrant box outdated --global | grep outdated | tr -d "*'" | cut -d ' ' -f 2`
if [ ! ${#AVAILABLE_UPDATES[@]} -eq 0 ]; then
for box in $AVAILABLE_UPDATES ; do
echo "Found an update for $box"
@gMagicScott
gMagicScott / README.md
Created November 25, 2015 18:04
Ansible - remove unmanaged files from a directory

from this question on Stack Overflow

Set up a managed_files variable as an array

- hosts: whatever
  vars:
    managed_files:
     - file1
 - file2
add_filter( 'author_link', 'prefix_adjust_author_link', 10, 3 );
function prefix_adjust_author_link( $link, $author_id, $author_nicename ) {
$author_id = intval( $author_id ); // Sanitize
$user_info = get_userdata( $author_id );
if ( ! $user_info ) {
return $link;
}
$link = home_url( '/' ) . 'who/' . $user_info->user_login;
@gMagicScott
gMagicScott / gist:1edf8534a408fbf40607
Created September 30, 2014 22:35
Sudo aware bash prompt
LOGNAME=$(logname)
UUSER=$([ "${LOGNAME}" = "${USER}" ] && echo ${USER} || echo '$(tput setaf 1)${LOGNAME}$(tput sgr0) as ${USER}')
PS1="[${UUSER}@\h \W]\\$ "
@gMagicScott
gMagicScott / README.md
Created April 21, 2014 03:52
Disable jQuery Migrate

I drop this in WPMU_PLUGIN_DIR when developing.

WPMU_PLUGIN_DIR defaults to wp-content/mu-plugins/ but is configurable in wp-config.php

sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
@gMagicScott
gMagicScott / gist:8107042
Last active January 1, 2016 06:49
Decoding PHP injection on WordPress files. **!! Do NOT run this code on your machine !!**
<?php
/**
* There are layers of protection to check a few things
* - Only run this code once
* - Only run when accessed by Google, MSN, or Yahoo!
*
* I removed those checks to make this more readable
*/