Skip to content

Instantly share code, notes, and snippets.

View VanDalkvist's full-sized avatar

Ivan VanDalkvist

  • Yandex
View GitHub Profile
@VanDalkvist
VanDalkvist / event-loop.md
Created September 7, 2018 08:31 — forked from jesstelford/event-loop.md
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

One always has, at every stage, in the process, a working system. I
find that teams can grow much more complex entities in four months
than they can build.
-- Fred Brooks, "No Silver Bullet"
%
I made this letter longer than usual because I lack the time to make it shorter.

AngularJS Directive Attribute Binding Explanation

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.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@VanDalkvist
VanDalkvist / angularjs-providers-explained.md
Created April 20, 2016 20:05 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

var WebSocketServer = require('websocket').server;
var http = require('http');
var server = http.createServer(function(request, response) {
console.log((new Date()) + ' Received request for ' + request.url);
response.writeHead(404);
response.end();
});
server.listen(9000, function() {
gulp.task('cordova-plugin-install', function() {
require('./plugins.json').forEach(function(plugin) {
sh.exec('cordova plugin add ' + plugin, {async: false}, function(code, output) {
console.log(output);
});
});
});
// ng-include-view
// - directive in module ng
//
// This works similar to ng-include and it won't create new scope,
// instead it uses the same level
//
// Example usage:
// <ng-include-view src=""></ng-include-view>

Node Error Handling and Domains

"Occurrences in this domain are beyond the reach of exact prediction because of the variety of factors in operation, not because of any lack of order in nature." - Albert Einstein

"Master of my domain" - Larry David

Error handling in an asynchronous language works in a unique way and presents many challenges, some unexpected. This tutorial reviews the various error handling patterns available in node, and explains how domains can be used to improve it.

There are four main error handling patterns in node:

  • Error return value