Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.
- Go to
settings
. - Search for
live templates
. - Under the javascript section you should be able to manage your templates.
/* | |
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license | |
* Author: Jim Palmer (based on chunking idea from Dave Koelle) | |
* Reference: http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm/ | |
*/ | |
function naturalSort (a, b) { | |
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, | |
sre = /(^[ ]*|[ ]*$)/g, | |
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, | |
hre = /^0x[0-9a-f]+$/i, |
// | |
// Regular Expression for URL validation | |
// | |
// Author: Diego Perini | |
// Updated: 2010/12/05 | |
// License: MIT | |
// | |
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it) | |
// | |
// Permission is hereby granted, free of charge, to any person |
Select all below snippet => drag and drop in browser bookmark bar | |
=> click on bookmark which you have just add => check the browser console | |
javascript:(function(){var e={};$("[id]").each(function(){var t=$('[id="'+this.id+'"]');if(t.length>1&&t[0]===this){e.id=this.id;e.obj=this;e.obj2=t[0]}});console.warn("Duplicate ID:",e.id,e.obj,e.obj2)})(); |
var myString = 'EXAMPLEstring'; | |
var myNewString = myString.replace(/[A-Z]/g, '0'); | |
console.log(myNewString); | |
function replaceFunc (a, b, c) { | |
console.log(a, b, c); | |
return a.toLowerCase(); | |
} | |
var myOtherString = myString.replace(/[A-Z]/g, replaceFunc); |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Array.prototype.remove = function(from, to) { | |
var rest = this.slice((to || from) + 1 || this.length); | |
this.length = from < 0 ? this.length + from : from; | |
return this.push.apply(this, rest); | |
}; | |
http://ejohn.org/blog/javascript-array-remove/ |
export const GoogleApi = function(opts) { | |
opts = opts || {} | |
const apiKey = opts.apiKey; | |
const libraries = opts.libraries || []; | |
const client = opts.client; | |
const URL = 'https://maps.googleapis.com/maps/api/js'; | |
const googleVersion = '3.22'; | |
let script = null; |
import React from 'react' | |
var Child = React.createClass({ | |
getInitialState: function(){ | |
console.log('Child getInitialState'); | |
return { value: 'start'} | |
}, | |
getDefaultProps: function(){ | |
console.log('Child getDefaultProps'); |