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.
// | |
// 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'); |
var nodes = document.querySelectorAll('[id]'); | |
var ids = {}; | |
var totalNodes = nodes.length; | |
for(var i=0; i<totalNodes; i++) { | |
var currentId = nodes[i].id ? nodes[i].id : "undefined"; | |
if(!ids[currentId]) { | |
ids[currentId] = []; | |
} | |
ids[currentId].push(nodes[i]); |