Skip to content

Instantly share code, notes, and snippets.

View caseymhunt's full-sized avatar
🐢
Slower is better.

Casey Hunt caseymhunt

🐢
Slower is better.
View GitHub Profile
@caseymhunt
caseymhunt / DefaultKeyBinding.dict
Created October 4, 2018 20:43 — forked from trusktr/DefaultKeyBinding.dict
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
@caseymhunt
caseymhunt / CPU & Fan Health : Today Scripts
Created April 27, 2015 22:25
CPU & Fan Health script for Today-Scripts project; Requires iStats
echo -e "--- CPU Stats ---";
istats cpu;
echo -e "\n--- Fan Stats ---";
istats fan;
@caseymhunt
caseymhunt / Battery Status : Today-Scripts
Last active August 29, 2015 14:20
A script for the Today-Scripts project which adds a battery status to the sidebar- includes mouse battery status.
full=$(pmset -g batt | { read; read n full; echo "$full"; })
batt=$(echo "$full" | cut -d';' -f1 | tr -d '%')
status=$(echo "$full" | cut -d';' -f2 | tr -d ' ')
time=$(echo "$full" | cut -d';' -f3 | sed 's/^ *//')
mousebatt=$(ioreg -n "BNBMouseDevice" | grep -i '"batterypercent" =' | sed 's/[^[:digit:]]//g')
noc=$'\e[39m'
if (($batt >= 66)); then battc=$'\e[32m';
elif (($batt >= 33)); then battc=$'\e[33m';
else battc=$'\e[31m';
@caseymhunt
caseymhunt / functions.php
Created July 25, 2013 23:06
Wordpress - strictly for debugging; used in functions.php of your theme- this will display the path/filename of any current page's template file in use.
<?php
add_action('wp_head', 'show_template');
function show_template() {
global $template;
print_r($template);
}
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@caseymhunt
caseymhunt / gist:5920945
Created July 3, 2013 17:48
JS & jQuery script that only allows numbers in a specified text field based on vanilla JS key mappings(code): http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
$('#elementID').keydown(function (event) {
if (event.keyCode > 57) {
if (event.keyCode < 96 || event.keyCode > 105) {
event.preventDefault();
}
}
});
@caseymhunt
caseymhunt / wp-redirect
Created July 3, 2013 16:09
A function for Wordpress (functions.php) that will redirect (301) using the value in a custom field named 'redirect.' Special thanks to: http://thisismyurl.com/6598/wordpress-redirect-single-post/ -- code originally from there, edited to suit my needs.
<?php
function thecasey_redirect() {
if ( is_page() ) {
global $post;
$post_id = $post->ID;
if ( !empty( $post_id ) )
$redirect = get_post_meta ( $post_id, 'redirect', true);
@caseymhunt
caseymhunt / wp_postlimit_override.php
Last active December 16, 2015 00:29
A wordpress functions.php code snippet that overrides the user controlled post limit so that certain post types or pages will display all or a declared number of posts rather than obey this limit.
<? // Open tag added for proper color formatting- DO NOT COPY THIS LINE
// Function to override the set value of Post Limit in Wordpress
function theme_post_override ( $query ) {
// Only act on author pages
if ( is_author() ) {
// Display ALL posts
$query->set( 'posts_per_page', -1 );
return;
@caseymhunt
caseymhunt / spotlights.html
Last active May 6, 2016 23:18
Example of animated spotlights using HTML5 & CSS3
<!DOCTYPE html>
<html>
<head>
<style>
body { background-color: black; color: white;}
.spot1 { left: 40%; -webkit-animation: move 5s infinite;}
.spot2 { left: 60%; -webkit-animation: move2 5s infinite;}
.spotlight {
position: absolute;
width: 53px;
@caseymhunt
caseymhunt / parselogfile.pl
Created January 14, 2013 21:29
Lang: PERL Descrip: Log parser- looks for a line in apache log that contains 'searchbox.php' then grabs the arguments passed in the URL with the names, query, engine and subengine. Dumps the results into a file with -parsed.log appended to source filename.
#!/usr/bin/perl -w
use URI::Escape; #Use URI decoding module.
$#ARGV >= 0 or die "No log file name supplied.";
#Assign argument (source file) to variable
$filename = $ARGV[0] . "-parsed.log";
#Print start message in terminal.
print "\n *** Processing log file for\: $ARGV[0] ***\n \n";
print "Please wait... \n";