(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.
| function logClass(target: any) { | |
| // save a reference to the original constructor | |
| var original = target; | |
| // a utility function to generate instances of a class | |
| function construct(constructor, args) { | |
| var c : any = function () { | |
| return constructor.apply(this, args); | |
| } |
(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.
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.| function calCulateReverse(number){ | |
| var arr= String(number).split(''); | |
| var mid = (arr.length - 1)/2; | |
| var left = 0; | |
| var right = arr.length - 1; | |
| var rightLarge = false; | |
| while(true){ | |
| if(left == right){ | |
| if(rightLarge){ |
When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.
Raw Attribute Strings
<div my-directive="some string" another-param="another string"></div>| /* global require */ | |
| var gulp = require('gulp'), | |
| os = require('os'), | |
| path = require('path'), | |
| gutil = require('gulp-util'), | |
| del = require('del'), | |
| rename = require('gulp-rename'), | |
| karma = require('karma').server, | |
| uglify = require('gulp-uglifyjs'), | |
| less = require('gulp-less'), |
| { | |
| // JSHint configuration for server-side development | |
| // See http://jshint.com/docs/ for more details | |
| "maxerr" : 50, // {int} Maximum error before stopping | |
| // Enforcing | |
| "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) | |
| "camelcase" : true, // true: Identifiers must be in camelCase | |
| "curly" : true, // true: Require {} for every new block or scope |
| [user] | |
| name = Josh Yu | |
| email = joshyupeng@gmail.com | |
| [core] | |
| editor = vim | |
| pager = less | |
| autocrlf = true | |
| [color] | |
| ui = auto | |
| [merge] |
IOS safari accept apple-touch-icon to be shown as bookmark icon, the minimal acceptable size is 57x57, otherwise the icon will be shown as internal default icon compass.
define the bookmark icon as below:
<link rel="apple-touch-icon" sizes="57x57" href="touch-icon-ipad.png">