Skip to content

Instantly share code, notes, and snippets.

View bjrn's full-sized avatar

Björn Rixman bjrn

View GitHub Profile
@bjrn
bjrn / example usage
Last active March 1, 2016 14:15
simple vngage boot script that allows for using vngage.subscribe() in your code before the script has loaded
// vngage.subscribe( message, func );
vngage.subscribe('banner:join', function () {
console.log('banner:join triggered');
});
@bjrn
bjrn / dabblet.css
Created March 27, 2013 14:59 — forked from LeaVerou/dabblet.css
Switch-style checkboxes.
/**
* Switch-style checkboxes.
* Inspired by Espresso’s “Tools” switch
*/
input[type="checkbox"]:not(:checked),
input[type="checkbox"]:checked { /* :checked here acting as a filter for older browsers */
position: absolute;
opacity: 0;
}
@bjrn
bjrn / dabblet.css
Created March 27, 2013 14:42
iOS 6 style switch checkboxes
/**
* iOS 6 style switch checkboxes
* by Lea Verou http://lea.verou.me
*/
:root input[type="checkbox"] { /* :root here acting as a filter for older browsers */
position: absolute;
opacity: 0;
}
@bjrn
bjrn / scroll.js
Created March 19, 2013 22:21
scrollToPos ( yPos, opts, after );
/*
Props to emilejs for nice handling of easing and callbacks.
TODO:
opts.el - calculate positions
(in our case, we do that outside of this function already)
IE8+ ... el = (typeof el === 'string') ? document.querySelector(el) : el
use window.requestAnimationFrame instead of setInterval
- with polyfill of course
@bjrn
bjrn / myConsole
Created October 18, 2012 13:49
window.console shim
myConsole = {};
(function fixConsole(fakeConsole) {
fakeConsole.debug = true;
fakeConsole.breakOnErrors = true;
var methods = ['log', 'warn', 'error', 'info', 'dir'];
if (!window.console) return;
@bjrn
bjrn / scrollfix.html
Created February 1, 2012 21:54
IOS Webkit - native internal scroll - a fix for the document page-bounce
<!DOCTYPE html>
<html>
<!-- NOTES
Demo - uses IOS native scroll available in IOS5, but sidestep the document-bounce behavior.
another take on the solution first seen here: https://gist.github.com/1372229
https://github.com/joelambert/ScrollFix/issues/2
Tested on iPad 2, using IOS 5.0.1.
@bjrn
bjrn / Zepto.serializeForm.js
Created July 29, 2011 10:34
Zepto version of $.fn.serializeForm used in http://maccman.github.com/spine.tutorials/form.html. Requires Zepto > 0.6 that $.fn.serializeArray()...
$.fn.serializeForm = function(){
var result = {};
$(this).serializeArray().forEach(function(item, i){
if (item.name.length){
result[item.name] = item.value;
}
});
@bjrn
bjrn / SlickGrid simple sorter.js
Created February 10, 2011 13:50
a snippet that allows for having different sorters for each column
// Define some sorting functions
function NumericSorter(a, b) {
var x = a[sortcol], y = b[sortcol];
return sortdir * (x == y ? 0 : (x > y ? 1 : -1));
}
function RatingSorter(a, b) {
var xrow = a[sortcol], yrow = b[sortcol];
var x = xrow[3], y = yrow[3];
return sortdir * (x == y ? 0 : (x > y ? 1 : -1));
}
@bjrn
bjrn / meta-boxes-for-wordpress.php
Created December 29, 2010 09:21
add to functions.php
<?php
//add excerpt field to pages as well, and not only posts:
function my_page_excerpt_meta_box() {
add_meta_box( 'postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'page', 'normal', 'core' );
}
add_action( 'admin_menu', 'my_page_excerpt_meta_box' );
//add Facts box to all pages
function my_facts_meta_box() {
/*
jQuery.equalHeights Plugin
@author John Hunter
@dependency jQuery 1.4.x
EqualHeights version 2.0 (2010-09-07 johnhunter.info)
Based on an idea copyright (c) 2008 Rob Glazebrook (cssnewbie.com)
use: $('#selector').equalHeights({minHeight: 200});
see defaults object for options