Skip to content

Instantly share code, notes, and snippets.

View yukulele's full-sized avatar

Clément P yukulele

  • France
View GitHub Profile
@yukulele
yukulele / hexToRGB.js
Created December 7, 2022 02:19
hexToRGB
function hexToRGB(hex = '#000') {
hex = hex.replace(/^#/, '')
if (
hex.length !== 3 && hex.length !== 6
|| /[^\da-f]/i.test(hex)
) throw new Error('Invaild hex color string')
return hex
.match(/(..?)(..?)(..?)/)
.slice(1)

Twitter native video player

Replace the user-unfriendly Twitter video player with the browser's native video player.

This allows you to:

  • seek backward/forward with the / keys
  • change the volume with the / keys
  • switch full screen with double-click or f key
  • access the video's contextual menu
  • change the playback speed with the + / - and 0 keys or via the contextual menu
@yukulele
yukulele / unicodeFlag.js
Created December 16, 2021 14:49
Convert ISO 3166-1 alpha-2 country code to unicode flag char
unicodeFlag=countryCode=>countryCode.replace(/[a-z]/g,c=>String.fromCharCode(0xd83c,c.charCodeAt()+56709))
function parseHtmlFragment(str = '') {
var t = document.createElement('template')
t.innerHTML = str
return t.content.cloneNode(true)
}
@yukulele
yukulele / easing.ts
Last active May 23, 2021 10:18
Simple Easing Functions in Typescript
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 August 29, 2017 17:24
client side prettier
This file has been truncated, but you can view the full file.
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var asn1=exports;asn1.bignum=require("bn.js");asn1.define=require("./asn1/api").define;asn1.base=require("./asn1/base");asn1.constants=require("./asn1/constants");asn1.decoders=require("./asn1/decoders");asn1.encoders=require("./asn1/encoders")},{"./asn1/api":2,"./asn1/base":4,"./asn1/constants":8,"./asn1/decoders":10,"./asn1/encoders":13,"bn.js":17}],2:[function(require,module,exports){var asn1=require("../asn1");var inherits=require("inherits");var api=exports;api.define=function define(name,body){return new Entity(name,body)};function
This file has been truncated, but you can view the full file.
{"candidats":["M. Emmanuel MACRON","Mme Marine LE PEN","M. François FILLON","M. Jean-Luc MÉLENCHON","M. Benoît HAMON","M. Nicolas DUPONT-AIGNAN","M. Jean LASSALLE","M. Philippe POUTOU","M. François ASSELINEAU","Mme Nathalie ARTHAUD","M. Jacques CHEMINADE","Abstentions","Blancs","Nuls"],"candidatsID":{"M. Emmanuel MACRON":0,"Mme Marine LE PEN":1,"M. François FILLON":2,"M. Jean-Luc MÉLENCHON":3,"M. Benoît HAMON":4,"M. Nicolas DUPONT-AIGNAN":5,"M. Jean LASSALLE":6,"M. Philippe POUTOU":7,"M. François ASSELINEAU":8,"Mme Nathalie ARTHAUD":9,"M. Jacques CHEMINADE":10,"Abstentions":11,"Blancs":12,"Nuls":13},"villes":[["01","Ambléon",[15,18,14,19,3,4,1,2,0,1,0,20,2,0]],["01","Ambronay",[348,458,233,296,82,80,13,17,11,9,1,268,53,11]],["01","Ambutrix",[95,135,84,89,23,28,3,8,2,3,3,91,12,5]],["01","Ambérieu-en-Bugey",[1332,1667,1084,1412,344,346,60,91,71,40,5,1962,114,58]],["01","Ambérieux-en-Dombes",[191,306,197,126,37,45,6,10,10,5,0,215,21,3]],["01","Andert-et-Condon",[55,40,44,39,8,6,8,3,6,0,0,41,1,3]],["01","Anglefor
@yukulele
yukulele / WikEdDiff.js
Created October 9, 2015 18:56
wikEd diff
// <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)
@yukulele
yukulele / esdown.js
Created June 29, 2015 23:45
esdown
/*=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;
@yukulele
yukulele / EventEmitter.js
Created June 22, 2015 14:24
EventEmitter ES6
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);