Skip to content

Instantly share code, notes, and snippets.

View swernerx's full-sized avatar

Sebastian Werner swernerx

View GitHub Profile
@lisamelton
lisamelton / convert-mp4-to-mkv.sh
Last active May 24, 2024 17:41
Convert MP4 video file into Matroska format without transcoding.
#!/bin/bash
#
# convert-video.sh
#
# Copyright (c) 2013-2014 Don Melton
#
about() {
cat <<EOF
$program 2.0 of December 3, 2014
@larrybotha
larrybotha / A.markdown
Last active December 4, 2025 03:24
Fix SVGs not scaling in IE9, IE10, and IE11

Fix SVG in <img> tags not scaling in IE9, IE10, IE11

IE9, IE10, and IE11 don't properly scale SVG files added with img tags when viewBox, width and height attributes are specified. View this codepen on the different browsers.

Image heights will not scale when the images are inside containers narrower than image widths. This can be resolved in 2 ways.

Use sed in bash to remove width and height attributes in SVG files

As per this answer on Stackoverflow, the issue can be resolved by removing just the width and height attributes.

@sergejmueller
sergejmueller / ttf2woff2.md
Last active November 15, 2025 22:07
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
@hdragomir
hdragomir / sm-annotated.html
Last active April 30, 2026 08:09
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@lisamelton
lisamelton / convert-mkv-to-mp4.sh
Last active October 17, 2021 13:51
Convert Matroska video file into MP4 format without transcoding.
#!/bin/bash
#
# convert-video.sh
#
# Copyright (c) 2013-2014 Don Melton
#
about() {
cat <<EOF
$program 2.0 of December 3, 2014
@beshur
beshur / hsb.scss
Created November 14, 2014 09:45
Sass: HSB to HSL converter
// Simple HSB to HSL converter by Alexander Futekov (@futekov)
// http://www.sitepoint.com/hsb-colors-with-sass/
//
@function hsb($h-hsb, $s-hsb, $b-hsb, $a: 1) {
@if $b-hsb == 0 {
@return hsla(0, 0, 0, $a)
} @else {
$l-hsl: ($b-hsb/2) * (2 - ($s-hsb/100));
$s-hsl: ($b-hsb * $s-hsb) / if($l-hsl < 50, $l-hsl * 2, 200 - $l-hsl * 2);
@return hsla($h-hsb, $s-hsl, $l-hsl, $a);
@WebReflection
WebReflection / is-native-function.js
Last active March 27, 2021 18:25
a runtime feature detection way to sniff native functions from fakes
var isNativeFunction = (function (Function) {
var
toString = Function.toString,
re = new RegExp(
'^' +
toString
.call(Function)
.replace(/([\/\\[\]{}()^$.*+?_-])/g, '\\$1')
.replace('Function', '[a-zA-Z$_][\\S]*') +
'$'
@WebReflection
WebReflection / gist:24c4c475bdeb59405e87
Last active February 15, 2016 15:56
setTimeout and setInterval extra arguments

Every single JavaScript engine supports standard timers *

These accept one or more extra argument by specs

for(var i = 0; i < 2; i++) {
  setTimeout(function (i) {
    console.log(i);
  }, 0, i); // <== see this?
}
@WebReflection
WebReflection / slice.js
Last active March 8, 2016 11:06
How to slice arguments without leaking them
// Andrea Giammarchi, WTFPL
function slice() {'use strict';
for (var
o = +this, // offset
i = o, // start index
l = arguments.length, // length
n = l - o, // new length
a = Array(n < 0 ? 0 : n); // new Array
i < l; i++
) a[i - o] = arguments[i];
@WebReflection
WebReflection / WeakMap.js
Last active October 8, 2015 01:01
Symbol based WeakMap
var WeakMap = WeakMap || (function (s, dP, hOP) {'use strict';
function WeakMap() { // by Andrea Giammarchi - WTFPL
dP(this, s, {value: Symbol('WeakMap')});
}
WeakMap.prototype = {
'delete': function del(o) {
delete o[this[s]];
},
get: function get(o) {
return o[this[s]];