Skip to content

Instantly share code, notes, and snippets.

View yckart's full-sized avatar

Yannick Albert yckart

View GitHub Profile
@yckart
yckart / README.md
Last active October 30, 2016 19:04
rawgit.com / rawgithub.com - Bookmarklet

A simple bookmarklet which makes our painful life a bit easier.

javascript:(function(b,a,c,d,e){if(/\.\w+$/.test(a))b.location=c+a.replace("/blob/","/");else if(e=prompt("Insert a filename:","index.html"))b.location=c+a.replace("/tree/","/")+(~a.indexOf(d)?"/":d)+e})(window,location.pathname,"http://rawgit.com","/master/");

The usage is quite simple:

Go to any repo where you like to preview a file, and execute the booklet. If the current url is a file, it should open the file directly, otherwise it will prompt for a filename (per default it is index.html).

// https://gist.github.com/yckart/4951636#file-uricomponent-js
var UTF8 = {
encode: function(str) { return unescape( encodeURIComponent(str) ); },
decode: function(str) { return decodeURIComponent( escape(str) ); }
};
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* SHA-1 implementation in JavaScript | (c) Chris Veness 2002-2010 | www.movable-type.co.uk */
/* - see http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html */
@yckart
yckart / nthChild.js
Last active December 17, 2015 18:19
var nthChild = function (elem, num, fn) {
var len = elem.length;
var ret = [];
var i = 0;
// :nth-child(num)
if (!isNaN(Number(num))) {
for (i = 0; i < len; i++) {
if (i === num - 1) {
if (fn) fn(elem[i]);
/**
* Hide the addressbar on ios & android devices
* https://gist.github.com/yckart/5609969
*
* Based on the work from Nate Smith
* @see https://gist.github.com/nateps/1172490
*
* Copyright (c) 2013 Yannick Albert (http://yckart.com)
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
* 2013/07/10
@yckart
yckart / jquery.addrule.js
Last active December 29, 2022 12:16
Add css-rules to an existing stylesheet - http://stackoverflow.com/a/16507264/1250044
/*!
* jquery.addrule.js 0.0.2 - https://gist.github.com/yckart/5563717/
* Add css-rules to an existing stylesheet.
*
* @see http://stackoverflow.com/a/16507264/1250044
*
* Copyright (c) 2013 Yannick Albert (http://yckart.com)
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
* 2013/11/23
**/
@yckart
yckart / performance.now.js
Last active December 16, 2015 20:18
performance.now polyfill
(function (performance) {
performance.now = performance.now ||
performance.webkitNow ||
performance.msNow ||
performance.mozNow ||
Date.now || function () {
return new Date().getTime();
};
}(this.performance = this.performance || {}));
@yckart
yckart / rAF.js
Created April 30, 2013 02:05
requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel refactored by Yannick Albert
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// refactored by Yannick Albert
// MIT license
(function(window) {
var equestAnimationFrame = 'equestAnimationFrame',
requestAnimationFrame = 'r' + equestAnimationFrame,
@yckart
yckart / snake.js
Last active December 15, 2015 20:41
Simple canvas snake game to port into some game-engines.
/*!
* snake.js 0.0.1 - https://gist.github.com/yckart/5320382/
* A super simple canvas snake game to port into some game-engines.
*
* Copyright (c) 2013 Yannick Albert (http://yckart.com)
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
* 2013/04/05
*/
@yckart
yckart / Class.js
Last active December 15, 2015 13:29
A class factory.
/**
* Class
* A class factory
*/
function Class(parent, members) {
// prepare single-inheritance
members = members || parent;
var cookie = {
create: function (name, value, minutes) {
var expires;
if (minutes) {
var date = new Date();
date.setTime(date.getTime() + (minutes * 60 * 1000));
expires = "; expires=" + date.toGMTString();
} else expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
},