Skip to content

Instantly share code, notes, and snippets.

View louisremi's full-sized avatar

Louis-Rémi Babé louisremi

View GitHub Profile
@louisremi
louisremi / animLoopX.js
Created July 29, 2011 17:34
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@louisremi
louisremi / LICENSE.txt
Created October 27, 2011 09:12 — forked from 140bytes/LICENSE.txt
c, an expressive className manipulation lib: c( elem, 'has/add/remove/toggle', class_name )
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 @louis_remi <http://louisremi.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@louisremi
louisremi / serverReachable.js
Created April 22, 2011 11:39
better navigation.onLine: serverReachable()
function serverReachable() {
// IE vs. standard XHR creation
var x = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" ),
s;
x.open(
// requesting the headers is faster, and just enough
"HEAD",
// append a random string to the current hostname,
// to make sure we're not hitting the cache
"//" + window.location.hostname + "/?rand=" + Math.random(),
@louisremi
louisremi / defaultDisplay_iframe.js
Created April 27, 2011 11:29
New defaultDisplay()
var elemDisplays = {},
// Store the iframe outside the function to reuse it
iframe, iframeDoc;
function defaultDisplay( nodeName ) {
if ( !elemDisplays[ nodeName ] ) {
// Try the classical method first, which is far faster
var elem = document.createElement( nodeName ),
display;
document.body.appendChild( elem );
display = window.getComputedStyle( elem )
@louisremi
louisremi / fakeXMLhttpRequest.js
Created May 24, 2011 12:05
Fake XMLHttpRequest producing slow progress events
function fakeXMLHttpRequest() {
var self = this;
this.upload = {
addEventListener: function(evt, cb) {
self.progressListener = cb;
}
}
this.open = function() {};
this.overrideMimeType = function() {};
this.loaded = 0;
@louisremi
louisremi / client.js
Created June 15, 2011 14:15
Friends Timeline snippets
// Create an EventSource object,
// passing it the URL of the server sccript
var evtSrc = new EventSource( "server.php" );
// Listen for messages/events on the EventSource
evtSrc.onmessage = function ( e ) {
addMessage( "status", JSON.parse(e.data) );
}
evtSrc.addEventListener("checkin", function( e ) {
addMessage( "checkin", JSON.parse(e.data) );
@louisremi
louisremi / machine.js
Last active May 17, 2022 15:37
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@louisremi
louisremi / genes_export.svg
Created November 10, 2014 18:13
SVG font exported by Prototypo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Over and Out test page</title>
<link rel="stylesheet" type="text/css" media="all" href="shCore.css" />
<link rel="stylesheet" type="text/css" media="all" href="shThemeFadeToGrey.css" />
<style>
.deco {
padding: 5px;
@louisremi
louisremi / keyframes.css
Created May 3, 2011 16:42
CSS3 animations keyframes
/* We are defining the "timeline" of the animation,
* each line representing a keyframe.
*/
@-moz-keyframes bounce {
/* Translate the element 400px to the right */
/* Here we are animating "-moz-tranform",
* but most CSS properties can be animated:
* width, color, font-size, box-shadow, ...
*/
from { -moz-transform: translate(0px); }