Quick function to deep merge using Object.assign()
. Thoughts?
/**
* Simple is object check.
* @param item
* @returns {boolean}
*/
Author: Mathias Bynens <http://mathiasbynens.be/> | |
This code is licensed under the WTFPL. Feel free to relicense as needed. |
// public domain, use it for whatever | |
// returns "calc", "-moz-calc", etc | |
// (no -ms because they already support it non-prefixed) | |
function prefixedCalc () { | |
var prefixes = ["","-webkit-","-moz-","-o-"], el | |
for (var i = 0; i < prefixes.length; i++) { | |
el = document.createElement('div') | |
el.style.cssText = "width:" + prefixes[i] + "calc(9px)" | |
if (el.style.length) return prefixes[i] + "calc" |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Hello</title> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
Hello World | |
</body> |
var build_query = function (obj, num_prefix, temp_key) { | |
var output_string = [] | |
Object.keys(obj).forEach(function (val) { | |
var key = val; | |
num_prefix && !isNaN(key) ? key = num_prefix + key : '' |
<?php | |
/** | |
* Is RTL | |
* Check if there RTL characters (Arabic, Persian, Hebrew) | |
* | |
* @author Khaled Attia <sourcecode@khal3d.com> | |
* @param String $string | |
* @return bool | |
*/ |
// ==UserScript== | |
// @name Medium: remove location hash | |
// @namespace http://efcl.info/ | |
// @description Remove location hash from medium | |
// @include https://medium.com/*#* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
function removeLocationHash(){ |
#Mobile Device Detection via User Agent RegEx
Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.
I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.
The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".
Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(
-moz-appearance
to none
. This will "reset" the styling of the element;text-indent
to 0.01px
. This will "push" the text a tiny bit[1] to the right;A very basic regex-based Markdown parser. Supports the
following elements (and can be extended via Slimdown::add_rule()
):