Skip to content

Instantly share code, notes, and snippets.

View jsguy's full-sized avatar

Mikkel Bergmann jsguy

View GitHub Profile
@jsguy
jsguy / dabblet.html
Created June 16, 2012 01:03
Untitled
<div>
<p>Hello World?</p>
</div>
<script>
// Why can't Chrome see ths save?
setInterval(function() {
console.log('hello, is there anybody out there? Ya\'ll?');
}, 1000);
@jsguy
jsguy / dabblet.html
Created June 16, 2012 01:05
Untitled
<div>
<p>Hello World?</p>
</div>
<script>
// Why can't Chrome see ths save?
setInterval(function() {
console.log('hello, is there anybody out there? Ya\'ll?');
}, 1000);
@jsguy
jsguy / index.html
Created August 13, 2012 22:18
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- IF PEN IS PRIVATE -->
<!-- <meta name="robots" content="noindex"> -->
<!-- END -->
@jsguy
jsguy / index.html
Created August 13, 2012 22:18
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- IF PEN IS PRIVATE -->
<!-- <meta name="robots" content="noindex"> -->
<!-- END -->
// Nicely format a number as money, including germanic style - original from: http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript
// eg: console.log(formatMoney(123456789.12345, ',', '.'));
var formatMoney = function(value, decimalPoint, thousandSeperator) {
var sign = value < 0 ? "-" : "",
number = parseInt(value = Math.abs(+value || 0).toFixed(2), 10) + "",
splitThousand = (splitThousand = number.length) > 3 ? splitThousand % 3 : 0;
decimalPoint = decimalPoint == undefined ? "." : decimalPoint;
thousandSeperator = thousandSeperator == undefined ? "," : thousandSeperator;
@jsguy
jsguy / gist:5981266
Last active December 19, 2015 16:08
SMH fix
<a href="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());}}}})())">SMH fix</a>
@jsguy
jsguy / gist:6067483
Created July 24, 2013 01:29
When using jQuery, and you need to select elements with weird IDs, this is handy
// Escape unwanted CSS selector chars
escapeForJquery = function(str) {
var charList = ["\\", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", "-", ",", ".", "/", ":", ";", "<", "=", ">", "?", "@", "[", "]", "^", "`", "{", "|", "}", "~"],
i, result = str;
for(i = 0; i < charList.length; i+=1) {
result = result.split(charList[i]).join("\\" + charList[i]);
}
return result;
};
<!doctype html>
<!--[if lt IE 9]><html class="ie"><![endif]-->
<!--[if gte IE 9]><!--><html><!--<![endif]-->
<!--
The comment jumble above is handy for targeting old IE with CSS.
http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
-->
<head>
@jsguy
jsguy / gist:6446407
Created September 5, 2013 05:36
Find inputs for cross-browser ajax form submit (works in IE7 even!)
.find('input:not(:disabled)')
@jsguy
jsguy / gist:6822077
Created October 4, 2013 07:09
jQuery konamify plugin... why not, it's friday.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<p>