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 / validate-email.js
Created October 7, 2015 18:57
quick basic email validation in javascript
// returns false unless valid
function validateEmail(email)
{
var re = /\S+@\S+\.\S+/;
return re.test(email);
}
@justinallen
justinallen / grab-a-hash.js
Created December 3, 2015 22:19
grab a hash
var hash = window.location.hash;
if (hash == "#hashish" || pathArray[0] == "#hashish") {
// do stuff
}
@justinallen
justinallen / social.html
Last active January 21, 2016 01:52
simple social buttons for an mvc template
<div class="share-bar">
<h5>Share on:</h5>
<a href="https://twitter.com/intent/tweet?text={{title}}&url={{absoluteUrl}}&via={{twitterUser}}&related={{twitterUser}}" rel="nofollow" target="_blank" title="Share on Twitter">
<img src="/images/social-icons/twitter.png" alt="twitter icon">
</a>
<a href="https://facebook.com/sharer.php?u={{absoluteUrl}}" rel="nofollow" target="_blank" title="Share on Facebook">
<img src="/images/social-icons/facebook.png" alt="facebook icon">
</a>
<a href="https://plus.google.com/share?url={{absoluteUrl}}" rel="nofollow" target="_blank" title="Share on Google+">
<img src="/images/social-icons/googleplus.png" alt="google plus icon">
@justinallen
justinallen / wget-example.txt
Created September 17, 2016 22:53
wget download website
$ wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--domains example.us \
--no-parent \
example.us
/**
* 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"
@justinallen
justinallen / detectIE.js
Created June 22, 2017 22:47
IE Detection in JavaScript
// 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) {
@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"/>
@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 / 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 / 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