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.
# This is a really old post, in the comments (and stackoverflow too) you'll find better solutions. | |
def find(key, dictionary): | |
for k, v in dictionary.iteritems(): | |
if k == key: | |
yield v | |
elif isinstance(v, dict): | |
for result in find(key, v): | |
yield result | |
elif isinstance(v, list): |
FRP to me means building your app by transforming values over time, from the input to the current state to the display.
This implementation is based on a the [graphics][1] library and is heavily inspired by [Elm][2]
A full implementation of TodoFRP can be found [online at Raynos/graphics example server][3]
// Compute the Levenshtein distance between `Array`-like sequences `a` and `b`; the minimum number of | |
// single-element insertions, deletions and substitutions necessary to transform `a` into `b`. | |
// Strict equality semantics are used by default to compare sequence elements; a function `equal` can | |
// optionally be provided to alter this behavior. | |
function levenshtein(a, b, equal) { | |
// `aii` and `bii` are used to track `ai - 1` and `bi - 1` more or less free of charge. | |
// `d0` and `d1` are used to store the 'previous' and 'current' rows respectively. | |
// `x`, `y` and `z` are used to permit the implementation of an optimized `min` using a ternary expression. | |
var ai, aii, ae, al, bi, bii, bl, d0, d1, dd, x, y, z; | |
if(a === b) return 0; |
var helper = window.helper = { | |
/* | |
Boolean | |
*/ | |
isiPad: navigator.userAgent.match(/iPad/i) != null, | |
isRetina: window.devicePixelRatio && window.devicePixelRatio > 1, | |
isOnline: navigator.onLine, | |
isWebAppMode: window.navigator.standalone || false, | |
landscape: function(){ return Math.abs(helper.orientation) === 90; }, | |
portrait: function(){ return !helper.landscape() }, |
var HandheldFriendlyTag=document.createElement('meta'); | |
HandheldFriendlyTag.id="HandheldFriendly"; | |
HandheldFriendlyTag.name = "HandheldFriendly"; | |
HandheldFriendlyTag.content = "true"; | |
document.getElementsByTagName('head')[0].appendChild(HandheldFriendlyTag); | |
var MobileOptimizedTag=document.createElement('meta'); | |
MobileOptimizedTag.id="MobileOptimized"; | |
MobileOptimizedTag.name = "MobileOptimized"; | |
MobileOptimizedTag.content = "320"; | |
document.getElementsByTagName('head')[0].appendChild(MobileOptimizedTag); |
## projectName | |
<VirtualHost *:80> | |
ServerName projectName.local.plou | |
CustomLog "/www/.logs/projectName.local.plou-access_log" combined | |
ErrorLog "/www/.logs/projectName.local.plou-error_log" | |
DocumentRoot "/www/projectName/" | |
Header set Access-Control-Allow-Origin "*" | |
Header always set Access-Control-Allow-Methods "POST, PUT, GET, DELETE, OPTIONS" | |
Header always set Access-Control-Allow-Headers "Content-Type" | |
</VirtualHost> |
function quicksort (array, left, right) { | |
var index, pivot, l, r, temp; | |
if (array.length > 1) { | |
left = typeof left === 'undefined' ? 0 : left; | |
right = typeof right === 'undefined' ? array.length - 1 : right; | |
// partition(array, left, right) |
#########
#########
It's not that I want to avoid those particular tags; I just want to generate the most documentation with the fewest number of tags. Lots of tags start impacting code readability.
Here's a better illustration of my use case. A few constructors are defined inside of an IIFE in order to keep them out of the global namespace. They are then exported with an AMD module definition at the bottom:
(function () {
// Add Rules to Stylesheets with JavaScript | |
// http://davidwalsh.name/add-rules-stylesheets | |
/* Getting the Stylesheet | |
Which stylesheet you add the rules to is up to you. If you have a specific stylesheet in mind, you can add an ID to the LINK or STYLE element within your page HTML and get the CSSStyleSheet object by referencing the element's sheet property. The stylesheets can be found in the document.styleSheets object:*/ | |
var sheets = document.styleSheets; // returns an Array-like StyleSheetList | |
/* | |
Returns: |