Skip to content

Instantly share code, notes, and snippets.

Looking for it

Justin Allen justinallen

Looking for it
Block or report user

Report or block justinallen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View typographic-widow-control.js
// great little typographic widow control script from chris coyier
$("h2 a").each(function() {
var wordArray = $(this).text().split(" ");
if (wordArray.length > 1) {
wordArray[wordArray.length-2] += " " + wordArray[wordArray.length-1];
$(this).html(wordArray.join(" "));
justinallen / shortcode.php
Created Sep 13, 2018
simple boilerplate wordpress shortcode
View shortcode.php
* Boilerplate WordPress shortcode - can drop into functions.php
* Use: [bananify this="thing to add a banana to"]
function bananify_func( $atts ) {
$a = shortcode_atts( array(
'this' => 'something'
), $atts );
justinallen / wordpress-image-classes-on-captioned-images.js
Created Sep 12, 2018
WordPress / jQuery snippet for moving custom image classes up to the caption on captioned images
View wordpress-image-classes-on-captioned-images.js
* Hoist custom image classes up to the caption that wraps it
$('figure.wp-caption').each(function() {
var caption = $(this);
caption.removeAttr('width').css('width', ''); // remove width attribute
var img = $(this).find('img');
var imgClasses = img.attr('class').split(/\s+/); // list of classes
imgClasses.forEach(function(element) {
img.removeClass(element); // remove from image
justinallen /
Created Apr 17, 2018
Unix dates to human readable and back again, in Python
# cribbed / adapted from here
from time import strftime
from datetime import datetime
from datetime import date
from time import mktime
# convert unix to human-readable
def unix_to_human(unix_date):
human_date = datetime.fromtimestamp(int(unix_date/1000.0)).strftime('%Y-%m-%d %H:%M:%S')
return human_date
justinallen /
Created Nov 21, 2017
pretty format a json file
python -m json.tool my_json.json > my_pretty_json.json
justinallen /
Created Nov 3, 2017
stupid simple email notification in python
# all thanks to nael shiab's post here:
# adding gist for my own reference / ease remembering
import smtplib
from_email = ""
from_email_password = "somethingsecure"
to_email = ""
server = smtplib.SMTP('', 587)
justinallen / x.svg
Created Sep 16, 2017
Simple SVG Shape: X
View x.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View fb-metatags.html
<!-- Facebook meta tags -->
<meta property="og:title" content="My Webpage"/>
<meta property="og:description" content="In 2017, a webpage was created by me."/>
<meta property="og:image" content=""/>
<meta property="og:url" content=""/>
<meta property="og:site_name" content="Webpage"/>
justinallen / detectIE.js
Created Jun 22, 2017
IE Detection in JavaScript
View detectIE.js
// just a slimmed-down implementation of browser testing for IE in JavaScript
// based on code I found online
* detect IE
* returns version of IE or false, if browser is not Internet Explorer
function detectIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
View bigNumberFormat.js
* Nicely format large numbers to make them readable:
* Billions to one decimal like "$1.3 billion"
* Millions to nearest million like "$346 million"
* Thousands to nearest thousand like "$144,000"
* @param {number} The number to format
* @returns {string} Readable string with dollar sign and amount
function niceBigNumber(num) {
// format billions to one decimal like "$1.3 billion"
You can’t perform that action at this time.