Update: please note that I have since switched to using a set of bash scripts instead of poluting the Git repository with git svn.
Author: Kaspars Dambis
kaspars.net / @konstruktors
| <# | |
| .SYNOPSIS | |
| This is a Powershell script to dump console buffer as html to file. | |
| .DESCRIPTION | |
| This Powershell script will iterate over the current console buffer and | |
| output it as html preserving colors. | |
| .PARAMETER FilePath |
| SELECT | |
| o.name as 'TableName' , | |
| SUM ( | |
| CASE | |
| WHEN (index_id < 2) THEN row_count | |
| ELSE 0 | |
| END | |
| ) as 'RowCount', | |
| LTRIM (STR (SUM (reserved_page_count)/1024 * 8, 15, 0) + ' MB') as'Reserved MB', |
| /* @flow */ | |
| declare module 'dynamoose' { | |
| declare type Throughput = number | ({ | |
| read: number; | |
| } | { | |
| write: number; | |
| }); | |
| declare type ThroughputConfig = { | |
| throuput: Throughput; |
| // Custom made dynamoose declaration file. | |
| declare module "dynamoose" { | |
| export function local(url: string): void; | |
| export function model<DataSchema, KeySchema, ModelSchema extends Model<DataSchema>>( | |
| modelName: string, | |
| schema: Schema, | |
| options?: ModelOption | |
| ): ModelConstructor<DataSchema, KeySchema, ModelSchema>; | |
| export function setDefaults(options: ModelOption): void; |
Update: please note that I have since switched to using a set of bash scripts instead of poluting the Git repository with git svn.
Author: Kaspars Dambis
kaspars.net / @konstruktors
| // context | |
| var mongoose = require('mongoose'); | |
| mongoose.connect('mongodb://...'); | |
| /** | |
| * Generates Mongoose uniqueness validator | |
| * | |
| * @param string modelName | |
| * @param string field | |
| * @param boolean caseSensitive |
It's possible for a developer to create a new domain and then simply run
domain.enter(). Which then acts as a catch-all for any exception in the
future that couldn't be observed by the thrower. Allowing a module author to
intercept the exceptions of unrelated code in a different module. Preventing
@mafintosh asks: "Does anyone have a good code example of when to use setImmediate instead of nextTick?"
https://twitter.com/mafintosh/status/624590818125352960
The answer is "generally anywhere outside of core".
process.nextTick is barely asynchronous. Flow-wise it is asynchronous, but it will trigger before any other asynchronous events can (timers, io, etc.) and thus can starve the event loop.
In this script I show a starved event loop where I just synchronously block, use nextTick and setImmediate
| "use strict"; | |
| var clsModule = require("continuation-local-storage"); | |
| const superagent = require("superagent"); | |
| const assert = require("assert"); | |
| var http = require("http"); | |
| var keepAlive = process.env.KEEP_ALIVE !== "0"; | |
| var httpAgent = new http.Agent({ | |
| keepAlive: keepAlive, |
| 'use strict'; | |
| const asyncWrap = process.binding('async_wrap'); | |
| const fs = require('fs'); | |
| // | |
| // Track | |
| // | |
| // 1. Setup a global variable to track the context of the async_hook_init_function | |
| let callbackContext = 'root'; | |
| process.nextTick(function () { |