Skip to content

Instantly share code, notes, and snippets.

View jsguy's full-sized avatar

Mikkel Bergmann jsguy

View GitHub Profile
@jsguy
jsguy / gist:9732087
Created March 24, 2014 00:26
SMH fix
javascript:void((function(){$('#subscription-overlay').remove();$('body').css({overflow: 'auto'}); localStorage.clear(); var a,b,c,e,f;f=0;a=document.cookie.split("; ");for(e=0;e<a.length&&a[e];e++){f++;for(b="."+location.host;b;b=b.replace(/^(?:%5C.|[^%5C.]+)/,"")){for(c=location.pathname;c;c=c.replace(/.$/,"")){document.cookie=(a[e]+"; domain="+b+"; path="+c+"; expires="+new Date((new Date()).getTime()-1e11).toGMTString());}}};document.location.reload()})())
@jsguy
jsguy / designer.html
Created September 4, 2014 03:47
designer
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../ace-element/ace-element.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@jsguy
jsguy / mithril.ie.polyfill.js
Last active June 11, 2021 05:06
Mithril IE8 polyfill
// IE polyfills needed by mithril for IE8 and below
// array.indexOf - https://gist.github.com/revolunet/1908355
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
@jsguy
jsguy / mobilekeyboardfix.jquery.js
Created July 20, 2015 02:01
Allow click to work even when keyboard is shown on mobile device
/*
Make the submit button "click" even when the keyboard is shown
http://stackoverflow.com/questions/24306818/form-submit-button-event-is-not-captured-when-keyboard-is-up-ios-7
http://stackoverflow.com/questions/12690620/checking-if-touchend-comes-after-a-drag
Note: requires jQuery
*/
$(function(){
// Check if the user is dragging
@jsguy
jsguy / withES6.js
Created July 21, 2017 01:45
The with statement in ES6
// Like the with statement, but in ES6 and scoped only onto obj
const withES6 = function(obj, code){
const scope = new Function(...Object.keys(obj), code);
scope(...Object.values(obj));
};
// Test
let myObj = {
res: {},
a: 3,
function htmlDecode(input){
var e = document.createElement('div');
e.innerHTML = input;
return e.childNodes[0].nodeValue;
}
function HtmlEncode(s)
{
var el = document.createElement("div");
el.innerText = el.textContent = s;