Skip to content

Instantly share code, notes, and snippets.

@jeremyworboys
jeremyworboys / is_blog.php
Created February 9, 2012 05:54 — forked from wesbos/is_blog.php
WordPress: is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post);
return (($posttype == 'post') && ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())));
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@jeremyworboys
jeremyworboys / gist:1990311
Created March 7, 2012 01:30
CSS: Image Replacement
.ir {
border: 0;
color: transparent;
font: 0/0 a;
text-shadow: none;
}
@jeremyworboys
jeremyworboys / sc-dl.js
Created March 12, 2012 08:46 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl, pl, ps = d.querySelectorAll('.large.player, .medium.player');
for (var i = ps.length - 1; i >= 0; i--) {
pl = ps[i];
dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+pl.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = pl.querySelector('.info-header h1, .info-header h3').innerText+'.mp3';
pl.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
@jeremyworboys
jeremyworboys / gist:2049932
Created March 16, 2012 12:45
Wordpress: Start Widget
<?php
error_reporting(E_ALL);
/*
Plugin Name: PLUGIN_NAME
Plugin URI: PLUGIN_URI
Description: PLUGIN_DESCRIPTION
Version: 1.0
Author: Jeremy Worboys
@jeremyworboys
jeremyworboys / placeholder.scss
Created April 4, 2012 00:42 — forked from antsa/placeholder.scss
SCSS: Placeholder
// Placeholder @mixin for Sass
//
// A mixin to style placeholders in HTML5 form elements.
// Includes also a .placeholder class to be used with a polyfill e.g.
// https://github.com/mathiasbynens/jquery-placeholder
// Requires Sass 3.2.
//
// Example usage (.scss):
//
// input {
@jeremyworboys
jeremyworboys / gist:2395306
Created April 15, 2012 23:25
CSS: clearfix
.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
@jeremyworboys
jeremyworboys / gist:2403838
Created April 17, 2012 06:11
jQuery: Responsive Nav Generator
/**
* Helper Function
--------------------------------------------------------------------------*/
String.prototype.repeat = function(count) {
if (count < 1) return '';
var result = '', pattern = this.valueOf();
while (count > 0) {
if (count & 1) result += pattern;
count >>= 1, pattern += pattern;
@jeremyworboys
jeremyworboys / gist:2556435
Created April 30, 2012 08:08
Javascript: Fix iOS inappropriate zooming
/*! A fix for the iOS orientationchange zoom bug.
Script by @scottjehl, rebound by @wilto.
MIT License.
*/
(function(w){
// This fix addresses an iOS bug, so return early if the UA claims it's something else.
if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){
return;
}
@jeremyworboys
jeremyworboys / gist:2602707
Created May 5, 2012 14:04
SCSS: Media query generator
$bp-names: "narrow", "medium", "wide";
$bp-vals: "30em", "60em", "90em";
@mixin respond-to($name) {
@media screen and (min-width: nth($bp-vals, index($bp-names, $name))) {
@content
}
}
@jeremyworboys
jeremyworboys / gist:2603613
Created May 5, 2012 16:01
HTML: Meta device width
<meta name="viewport" content="width=device-width, initial-scale=1.0">