Skip to content

Instantly share code, notes, and snippets.

View peterwilsoncc's full-sized avatar

Peter Wilson peterwilsoncc

View GitHub Profile
@peterwilsoncc
peterwilsoncc / base64imgages.html
Last active December 14, 2015 23:39
Base64 Encoded CSS
<html>
<head>
<link rel="stylesheet" href="style.css">
<noscript><link rel="stylesheet" href="base64images.css"></noscript>
</head>
<body>
<p> Hello World </p>
<script>
@peterwilsoncc
peterwilsoncc / rapid-adn-widget.css
Last active December 16, 2015 07:49
Sample CSS for the Rapid Twitter and ADN Widgets for WordPress
/* refer to: http://wordpress.org/extend/plugins/rapid-adn-widget/ */
.adnpost {
margin-bottom: 1em;
}
.adnpost__datestamp {
display:block;
/* maybe */ text-align:right; /* too */
}
@peterwilsoncc
peterwilsoncc / css.css
Last active December 17, 2015 11:29
Using media queries in JavaScript (based around http://adactio.com/journal/5429/)
#js-mediaquery {
overflow: hidden;
width: 1px;
height: 1px;
position: absolute;
top: -999999em;
left: auto;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
@peterwilsoncc
peterwilsoncc / theme.js
Last active December 18, 2015 14:59
Rapid Twitter Widget for WordPress filter
if(typeof(RapidTwitter)=='undefined'){RapidTwitter={};}
RapidTwitter.generate_html = function(screen_name, tweets){
var the_html = '';
for (var i=0, l=tweets.length; i<l; i++) {
var use_tweet = tweets[i],
rt_html = '',
classes = ['tweet'];
if (typeof use_tweet.user.screen_name == 'undefined') {
@peterwilsoncc
peterwilsoncc / trickery.css
Created June 18, 2013 06:45
Box shadow with border fallback
.avoid-ids {
width: 200px; height: 50px; /* for demo */
background-color: #ddd;
border: solid #999;
border-width: 0 1px 1px 0;
border: 0 solid rgba(0,0,0,0);
-webkit-box-shadow: 0 2px 2px rgba(0,0,1,.25);
box-shadow: 0 2px 2px rgba(0,0,1,.25);
}
@peterwilsoncc
peterwilsoncc / js-starter-file.js
Created June 20, 2013 05:57
JavaScript starter file
PWCC = this.PWCC || {};
console = this.console || {};
console.log = this.console.log || function(){};
console.error = this.console.error || function(){};
(PWCC.exe = function(window, document, $) {
var html = document.documentElement,
body = html.getElementsByTagName('body')[0];
@peterwilsoncc
peterwilsoncc / script.js
Last active December 18, 2015 17:49
Async JS loader
PWCC = this.PWCC || {};
console = this.console || {};
console.log = this.console.log || function(){};
console.error = this.console.error || function(){};
(PWCC.exe = function(window, document, $) {
var html = document.documentElement,
body = html.getElementsByTagName('body')[0];
@peterwilsoncc
peterwilsoncc / _note.md
Last active December 19, 2015 14:39
Filter's used to add a little SMACSS to WordPress captions and gallery short codes.
@peterwilsoncc
peterwilsoncc / singleton-for-wordpress-themes.php
Last active December 20, 2015 14:19
Experimenting with singletons for WordPress themes - it makes it easier than dozens of calls to function_exists(), I think. Maybe.
<?php
/* Child Theme's functions.php */
function collaborate_class_init() {
class Collaborate extends Collaborate_Parent_Theme {
public static function theme() {
if ( ! Collaborate::$instance instanceof self ) {
Collaborate::$instance = new self();
}
@peterwilsoncc
peterwilsoncc / actions.js
Created August 21, 2013 06:41
add_action, do_action in Javascript
function add_action( action_name, callback, priority ) {
if ( ! priority ) {
priority = 10;
}
if ( priority > 100 ) {
priority = 100;
}
if ( priority < 0 ) {