Skip to content

Instantly share code, notes, and snippets.

View bewildergeist's full-sized avatar

Dan Okkels Brendstrup bewildergeist

View GitHub Profile
@greystate
greystate / csv-output.xslt
Last active January 4, 2016 05:39
How to output nodes from a CSV list of ids in a property (Umbraco) - it silently handles duplicates and non-existing (unpublished or trashed) nodes by grabbing a nodeset of all the nodes that have an id that's contained in the CSV list. Using the [<apply-templates />](http://pimpmyxslt.com/reference/#apply-templates) instruction makes it easy to…
<!-- Umbraco hands us the XML document here -->
<xsl:param name="currentPage" />
<xsl:template match="/">
<!-- This is just to get the right context document -->
<xsl:for-each select="$currentPage">
<!-- Supplying a white-space separated string to `id()` will work! -->
<xsl:apply-templates select="id(translate(propertyName, ',', ' '))" />
</xsl:for-each>
</xsl:template>
@isDipesh
isDipesh / ko-chosen.js
Last active January 11, 2019 23:42
Collection of Knockout.js custom bindings.
//http://stackoverflow.com/questions/13210663/how-to-order-knockout-bindings
ko.bindingHandlers.chosen = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
var allBindings = allBindingsAccessor();
var options = {default: 'Select one...'};
$.extend(options, allBindings.chosen)
$(element).attr('data-placeholder', options.default);
@leekelleher
leekelleher / template-animation.md
Last active December 19, 2015 19:38
Exploring the 'Template Animation' concept
@adactio
adactio / placeholderFromDatalist.js
Created August 12, 2012 15:54
Generate a placeholder attribute from the datalist associated with that input.
(function(win,doc) {
if (doc.querySelectorAll) {
var inputs = doc.querySelectorAll('input[list]'),
total = inputs.length;
for (var i=0; i<total; i++) {
var input = inputs[i],
id = input.getAttribute('list'),
list = doc.getElementById(id),
options = list.getElementsByTagName('option'),
amount = options.length,
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@emilbjorklund
emilbjorklund / breakpoints_via_css.html
Created April 24, 2012 16:03
Width detection via sneaky CSS rules
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
@ethangardner
ethangardner / gist:1991279
Last active November 17, 2020 06:18
Raphael JS Guitar Neck Diagram
/**
* @author Ethan Gardner
* @see: http://www.ethangardner.com/articles/drawing-with-raphael-js-plus-a-bonus-for-guitar-players/
*/
var paper = new Raphael(document.id("fretboard"), 1300, 300);
/**
* Set up a GTR object to be used for namespacing
* @see http://www.ethangardner.com/articles/javascript-namespace-strategy-for-large-applications/
@padolsey
padolsey / cat.js
Created December 4, 2011 19:00
Improving Jeremy Keith's CAT news example from http://24ways.org/2011/conditional-loading-for-responsive-designs
var cat = {};
/**
* cat.NewsBox
* Retrieves news from Google
*/
cat.NewsBox = (function(){
function NewsBox(searchTerm, injectFn) {
this.searchTerm = searchTerm;
@bobslaede
bobslaede / modernizr.positionfixed.js
Created September 16, 2011 08:50
Modernizr position fixed check
;(function(Modernizr, window) {
Modernizr.addTest('positionfixed', function () {
var test = document.createElement('div'),
control = test.cloneNode(false),
fake = false,
root = document.body || (function () {
fake = true;
return document.documentElement.appendChild(document.createElement('body'));
}());
@vasilisvg
vasilisvg / responsive-context-images.html
Created September 7, 2011 10:50
Responsive context aware images without cookies or server logic
<!doctype html>
<!--
WARNING!
You probably shouldn't use this technique since images never show up
if the script isn't loaded for one reason or another. Some reasons:
- The content is viewed using a RSS reader
- The content is viewed with a read-it-later service
- The user has a flaky connection (hotel wifi, Dutch train, etc)
-->