Skip to content

Instantly share code, notes, and snippets.


Dave Shepard kynatro

View GitHub Profile
jonathantneal /
Last active Sep 8, 2021
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\"
jamiehs / 01-modal_content.html
Last active Aug 29, 2015
Assuming the below HTML with the video class on the modal and the video URL as the data attribute on the video content.
View 01-modal_content.html
<a data-toggle="modal" data-target=".bs-modal-lg">Open Modal</a>
<div class="modal fade bs-modal-lg video" tabindex="-1" role="dialog" aria-labelledby="VideoModal" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" data-video-url="//;byline=0&amp;title=0&amp;autoplay=1">
<div class="fve-video-wrapper fve-image-embed fve-thumbnail-image youtube" style="padding-bottom:56.25%;">
<iframe src="" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
scoates / twitter_user_to_image
Last active Dec 19, 2015
Get a twitter profile image from a username. We route around bad APIs. Twitter wears the scumbag hat, these days.
View twitter_user_to_image
# Usage: $0 username
# e.g.:
# $ ./twitter_user_to_image coates
curl -sL$1 | grep profile_images | head -n1 | perl -p -e's/.*?http/http/;s/".*//;s/_bigger//'
paulirish /
Last active Sep 11, 2021 polyfill (aka
// @license
// copyright Paul Irish 2015
// is supported everywhere except IE8. For IE8 we use the polyfill
// as Safari 6 doesn't have support for NavigationTiming, we use a timestamp for relative values
// if you want values similar to what you'd get with real, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "";
parser.protocol; // => "http:"
parser.hostname; // => ""
parser.port; // => "3000"
parser.pathname; // => "/pathname/"; // => "?search=test"
parser.hash; // => "#hash"; // => ""
pauljamesrussell / spec_helper.rb
Created Nov 9, 2011
RSpec matcher for ensuring a model is accepting nested attributes for an association, and accepting/rejecting the right values.
View spec_helper.rb
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })}
RSpec::Matchers.define :accept_nested_attributes_for do |association|
match do |model|
@model = model
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym)
if @nested_att_present && @reject
@reject_success = model.send("#{association}").empty?
View gist:527683
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
View stylesheetLoadDetection.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<meta charset="UTF-8">
<title>Detecting Stylesheet Load Test</title>
<script src=""></script>
<script type="text/javascript">
jQuery(function () {
var css = document.createElement('link');
css.type = 'text/css';