Skip to content

Instantly share code, notes, and snippets.

@jaan
jaan / How to filter npm audit results by severity?
Last active November 28, 2018 23:27
How to filter npm audit results by severity?
`npm audit | grep -E "(High | Critical)" -B3 -A10` will show only High or critical vulnerabilities
Available severities to try: Low |High| Moderate | Critical
Replace the severities in the above command per your needs.
@jaan
jaan / safaribug.md
Created January 27, 2016 18:54
crashsafari

Recently crashsafari bug started crashing the safari with very long url. Here's the script.

var total = "";
for( var i = 0; i < 100000; i++ ) {
  total = total + i.toString();
  history.pushState(0,0, total );
}

@jaan
jaan / eventlistenersinjs.md
Last active January 27, 2016 09:24
Adding and Removing Event Listeners with function parameters in Javascript with Event Array

##addEventListener and removeEventListener with function parameters in Javascript along with Event Array

I'm posting a solution which i have implemented to overcome the issue with removeEventListener for anonymous functions. It's basically a closure pattern.

var eventsArray = ['myevent.firstEvent', 'myevent.secondEvent, 'myevent.thirdEvent', 'myevent.fourtEvent', 'myevent.fifthEvent'];

eventsArray.forEach(function(element, index) {
    (function(){
        var paramterCache;
@jaan
jaan / JS error tracking in google analytics
Last active August 29, 2015 14:16
How to track javascript/jquery errors in google anlaytics?
// Track javaScript errors
window.addEventListener('error', function (err) {
var lineAndColumnInfo = err.colno ? ' line:' + err.lineno +', column:'+ err.colno : ' line:' + e.lineno;
ga(
'send',
'event',
'JavaScript Error',
err.message,
err.filename + lineAndColumnInfo + ' -> ' + navigator.userAgent,
0,
@jaan
jaan / devconsoletrick
Created February 24, 2015 04:24
How to display message when dev console is opened?
setTimeout(console.log.bind(console, "\n%cStop!", "font-family:helvetica; font-size:20px; font-size:50px; font-weight:bold; color:red; -webkit-text-stroke:1px black;"));
setTimeout(console.log.bind(console, "\n%cThis is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Facebook feature or \"hack\" someone\'s account, it is a scam and will give them access to your Facebook account.", "font-family:helvetica; font-size:20px;"));
setTimeout(console.log.bind(console, "\n%cFor more information, see https://www.xys.com/selfxss.", "font-family:helvetica; font-size:20px;"));
@jaan
jaan / designer.html
Last active August 29, 2015 14:10
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
@jaan
jaan / Promises
Created October 16, 2014 06:29
Promises
http://blog.getify.com/promises-part-1/
@jaan
jaan / Bring up the simple http server
Created September 8, 2014 06:52
Bringing up the simple http server from current directory
Defaults the port, but allows you to override it. And opens the browser with your real hostname, instead of localhost, for sharing with other people.
# via https://gist.github.com/1525217
function server() {
local host=`hostname`
local port="${1:-8888}"
(sleep 1 && open "http://${host}:${port}/")&
python -m SimpleHTTPServer "$port"
}
@jaan
jaan / Javascript Promises Resources
Created May 13, 2014 07:02
JavaScript Promises Resources
http://davidwalsh.name/write-javascript-promises

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt