Skip to content

Instantly share code, notes, and snippets.

View tylerpearson's full-sized avatar

Tyler Pearson tylerpearson

View GitHub Profile
tylerpearson /
Last active December 10, 2015 15:09
Delay load of social scripts
loadSocialScripts = ->
# Facebook
script = document.createElement('script')
script.async = true; = 'facebook-jssdk'
script.src = '//'
# Twitter
tylerpearson / less-retina-mixin.less
Last active December 10, 2015 19:19
LESS mixin to make optimization for Retina and high-dpi screens easier.
// media queries are escaped to prevent potential LESS rendering errors
// adapted from
@mediaRetina: ~"(min-resolution: 124dpi), (-webkit-min-device-pixel-ratio: 1.3), (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 4/3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx)";
.image-2x(@image, @width, @height) {
@media @mediaRetina {
background-image: url('@{image}');
background-size: @width @height;
tylerpearson /
Last active December 17, 2015 22:08
generate a wrapper file

Quick steps to generate a wrapper file from a Hifi site

  1. Make sure you have wget installed on your machine. With Homebrew use brew install wget.
  2. Put wrapper.rb in the directory where you want the files to be saved.
  3. Run the script: ruby wrapper.rb The first and only argument is the url for an interior page that should be used as the template for the wrapper. A home page could be used, but it's unlikely you'd want that for a wrapper. The url should look something like
  4. Manually change the title, and change or remove any extra headers or content.

This should work with sites using an SSL because the assets should all be saved in the wrapper template directory.

<!-- your site's markup -->
<!-- start popup -->
<div id="CoverPop-cover" class="splash">
<div class="CoverPop-content splash-center">
<!-- the popup content (form, welcome message, etc.) -->
tylerpearson / NMC-splash.js
Last active December 18, 2015 23:49
JS script with cookie integration for redirecting visitors to a splash page. jQuery free.
var NMC = NMC || {};
NMC.util.Splash = (function () {
"use strict";
var daysBeforeCookieExpires = 30,
createCookie = function(name, value, expires, path, domain) {
var cookie = name + "=" + escape(value) + ";";
if (expires) {
tylerpearson / content.html
Last active December 19, 2015 20:49
Create custom "Share on Twitter" and "Share on Facebook" buttons
<a class="js-share-button" target="_blank" data-button-name="Twitter" href="">Share on Twitter</a>
<a class="js-share-button" target="_blank" data-button-name="Facebook" href="">Share on Facebook</a>
<!-- set more Facebook info in the OG tags -->
tylerpearson / twlinkify.js
Created July 18, 2013 03:53
a simple jQuery plugin to add links to the text of tweets
// Twlinkify
// an absurdly simple jQuery plugin to linkify the text of tweets
;(function($) {
// from
function addTwitterLinks(text) {
var e = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
text = text.replace(e, "<a href='$1' target='_blank'>$1</a>");
e = /(^|\s)#(\w+)/g;
(function(w, d, s) {
function go(){
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.src = url; = id;
fjs.parentNode.insertBefore(js, fjs);
load('//', 'fbjssdk');
load('//', 'tweetjs');
tylerpearson /
Created October 5, 2013 16:58
1000 most followed Twitter accounts by NFL players
tylerpearson /
Created October 5, 2013 18:05
1000 most followed Twitter accounts by NBA players