0 constant nil | |
: cons ( car cdr -- list ) here >r swap , , r> ; | |
: list ( x... #x -- list ) nil swap 0 ?do cons loop ; | |
: list: ( x... #x "name" -- ) list constant ; | |
: car ( list -- car ) @ ; | |
: car! ( car list -- ) ! ; | |
: cdr ( list -- cdr ) cell+ @ ; | |
: cdr! ( cdr list -- ) cell+ ! ; | |
: list. ( list -- ) begin ?dup while dup car . cdr repeat ; |
#!/bin/bash | |
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/ | |
E_BADARGS=99 | |
baseName=$(basename $0) | |
function printHelp() { | |
>&2 echo -e "\nUsage: " |
Here's an example of how to debug Mocha v4 if it hangs.
Ensure you're using a Node.js 8 or newer (or any version with async_hooks support).
If you run your test, you'll notice it hangs:
$ mocha test.js
Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.
This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would
Various 'features' of C++ that show the hacky / inconsistent way in which the language was constructed. This is a work in progress, and currently contains some of the reasons I can remember why I've given up on C++. If you want to contribute, leave your favourite "hack" in the comments.
-
(in)Visibility: C++ allows changing the access modifier of a virtual function in the derived class. Not only does C++ have no notion of interfaces, it actually allows subclasses to hide public methods from the superclass.
-
Operator over-overloading: One of the increment operators takes a dummy int parameter in order to allow overloading. Can you tell which without googling? (hint: it is postfix).
-
Exception unspecifiers: C++ has two types of exception specifiers: throw() and nothrow. The first is deprecated (because 'we screwed up, sorry, let's forget about this terrible mess'). The second one guarantees its contract by terminating the application when violated. That's because functions declared nothro
#include <stdio.h> | |
#define STR2(x) #x | |
#define STR(x) STR2(x) | |
#ifdef _WIN32 | |
#define INCBIN_SECTION ".rdata, \"dr\"" | |
#else | |
#define INCBIN_SECTION ".rodata" | |
#endif |
"How do I get started with Node?" is a commonly heard question in #Node.js. This gist is an attempt to compile some of the answers to that question. It's a perpetual work-in-progress.
And if this list didn't quite answer your questions, I'm available for tutoring and code review! A donation is also welcome :)
Before you get started learning about JavaScript and Node.js, there's one very important article you need to read: Teach Yourself Programming in Ten Years.
Understand that it's going to take time to learn Node.js, just like it would take time to learn any other specialized topic - and that you're not going to learn effectively just by reading things, or following tutorials or courses. _Get out there and build things!
var a = ["sdfdf", "http://oooooolol"], | |
handleNetErr = function(e) { return e }; | |
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr)) | |
.then(function(sdf, invalid) { | |
console.log(sdf, invalid) // [Response, TypeError] | |
}) | |
.catch(function(err) { | |
console.log(err); | |
}) |
db.currentOp().inprog.forEach( | |
function(op) { | |
if(op.secs_running > 5) printjson(op); | |
} | |
) |