Skip to content

Instantly share code, notes, and snippets.

Binyamin Laukstein laukstein

Block or report user

Report or block laukstein

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Rich-Harris
Rich-Harris / service-workers.md
Last active Aug 16, 2019
Stuff I wish I'd known sooner about service workers
View service-workers.md

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@Salakar
Salakar / deepMerge.md
Last active Jul 17, 2019
ES6/ES2015 Object deep merge
View deepMerge.md

Deep Merge

Quick function to deep merge using Object.assign(). Thoughts?

    /**
     * Simple is object check.
     * @param item
     * @returns {boolean}
     */
View Medium: remove location hash.user.js
// ==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(){
@inexorabletash
inexorabletash / @ OBSOLETE Origin Mutex.md
Last active Dec 9, 2015
OBSOLETE: Per-Origin Mutex for JS
View @ OBSOLETE Origin Mutex.md

A proposed Web platform API for a simple, origin-scoped locking primitive.

STATUS: Go see this much better proposal instead.

Basic usage

acquireMutex(name).then( ... );
@joaocunha
joaocunha / How To Hide The Select Arrow On Firefox.md
Last active Feb 25, 2019
How to hide <select> dropdown's arrow in Firefox when using "-moz-appearance: none;".
View How To Hide The Select Arrow On Firefox.md

This is no longer a bug. I'm keeping the gist for historical reasons, as it helped to get it fixed. Make sure to read the notes by the end of the post.

How to remove hide the select arrow in Firefox using -moz-appearance:none;

TL;DR (or, the fix)

  1. Set -moz-appearance to none. This will "reset" the styling of the element;
  2. Set text-indent to 0.01px. This will "push" the text a tiny bit[1] to the right;
@Rob-ot
Rob-ot / prefixedCalc.js
Created Aug 20, 2012
Detect which prefixed css calc to use via javascript
View prefixedCalc.js
// 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"
@igrigorik
igrigorik / file.html
Created Jul 6, 2012
Example of early head flush on load time
View file.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Hello</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
Hello World
</body>
@jbroadway
jbroadway / Slimdown.md
Last active Aug 9, 2019
Slimdown - A simple regex-based Markdown parser.
View Slimdown.md

Slimdown

A very basic regex-based Markdown parser. Supports the following elements (and can be extended via Slimdown::add_rule()):

  • Headers
  • Links
  • Bold
  • Emphasis
  • Deletions
@luk-
luk- / http_build_query.js
Created May 17, 2012
php's http_build_query() in javascript
View http_build_query.js
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 : ''
@dalethedeveloper
dalethedeveloper / gist:1503252
Created Dec 20, 2011
Mobile Device Detection via User Agent RegEx
View gist:1503252

#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(

You can’t perform that action at this time.