Skip to content

Instantly share code, notes, and snippets.

@cole007
cole007 / .htaccess
Created February 18, 2014 12:17
htaccess rewrite issue
# htaccess rule to redirect queries to eg /shop/category/dvd to /shop/index.php?c=dvd
# HOWEVER this overrides any further queries, eg/shop/category/dvd?d=2011
RewriteRule ^shop/category/([a-zA-Z0-9-/]+)$ shop/index.php?c=$1 [L]
@cole007
cole007 / index.html
Created March 5, 2014 20:32
Google: Custom Search API
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
// note key and cx strings here
var url = 'https://www.googleapis.com/customsearch/v1?key=AIzaSyBjBWczqg-5fB_2IkJ9ewb6AfP7BSNO5ZA&cx=012215714774810169881:nkujpnbrxhi&q=atoms&fileType=pdf';
$(function() {
// see http://api.jquery.com/jquery.getjson/
var jqxhr = $.getJSON( url, function() {
console.log( "success" );
@cole007
cole007 / Sample
Created July 7, 2014 14:34
Checkboxify
<p>Requires association between for/id pairs</p>
<p>
<label for="checkbox1">Checkbox 1</label>
<input name="checkbox1" id="checkbox1" type="checkbox" checked value="Box"/>
</p>
<p>
<label for="checkbox2">Checkbox 2</label>
<input name="checkbox2[]" id="checkbox2" type="checkbox" checked value="Square"/>
Our country confuses the needs of the many with the wants of the few. Thirty years of neo-liberal policy has put us all in the pockets of the banks, enslaved by the manacles of mortgages, big debt and a media that constantly tells us what we deserve.
We eschew public services, universal healthcare and education to keep taxes low and the business machine oiled, a machine that makes the rich richer and the poor poorer.
Ours is a democracy and a democracy that we have sold to the world as the correct way to do things. We go to war in the name of democracy and protecting our liberties. But we have to ask ourselves what are the values and liberties that we are trying to uphold when our own civil liberties are compromised in the name of 'protecting' our citizens.
What right does an elected body have to make these decisions without due process. The institutions and diligence that have been set up to protect us. All of us. Legislation must go through the proper process.
You work for us.
Dear …,
I am writing in disgust at the news of emergency legislation being 'rushed through' without due diligence and democratic, political process.
As my representative in Parliament I write to request that you seek this legislation be considered in the correct manner with proper consultation and debate amongst the elected representatives of this country.
Rushing through emergency legislation in a week without a proper debate in parliament fundamentally undermines our democratic process and we have to ask ourselves if we undermine our civil liberties to protect our citizens what are the values we are trying to defend and uphold with this new legislation?
Concerned,
@cole007
cole007 / jquery.customSelect.js
Last active August 29, 2015 14:03
Custom select
// fork of library at http://adam.co/lab/jquery/customselect/
// removes width calculations
/*!
* jquery.customSelect() - v0.5.1
* http://adam.co/lab/jquery/customselect/
* 2014-03-19
*
* Copyright 2013 Adam Coulombe
* @license http://www.opensource.org/licenses/mit-license.html MIT License
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div class="booking-item booking-item--left booking-item--full">
@cole007
cole007 / footer.JS
Created August 26, 2014 09:12
From footer template
@cole007
cole007 / dobanners.js
Last active August 29, 2015 14:05
Do Banners polyfill
doBanners: function() {
var banners = $('.banners-wrapper');
banners.after('<div class="banner-nav-wrapper"></div>');
$('.banner-nav-wrapper').append('<ul class="banner-switch"></ul>')
.append('<ul class="banner-nav"></ul>');
banners.find('.item').each(function(i) {
$(this).addClass('banner-panel-'+i);
var url = $(this).find('.more a').attr('href');
if (i == 0) $(this).addClass('active');
var navImg = $(this).find('.do-image').data('nav');
if(viewportwidth > 1183 && !$('.page').hasClass('home') ){
$('a.icon--search').on('click touchend',function(e) {
e.preventDefault();
$(this).toggleClass('nav-active');
$(this).next('.search__form').toggleClass('search__form--active');
$('.header__secondary-menu').fadeToggle();
});
$('.search__form').css('top','5.45em');
} else {
$('a.icon--search').on('click touchend',function(e) {