Skip to content

Instantly share code, notes, and snippets.

View shawn-crigger's full-sized avatar

Shawn Crigger shawn-crigger

View GitHub Profile
@shawn-crigger
shawn-crigger / date-percentage.php
Created February 15, 2020 13:26
This class can calculate the percentage of the days that passed.
<?php
/*
*I dont know if this can be useful for you but
*
*I came up with it, and I give it as a present to you.
*
*I'm not a skillful programmer, I just enjoy doing this,
*
*Thanks for reading
*********************************************************

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@shawn-crigger
shawn-crigger / webdev_tools.md
Created July 15, 2019 14:07 — forked from slow-is-fast/webdev_tools.md
Web Development Tools
@shawn-crigger
shawn-crigger / gist:6a6eaba39cae113eb8d767be1b99aa15
Created November 9, 2018 16:10 — forked from johnfmorton/gist:3abf28530a7c4ea15b62
Slightly modified version of http://detectmobilebrowsers.com/ JS script to detect mobile. This includes tablets
// returns true is browser is mobile
// added "|android|ipad|playbook|silk" to first regex to detect tablets
// This leaves 2 'android' tests in the first regex. One of the 'android' tests can be eliminated
// but left in so you can remove the "|android|ipad|playbook|silk" string easily.
function isMobile() {
var a = navigator.userAgent||navigator.vendor||window.opera;
if (/(android|bb\d+|meego|android|ipad|playbook|silk).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)
@shawn-crigger
shawn-crigger / fluid-ratio.scss
Created November 9, 2018 16:10 — forked from jakejscott/fluid-ratio.scss
Fluid Ratio images
// credit Rolf Timmermans
// http://voormedia.com/blog/2012/11/responsive-background-images-with-fixed-or-fluid-aspect-ratios
/* Calculate fluid ratio based on two dimensions (width/height) */
@mixin fluid-ratio($large-size, $small-size) {
$width-large: nth($large-size, 1);
$width-small: nth($small-size, 1);
$height-large: nth($large-size, 2);
$height-small: nth($small-size, 2);
$slope: ($height-large - $height-small) / ($width-large - $width-small);
@shawn-crigger
shawn-crigger / pds-remover.sh
Created November 9, 2018 16:10 — forked from strika/pds-remover.sh
Bash script for removing all PSD files from a repo history.
#!/bin/bash
set -o errexit
git filter-branch --tree-filter "git rm -r -f --ignore-unmatch *.psd" HEAD
rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune
@shawn-crigger
shawn-crigger / Marker.js
Created November 9, 2018 16:07 — forked from ttscoff/Marker.js
Bookmarklet for Markdownifying webpage selections
// Marker, a bookmarklet for Markdownifying webpage selections
// javascript:(function(){var p=document.createElement("p");p.innerHTML="<strong>Loading&hellip;</strong>";p.id="loadingp";p.style.padding="20px";p.style.background="#fff";p.style.left="20px";p.style.top=0;p.style.position="fixed";p.style.zIndex="9999999";p.style.opacity=".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src="https://gist.github.com/ttscoff/8078727/raw/Marker.js?x="+(Math.random());})();
(function () {
function callback() {
(function ($) {
var raw, userSelection;
if (window.getSelection) {
// W3C Ranges
userSelection = window.getSelection ();
// Get the range:
@shawn-crigger
shawn-crigger / functions.php
Created October 26, 2018 15:17
Adds new user to wp, created like this because user table was broken and wp_insertuser was not working due to duplicate primary id equal 0 error
<?php
if ( isset( $_GET['test'] ) && 'shawn' == $_GET['test'] ) :
add_action('init', 'make_user');
endif;
function make_user() {
global $wpdb;
$wpdb->show_errors();
@shawn-crigger
shawn-crigger / random_chars.php
Last active June 13, 2018 17:01
Returns random characters
function _make_token( $length = 16 )
{
$token = "";
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
$codeAlphabet.= "0123456789";
$max = strlen($codeAlphabet); // edited
for ($i=0; $i < $length; $i++) {
token .= $codeAlphabet[random_int(0, $max-1)];
}
@shawn-crigger
shawn-crigger / country_array.php
Last active January 7, 2018 03:19
ISO Country List Array
<?php
/**
* Array of Countries with ISO value as keys
* @var array
*/
$countries = array( 'AF' => 'Afghanistan', 'AX' => 'Åland Islands', 'AL' => 'Albania', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AI' => 'Anguilla', 'AQ' => 'Antarctica', 'AG' => 'Antigua and Barbuda', 'AR' => 'Argentina', 'AM' => 'Armenia', 'AW' => 'Aruba', 'AU' => 'Australia', 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BS' => 'Bahamas', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BB' => 'Barbados', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BZ' => 'Belize', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BT' => 'Bhutan', 'BO' => 'Bolivia', 'BA' => 'Bosnia and Herzegovina', 'BW' => 'Botswana', 'BV' => 'Bouvet Island', 'BR' => 'Brazil', 'IO' => 'British Indian Ocean Territory', 'BN' => 'Brunei Darussalam', 'BG' => 'Bulgaria', 'BF' => 'Burkina Faso', 'BI' => 'Burundi', 'KH' => 'Cambodia', 'CM' => 'Cameroon', 'CA' => 'Canada', 'CV' => 'Cape Verde', 'KY' => 'Cayman Islands', 'CF' => 'Central African Republic', 'TD' =