Skip to content

Instantly share code, notes, and snippets.

Clément P yukulele

  • France
View GitHub Profile
View parse-html-fragment.js
function parseHtmlFragment(str = '') {
var t = document.createElement('template')
t.innerHTML = str
return t.content.cloneNode(true)
}
@yukulele
yukulele / easing.ts
Last active Apr 22, 2018
Simple Easing Functions in Typescript
View easing.ts
class Ease {
static in(t: number, p = 1) {
return t ** p
}
static out(t: number, p = 1) {
return 1 - Ease.in(1 - t, p)
}
static inOut(t: number, p = 1):number {
if (t <= 0.5) {
return Ease.in(t * 2, p) / 2
@yukulele
yukulele / prettier.js
Created Aug 29, 2017
client side prettier
View prettier.js
This file has been truncated, but you can view the full file.
View WikEdDiff.js
// <syntaxhighlight lang="JavaScript">
// ==UserScript==
// @name wikEd diff
// @version 1.2.4
// @date October 23, 2014
// @description improved word-based diff library with block move detection
// @homepage https://en.wikipedia.org/wiki/User:Cacycle/diff
// @source https://en.wikipedia.org/wiki/User:Cacycle/diff.js
// @author Cacycle (https://en.wikipedia.org/wiki/User:Cacycle)
View esdown.js
/*=esdown=*/(function(fn, deps, name) { function obj() { return {} } if (typeof exports !== 'undefined') fn(require, exports, module); else if (typeof define === 'function' && define.amd) define(['require', 'exports', 'module'].concat(deps), fn); else if (typeof window !== 'undefined' && name) fn(obj, window[name] = {}, {}); else if (typeof self !== 'undefined' && name) fn(obj, self[name] = {}, {}); else fn(obj, {}, {}); })(function(require, exports, module) { 'use strict'; function __load(p, l) { module.__es6 = !l; var e = require(p); if (e && e.constructor !== Object) e.default = e; return e; }
(function() {
var VERSION = "0.9.9";
var Global = (function() {
try { return global.global } catch (x) {}
try { return self.self } catch (x) {}
return null;
View EventEmitter.js
class EventEmitter{
constructor(selector){
this.cb = new Map();
}
on(e,f){
var cb;
if(!this.cb.has(e))
this.cb.set(e, cb = new Set());
else
cb = this.cb.get(e);
View ie-classes.php
<?php
function ieClasses( $min = 6, $max = 11 ) {
$classes = array();
preg_match("/msie (\d+)/i", $_SERVER['HTTP_USER_AGENT'], $match);
if( count( $match ) > 0 ){
$version = +$match[1];
$classes[] = 'ie';
$classes[] = 'ie' . $version;
for( $i = $min ; $i <= $max ; $i++ ){
if( $version < $i )
@yukulele
yukulele / ie-version.js
Last active Jan 9, 2018
Test Internet Explorer version and add classes to <html>
View ie-version.js
var ieVersion = (function(){
var classes = []
var match = /msie (\d+)/i.exec( navigator.userAgent )
if( match ){
var version = +match[1]
var min = 6
var max = 11
classes.push( 'ie' )
classes.push( 'ie' + version )
for( var i = min ; i <= max ; i++ ){
@yukulele
yukulele / scroobar-width.js
Last active Aug 29, 2015
scrollbar width
View scroobar-width.js
var scrollBarWidth = (function(){
var html = document.documentElement;
var outer = document.createElement("div");
var inner = document.createElement("div");
outer.style.visibility = "hidden";
outer.style.width = "100px";
outer.style.overflow = "scroll";
outer.appendChild(inner);
You can’t perform that action at this time.