Skip to content

Instantly share code, notes, and snippets.

View thomasjbradley's full-sized avatar
🐢
Saving dinosaurs

Thomas J Bradley thomasjbradley

🐢
Saving dinosaurs
View GitHub Profile
@thomasjbradley
thomasjbradley / mobile.html
Last active October 6, 2015 10:18
html: iOS meta tags
<!--
http://blog.cloudfour.com/seven-things-i-learned-while-making-an-ipad-web-app-2/
-->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default|black|black-translucent">
<meta name="format-detection" content="telephone=no">
<!--
@thomasjbradley
thomasjbradley / uri.js
Created September 6, 2012 23:38 — forked from jlong/uri.js
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"
@thomasjbradley
thomasjbradley / retina.css
Last active June 29, 2018 06:48
css: retina media query
/* http://www.brettjankord.com/2012/11/28/cross-browser-retinahigh-resolution-media-queries/ */
/* 1.25 dpr */
@media (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
}
/* 1.3 dpr */
@media (-webkit-min-device-pixel-ratio: 1.3), (min-resolution: 124.8dpi) {
@thomasjbradley
thomasjbradley / svg-to-png.js
Last active October 11, 2015 11:58
js: svg to png
if (!Modernizr.inlinesvg) {
;(function () {
var imgs = document.getElementsByTagName('img')
, totalImgs = imgs.length
, i = 0
for (i = 0; i < totalImgs; i++) {
imgs[i].src = imgs[i].src.replace(/svg$/, 'png')
}
}())
@thomasjbradley
thomasjbradley / svg-to-png.css
Last active October 11, 2015 12:07
css: svg to png
.icon {
background: transparent url("../img/icon.svg") no-repeat left top;
}
/* Depends on Modernizr */
.no-inlinesvg .icon {
background-image: url("../img/icon.png");
}
@thomasjbradley
thomasjbradley / images-on.js
Last active October 12, 2015 08:18
js: detect if images on
/*
http://www.456bereastreet.com/archive/201211/using_javascript_to_check_if_images_are_enabled/
Will add the class `images-on` to <body>
Check if images are disabled: http://www.paciellogroup.com/blog/2011/10/detecting-if-images-are-disabled-in-browsers/
*/
(function() {
var image = new Image();
image.onload = function() {
if (image.width > 0) {
@thomasjbradley
thomasjbradley / deploy.sh
Last active October 13, 2015 17:18
Simple deployment with rsync
#!/usr/bin/env bash
rsync -e ssh -a -r --delete --delete-excluded --progress --compress --chmod=u=rwx,go=rx --exclude-from 'rsync-exclude.txt' ./ ssh-server-alias:/path/on/remote/server
@thomasjbradley
thomasjbradley / tv.css
Last active July 24, 2017 10:05
css: tv media query
/* http://people.opera.com/danield/utils/webtv.html */
@media tv, (width: 1920px) and (height: 1080px), (width: 1280px) and (height: 720px) {
}
@thomasjbradley
thomasjbradley / browse.py
Last active December 11, 2015 09:49
Launches my browser and goes to the correct vhost and folder from terminal
#!/usr/bin/env python
import os
cwd = os.getcwd().replace("/Users/thomasjbradley/Dropbox/www/", "")
domain = "http://"
dir_bits = cwd.split("/")
domain += dir_bits.pop(0)
domain += ".dev/"
@thomasjbradley
thomasjbradley / httpd-vhosts.conf
Created January 21, 2013 02:32
Dynamic vhost setup with Apache
NameVirtualHost *:80
NameVirtualHost *:443
<Virtualhost *:80>
VirtualDocumentRoot /www/%1
UseCanonicalName Off
SetEnv ENV dev
ServerName vhosts.dev
ServerAlias *.dev
ServerAlias *.xip.io