Skip to content

Instantly share code, notes, and snippets.

View gavinblair's full-sized avatar

Gavin Blair gavinblair

View GitHub Profile
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<polymer-element name="my-element">
@gavinblair
gavinblair / setTimeout.js
Last active August 29, 2015 14:04
Pass arguments to setTimeout
setTimeout(
(function(el){
return function(){
el.hide();
};
}($(this))), 2000);
div {
@include image-2x("logo.png", "logo2x.png");
}
@mixin image-2x($image1, $image2) {
background-image: url($image);
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
background-image: url($image2);
background-size: image-width($image1) image-height($image1);
}
while :; do cat /System/Library/Accessibility/AccessibilityDefinitions.plist | say -v Whisper; sleep 1; done
@gavinblair
gavinblair / pagination_view.php
Created June 7, 2010 15:33
Pagination Display
<ul class='pager'>
<?php
//The goal is to have a pager showing (if available) 5 numbers,
//with the current page number in the middle, if available.
// <<First and <Previous are shown if you can't see page 1,
// and Next> and Last>> are shown if you can't see the last page.
$start = $currentpage <= 2 ? 1 : $currentpage - 2;
$end = $currentpage > ($totalpages - 2) ? $totalpages : $currentpage + 2;
if ($end == $totalpages && $start > 2) {
$diff = $totalpages - $currentpage;
<select name=”gender”>
<option value=”1”>Male</option>
<option value=”2”>Female</option>
</select>
@gavinblair
gavinblair / thumbnail.php
Created June 8, 2010 15:19
Generate thumbnails on the fly
<?php
if (!isset($_GET['src'])) {
//for testing, navigate to thumbnail.php?img=page/to/yourimage.jpg
echo "<img src='/thumbnail.php?src={$_GET['img']}' />";
} else {
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header("Content-type: image/pjpeg");
@gavinblair
gavinblair / index.php
Created June 10, 2010 16:06
Load a mobile theme if the user is using a smartphone
<?php
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "iphone") !== FALSE
|| strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "ipod") !== FALSE
|| strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "android") !== FALSE
|| strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "blackberry") !== FALSE ) {
include 'mobile.php';
} else {
?><!DOCTYPE ...
var jQT = new $.jQTouch({
'icon': '/presentation/libraries/jqtouch/themes/mytheme/img/icon.png',
addGlossToIcon: true,
startupScreen: '/presentation/libraries/jqtouch/themes/mytheme/img/startup.png',
statusBar: 'black',
preloadImage: [
//...
],
useFastTouch: false //allows us to do $().submit() on forms
});