Skip to content

Instantly share code, notes, and snippets.

View cameronbaney's full-sized avatar

Cameron Baney cameronbaney

View GitHub Profile
@tpluscode
tpluscode / .gitignore
Last active April 24, 2017 16:03
Example of Web Component Tester with bound fixture
bower_components/
@markschl
markschl / lazyLoader.js
Last active April 23, 2017 13:02
Attempt to implement a Handsontable (www.handsontable.com) plugin allowing deferred loading of data (see also https://github.com/warpech/jquery-handsontable/issues/607). For an example see: http://jsfiddle.net/7Z3bD/54/
/**
* This Handsontable plugin implements deferred data loading, useful for
* large tables ("infinite scrolling").
*
*
* Example usage
* -------------
* In this example data is fetched from a Django + Tastypie Api
*
* var hot = new Handsontable(document.getElementById('table'), {
@Integralist
Integralist / Description.md
Last active April 25, 2020 16:20
This is how BBC News currently implements it's Image Enhancer for responsive images. Note: this is a completely rebuilt version of the code so the BBC's original source code doesn't actually look anything like the below example.

The BBC has a server-side image service which provides developers with multiple sized versions of any image they request. It works in a similar fashion to http://placehold.it/ but it also handles the image ratios returned (where as placehold.it doesn't).

The original BBC News process (and my re-working of the script) follows roughly these steps...

  • Create new instance of ImageEnhancer
  • Change any divs within the page (which have a class of delayed-image-load) into a transparent GIF using a Base64 encoded string.
    • We set the width & height HTML attributes of the image to the required size
    • We know what size the image needs to be because each div has custom data-attr set server-side to the size of the image
    • We then set a class of image-replace onto each newly created transparent image
  • We use a 250ms setTimeout to unblock the UI thread and which calls a function resizeImages which enhances the image-replace images so their source is now set to a URL whe
@anildigital
anildigital / client.js
Created April 9, 2011 10:16
Twitter streaming API example twitter-node and socket.io
<!DOCTYPE HTML>
<head>
<title>Codesnippit NodeJS Twitter Tracker Client</title>
</head>
<body>
<ul></ul>
<script>
(function() {
var script = document.createElement("script");
script.src = "http://code.jquery.com/jquery.min.js";
@scribu
scribu / gist:906872
Created April 7, 2011 01:21
'price' sortable column example
<?php
// Register the column
function price_column_register( $columns ) {
$columns['price'] = __( 'Price', 'my-plugin' );
return $columns;
}
add_filter( 'manage_edit-post_columns', 'price_column_register' );