Skip to content

Instantly share code, notes, and snippets.

@sidisinsane
sidisinsane / .htaccess
Last active August 29, 2015 14:16
generic force www (incl. subdomains) and non-www
########################################################################################
# store requested protocol in %{ENV:protocol}
########################################################################################
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=protocol:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=protocol:http]
########################################################################################
# force non www
@sidisinsane
sidisinsane / .htaccess
Created March 4, 2015 19:39
force trailing slash
########################################################################################
# force trailing slash
########################################################################################
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
@sidisinsane
sidisinsane / .htaccess
Created March 4, 2015 19:39
placeholder redirects
########################################################################################
# store requested protocol in %{ENV:protocol} (i always use this...)
########################################################################################
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=protocol:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=protocol:http]
########################################################################################
# placeholder redirects (exclude specific matching redirects!)
@sidisinsane
sidisinsane / revoke-intl-number-format.js
Last active April 29, 2016 07:52
Revokes formatting previously applied by ‘Intl.NumberFormat‘
// ---
// Revokes formatting previously applied by ‘Intl.NumberFormat‘
//
// Usage:
// '123.456,78'.revokeIntlNumberFormat('de-DE');
// Result:
// 123456.78
// ---
Object.defineProperty(Object.prototype, 'revokeIntlNumberFormat', {
value: function(locale) {
function trimSvgWhitespace() {
// get all SVG objects in the DOM
var svgs = document.getElementsByTagName("svg");
// go through each one and add a viewbox that ensures all children are visible
for (var i=0, l=svgs.length; i<l; i++) {
var svg = svgs[i],
box = svg.getBBox(), // <- get the visual boundary required to view all children
@sidisinsane
sidisinsane / keybase.md
Created January 17, 2018 07:18
Keybase proof

Keybase proof

I hereby claim:

  • I am sidisinsane on github.
  • I am sidisinsane (https://keybase.io/sidisinsane) on keybase.
  • I have a public key ASBxKGSW70T8EFlEy_PTCQbhGIUyVv13PKUE1laZZIzIigo

To claim this, I am signing this object:

Mobile Safari's 100% Height Dilemma

Whether you're developing a web application with native-ish UI, or just a simple modal popup overlay that covers the viewport, when it comes to making things work on iDevices in Mobile Safari, you're in for a decent amount of pain and suffering. Making something "100% height" is not as easy as it seems.

This post is a collection of Mobile Safari's gotchas and quirks on that topic, some with solutions and fixes, some without, in good parts pulled from various sources across the internets, to have it all in one place. Things discussed here apply to iOS8, iOS9 and iOS10.

The Disappearing Browser Chrome

Screen real estate on smartphones is limited, so Mobile Safari collapses the browser chrome (address bar and optional tab bar at the top, and tool bar at the bottom) when the user scrolls down. When you

@sidisinsane
sidisinsane / animated-multiline-underline.css
Created March 21, 2019 07:10
Animated Multiline Underline
.animated-multiline-underline {
display: inline;
text-decoration: none;
width: calc(100%); /* somehow ie edge seems to need this */
background-image: linear-gradient(transparent calc(100% - 1px), currentColor 100%);
background-position: bottom left;
background-repeat: no-repeat;
background-size: 0% 1px;
-webkit-transition: background-size 300ms linear;
transition: background-size 300ms linear;
/**
* Format a number while typing it into an input field.
*
* @function formatNumberOnInput
* @param {!Element} element - The input element to format.
*
* @example
*
* formatNumberOnInput(document.getElementById('foo');
*/
/**
* Detect a click outside of an element and run a callback function.
*
* @function clickedOutside
* @param {!Element} element - The element for which to detect an outside click.
* @param {!Function} callback - The callback function to run when a click outside is detected.
*
* @example
*
* clickedOutside(document.getElementById('foo'), function(e) {