Skip to content

Instantly share code, notes, and snippets.

View justinallen's full-sized avatar
🔍
Looking for it

Justin Allen justinallen

🔍
Looking for it
View GitHub Profile
@justinallen
justinallen / regex.sh
Created March 23, 2021 05:36
Miscellaneous regex
# getting messy page numbers
^p. \(\#[0-9]{1,3}\)
# matches p. (#33)
# page headings with book title
^HARD TIMES. [0-9]{1,3}
# matches HARD TIMES. 101
@justinallen
justinallen / virtualenv-python-commands.sh
Created March 18, 2021 02:39
virtualenv python commands
# instantiate virtualenv with specific version of python
virtualenv -p /usr/bin/python3.7 venv
// great little typographic widow control script from chris coyier
// https://css-tricks.com/preventing-widows-in-post-titles
$("h2 a").each(function() {
var wordArray = $(this).text().split(" ");
if (wordArray.length > 1) {
wordArray[wordArray.length-2] += " " + wordArray[wordArray.length-1];
wordArray.pop();
$(this).html(wordArray.join(" "));
}
@justinallen
justinallen / shortcode.php
Created September 13, 2018 20:35
simple boilerplate wordpress shortcode
/**
* 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
justinallen / wordpress-image-classes-on-captioned-images.js
Created September 12, 2018 20:31
WordPress / jQuery snippet for moving custom image classes up to the caption on captioned images
/**
* 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
justinallen / unix-human-dates.py
Created April 17, 2018 22:22
Unix dates to human readable and back again, in Python
# cribbed / adapted from here http://partiallyattended.com/2011/10/13/managing-unix-time-in-python
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
justinallen / pretty-json.sh
Created November 21, 2017 01:13
pretty format a json file
python -m json.tool my_json.json > my_pretty_json.json
@justinallen
justinallen / notification.py
Created November 3, 2017 00:49
stupid simple email notification in python
# all thanks to nael shiab's post here: http://naelshiab.com/tutorial-send-email-python
# adding gist for my own reference / ease remembering
import smtplib
from_email = "########@gmail.com"
from_email_password = "somethingsecure"
to_email = "#######@some_email.com"
server = smtplib.SMTP('smtp.gmail.com', 587)
@justinallen
justinallen / x.svg
Created September 16, 2017 01:02
Simple SVG Shape: X
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@justinallen
justinallen / fb-metatags.html
Created July 6, 2017 18:15
Facebook Metatags
<!-- 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="http://website.com/image.jpeg"/>
<meta property="og:url" content="http://website.com/my-webpage.html"/>
<meta property="og:site_name" content="Webpage"/>