Skip to content

Instantly share code, notes, and snippets.

View Arecsu's full-sized avatar
🍪
Baking some cookies

Alejandro Romano Arecsu

🍪
Baking some cookies
View GitHub Profile
@jennyknuth
jennyknuth / README.md
Last active March 19, 2024 20:16
Transform an SVG into a data URI—best practice

How to transform an SVG into a data URI

by Jenny Knuth, based on the work of Chris Coyier and Taylor Hunt

A data URI is a nice way to include a web resource without needing to make an HTTP request. Chris Coyier explains the technique nicely in Probably Don't Base64 SVG.

While a PNG might use Base64 encoding, for SVG, there is a better way.

Taylor Hunt's experiments led to this solution for optimizing SVGs in data URIs:

"So the best way of encoding SVG in a data URI is data:image/svg+xml,[actual data]. We don’t need the ;charset=utf-8 parameter (or the invalid ;utf8 parameter…), because URLs are always ASCII."

@korny
korny / srt-parser.js
Created July 3, 2014 13:00
Simple SRT parser in JavaScript
function srtTimeToSeconds(time) {
var match = time.match(/(\d\d):(\d\d):(\d\d),(\d\d\d)/);
var hours = +match[1],
minutes = +match[2],
seconds = +match[3],
milliseconds = +match[4];
return (hours * 60 * 60) + (minutes * 60) + (seconds) + (milliseconds / 1000);
}
@gre
gre / easing.js
Last active May 8, 2024 14:30
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {