Skip to content

Instantly share code, notes, and snippets.

View bpierre's full-sized avatar
✌️

Pierre Bertet bpierre

✌️
View GitHub Profile
@bpierre
bpierre / mini-lightbox.js
Created November 6, 2011 00:08
A mini lightbox (jQuery)
/* A small script to display lightboxes. No IE6 support. */
/*global jQuery: false*/
(function($, window){
"use strict";
$.miniLightbox = {};
var EVENT_NS = 'minilightbox';
var DEFAULT_SETTINGS = {
'class': '',
@bpierre
bpierre / documentup-bookmarklet.js
Created May 1, 2012 16:01
Switch between documentup.com and github.com
// javascript:(function(){var%20w%20=%20window,h%20=%20w.location.host,p%20=%20w.location.pathname,r%20=%20p.match(/^(\/[^\/]+\/[^\/]+)/),gh%20=%20%27github.com%27,du%20=%20%27documentup.com%27;if%20(r%20&&%20h%20==%20gh)%20{w.location%20=%20%27http://%27%20+%20du%20+%20r[1];}%20else%20if%20(r%20&&%20h%20==%20du)%20{w.location%20=%20%27https://%27%20+%20gh%20+%20r[1];}})();
(function(){
var w = window,
h = w.location.host,
p = w.location.pathname,
r = p.match(/^(\/[^\/]+\/[^\/]+)/),
gh = 'github.com',
du = 'documentup.com';
if (r && h == gh) {
@bpierre
bpierre / gist:2603011
Created May 5, 2012 14:45
hasOwnProperty style
var obj = {
foo: 1,
bar: 2
};
Object.prototype.oops = function(){};
// Meh.
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
@bpierre
bpierre / anchor-select.js
Created May 8, 2012 14:48
CSS Selectors anchors: /mypage.html#anchor-select(#content > h1)
(function(window) {
function getSelector(hash) {
var matches;
hash = hash.slice(1);
matches = hash.match(/^anchor-select\((.+)\)$/);
if (matches) {
return decodeURIComponent(matches[1]);
}
return false;
@bpierre
bpierre / index.html
Created August 23, 2012 13:37
Mini Slider: zero dependencies, IE8+.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mini slider</title>
<link rel="stylesheet" href="mini-slider.css">
</head>
<body>
<div id="slider">
<!-- The previous button is inserted here -->
@bpierre
bpierre / parseurl.js
Created September 5, 2012 23:40
ParseURL
/*
ParseURL by James Padolsey: http://james.padolsey.com/javascript/parsing-urls-with-the-dom/
*/
// This function creates a new anchor element and uses location
// properties (inherent) to get the desired URL data. Some String
// operations are used (to normalize results across browsers).
function parseURL(url) {
var a = document.createElement('a');
@bpierre
bpierre / eternal-ff.txt
Created September 21, 2012 11:03
My Twitter followings
@BKcore
@codylindley
@KerbalSpaceP
@GilbertWehrle
@dlctbl
@FREE_FACTS
@tabatkins
@marijnjh
@rocket2guns
@stripe
@bpierre
bpierre / index.html
Created September 26, 2012 23:49
Mini clock
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Clock demo</title>
<style>
svg {
display: block;
position: absolute;
left: 50%;
@bpierre
bpierre / index.html
Created October 15, 2012 11:37
SUPER #7
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SUPER #7</title>
<style>
html { display: table; width: 100%; height: 100%; background: #000; }
body { display: table-cell; vertical-align:middle; text-align:center; margin: 0; }
canvas { margin: 0; }
h1 { color: #fff; margin: 0 0 10px; font:24px sans-serif; }
@bpierre
bpierre / kib.js
Created November 14, 2012 00:03
Another boring keyboard library
/*jshint browser:true */
(function(name, definition) {
if (typeof define == 'function') {
define(definition);
} else if (typeof module != 'undefined') {
module.exports = definition();
} else {
this[name] = definition();
}
})('kib', function(){