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.
@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);