Skip to content

Instantly share code, notes, and snippets.

View uxjw's full-sized avatar

James Wilcox uxjw

  • Primal Communications Ltd.
  • BC, Canada
View GitHub Profile
@uxjw
uxjw / gitlg.sh
Last active August 29, 2015 14:20
Git lg alias - log skin
# https://coderwall.com/p/euwpig/a-better-git-log
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@uxjw
uxjw / tree.php
Last active August 29, 2015 14:20
PHP Associative array to tree
<?php
// Converts an array of single rows with a parent id column into a tree
function tree($rows){
// supplied array must be indexed by row id
$tree = array(); //stores the tree
$tree_index = array(); //an array used to quickly find nodes in the tree
$id_column = "id"; //The column that contains the id of each node
$parent_column = "parent"; //The column that contains the id of each node's parent
@uxjw
uxjw / _breakpoints.scss
Last active August 29, 2015 14:20
SCSS Breakpoints Mixin
/**
* Breakpoint mixins
*/
$breakpoints: (
mobile: ( min: 300px, max: 479px ),
mobile_ls: ( min: 480px, max: 759px ),
tablet: ( min: 760px, max: 1023px ),
tablet_ls: ( min: 1024px, max: 1279px ),
laptop: ( min: 1280px, max: 1499px ),
@uxjw
uxjw / wordTrim.php
Last active August 29, 2015 14:20
Trim a string to a set length of words
<?php
// Shorten a string to a specific word count
function wordTrim($str,$maxwords=25, $more = '...'){
$words = explode(' ',trim($str));
if(count($words) > $maxwords)
{
$newStr = array();
for($i=0;$i<$maxwords;$i++)
$newStr[] = $words[$i];
@uxjw
uxjw / youtube-embed.txt
Created May 7, 2015 00:01
Youtube iFrame, Minimal branding
https://www.youtube.com/embed/VIDEOID?rel=0&controls=0&modestbranding=1&showinfo=0&hd=1&autoplay=1
@uxjw
uxjw / select_country.html
Created May 7, 2015 00:03
County Code Select
<!-- Generated from http://www.iso.org/iso/country_codes.htm on 2013/01/22 -->
<select name="country">
<option value="AF">AFGHANISTAN</option>
<option value="AX">&Aring;LAND ISLANDS</option>
<option value="AL">ALBANIA</option>
<option value="DZ">ALGERIA</option>
<option value="AS">AMERICAN SAMOA</option>
<option value="AD">ANDORRA</option>
<option value="AO">ANGOLA</option>
<option value="AI">ANGUILLA</option>
@uxjw
uxjw / tinymce_functions.php
Created May 7, 2015 00:05
Prevent TinyMCE from stripping schema.org Metadata
<?php
// Prevent TinyMCE from stripping out schema.org metadata
function schema_TinyMCE_init($in)
{
/**
* Edit extended_valid_elements as needed. For syntax, see
* http://www.tinymce.com/wiki.php/Configuration:valid_elements
*
* NOTE: Adding an element to extended_valid_elements will cause TinyMCE to ignore
/*
Fluid App Userscript
FastMail beta web interface
URL pattern: *fastmail.fm/mail/*
Based on https://github.com/melomac/Fluid
*/
@uxjw
uxjw / .htaccess
Last active January 30, 2016 06:38
Wordpress .htaccess Protections and Caching
Options +FollowSymlinks -Indexes
RewriteEngine On
# Disable the Server Signature
ServerSignature Off
# BEGIN WordPress
# Except for requests for /index.php and for the most-frequently-requested
# filetypes that WP cannot generate, rewrite all URL requests which do not
# resolve to an existing file or directory to the WordPress script filepath
@uxjw
uxjw / ios_vh_fix.css
Created December 15, 2016 07:57
iOS doesn't swap vh and vw like you would expect in landscape view, so we have to set these manually
/* fix iOS bug not displaying 100vh correctly */
/* iPad Pro */
@media only screen and (min-device-width : 1024px) and (max-device-width : 1366px) and (orientation : landscape) {
.fullheight {
height: 1024px;
}
}
@media only screen and (min-device-width : 1024px) and (max-device-width : 1366px) and (orientation : portrait) {
.fullheight {