This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// change selectors as you need | |
var selector = '.selector'; | |
$(document).ready(function() { | |
$(selector).click(function(e) { | |
$(selector).show(); | |
e.stopPropagation(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isMSIE = /*@cc_on!@*/0; | |
if (isMSIE) { | |
document.body.style.background = "red"; //it's IE :( | |
} else { | |
document.body.style.background = "green"; //it's not IE! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.repeat = function(times) { | |
return (new Array(times + 1)).join(this); | |
}; | |
var str = "1".repeat(3); | |
console.log(str); // 111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple and efficient way to shuffle | |
// a relatively small array. Doesn't work well | |
// with a lot of indices. See: http://stackoverflow.com/a/18650169/2104866 | |
var numbers = [1,2,3,4,5,6]; | |
numbers.sort(function() { | |
return .5 - Math.random(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// regexp for matching a valid email and populating an array with its parts | |
'[email protected]'.match(/([a-z|0-9]{2,})+\@([a-z|0-9]+)\.(.{2,})/) // <= ['[email protected]', 'email', 'domain', 'com'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div class="tabbed"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myObject(options) { | |
if(!(this instanceOf myObject)) | |
return new myObject(options); | |
} | |
var object = myObject({}); // acts as if was instantiated with new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wtf = (''+![])[0]+(''+![])[1]+([][0]+'')[0b101]+(''+![])[2] | |
console.log(wtf); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set linkanimations | |
set sortlinkhints | |
set noautofocus | |
set smoothscroll | |
let scrollstep = 100 | |
let blacklists = ["http://devdocs.io/*","https://inbox.google.com/*","https://mail.google.com/*","http://vim-adventures.com/*"] | |
let hintcharacters = 'asdfghjkl' | |
getIP() -> {{ | |
httpRequest({url: 'http://api.ipify.org/?format=json', json: true}, | |
function(res) { Status.setMessage('IP: ' + res.ip); }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |