Skip to content

Instantly share code, notes, and snippets.

View tylerpearson's full-sized avatar

Tyler Pearson tylerpearson

View GitHub Profile
@tylerpearson
tylerpearson / delay-social-load.coffee
Last active December 10, 2015 15:09
Delay load of social scripts
loadSocialScripts = ->
# Facebook
script = document.createElement('script')
script.async = true;
script.id = 'facebook-jssdk'
script.src = '//connect.facebook.net/en_US/all.js#xfbml=1'
document.body.appendChild(script)
# Twitter
@tylerpearson
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 http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
@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
tylerpearson / README.md
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 http://www.newmediacampaigns.com/about. 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 http://www.kevinstrouse.com/about.
  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.

<body>
<!-- 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
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
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="http://twitter.com/home?status=I%27m%20tweet%20content%20that%20ideally%20should%20be%20encoded">Share on Twitter</a>
<a class="js-share-button" target="_blank" data-button-name="Facebook" href="http://facebook.com/sharer.php?u=http%3A%2F%2Fwww.example.com">Share on Facebook</a>
<!-- set more Facebook info in the OG tags -->
@tylerpearson
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 http://stackoverflow.com/questions/8020739/regex-how-to-replace-twitter-links
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;
<script>
(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; js.id = id;
fjs.parentNode.insertBefore(js, fjs);
};
load('//connect.facebook.net/en_US/all.js#appId=changetoappid&xfbml=1', 'fbjssdk');
load('//platform.twitter.com/widgets.js', 'tweetjs');
@tylerpearson
tylerpearson / nfl-players-top-1000.md
Created October 5, 2013 16:58
1000 most followed Twitter accounts by NFL players
@tylerpearson
tylerpearson / nba-most.md
Created October 5, 2013 18:05
1000 most followed Twitter accounts by NBA players