Skip to content

Instantly share code, notes, and snippets.

@jamiehs
jamiehs / 01-modal_content.html
Last active August 29, 2015 13:55
Assuming the below HTML with the video class on the modal and the video URL as the data attribute on the video content.
<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="//player.vimeo.com/video/84747519?portrait=0&amp;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>
</div>
</div>
</div>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Detecting Stylesheet Load Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function () {
var css = document.createElement('link');
css.type = 'text/css';
@scoates
scoates / twitter_user_to_image
Last active December 19, 2015 09:49
Get a twitter profile image from a username. We route around bad APIs. Twitter wears the scumbag hat, these days.
#!/bin/bash
# Usage: $0 username
# e.g.:
# $ ./twitter_user_to_image coates
# https://si0.twimg.com/profile_images/1597362183/me.jpg
curl -sL http://twitter.com/$1 | grep profile_images | head -n1 | perl -p -e's/.*?http/http/;s/".*//;s/_bigger//'
@pauljamesrussell
pauljamesrussell / spec_helper.rb
Created November 9, 2011 23:15
RSpec matcher for ensuring a model is accepting nested attributes for an association, and accepting/rejecting the right values.
# 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
model.send("#{association}_attributes=".to_sym,[@reject])
@reject_success = model.send("#{association}").empty?
end
model.send("#{association}").clear
@paulirish
paulirish / performance.now()-polyfill.js
Last active August 1, 2023 15:42
performance.now() polyfill (aka perf.now())
// @license http://opensource.org/licenses/MIT
// copyright Paul Irish 2015
// Date.now() is supported everywhere except IE8. For IE8 we use the Date.now polyfill
// github.com/Financial-Times/polyfill-service/blob/master/polyfills/Date.now/polyfill.js
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, 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
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
// ----------------------------------------------------------
// 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) {}
@jonathantneal
jonathantneal / README.md
Last active March 19, 2024 23:31
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\ Text.app/Contents/SharedSupport/bin/subl"