Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
FROM golang:1.9 | |
RUN mkdir -p /go/src/github.com/purplebooth/example | |
WORKDIR /go/src/github.com/purplebooth/example | |
COPY . . | |
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go | |
FROM scratch | |
COPY --from=0 /go/src/github.com/purplebooth/example/main /main | |
CMD ["/main"] |
package main | |
//#include<stdio.h> | |
//void inC() { | |
// printf("I am in C code now!\n"); | |
//} | |
import "C" | |
import "fmt" | |
func main() { |
#include <stdio.h> | |
#include <node.h> | |
class WeakRef { | |
public: | |
WeakRef(v8::Isolate* isolate, v8::Local<v8::Value> func, const char* string): | |
string_(string) { | |
pers_.Reset(isolate, func); | |
pers_.SetWeak(this, DeleteMe, v8::WeakCallbackType::kParameter); | |
} |
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
/* test load from stream | |
* | |
* compile with: | |
* | |
* gcc -g -Wall load-from-stream.c `pkg-config vips --cflags --libs` | |
* | |
* test with: | |
* | |
* cat k2.jpg k4.jpg | ./a.out | |
*/ |
{ | |
"targets": [ | |
{ | |
"target_name": "example_addon", | |
"sources": [ "example_addon.c" ], | |
"include_dirs": [ "<!@(node -p \"require('node-addon-api').include\")" ], | |
"dependencies": [ "<!@(node -p \"require('node-addon-api').gyp\")" ] | |
} | |
] | |
} |
A quick overview of the node.js streams interface with basic examples.
This is based on @brycebaril's presentation, Node.js Streams2 Demystified
Streams are a first-class construct in Node.js for handling data.
Think of them as as lazy evaluation applied to data.
for i in `ls *.svg` | |
rsvg-convert -f pdf -o PDF/${i}.pdf $i |
#user nobody; | |
#Defines which Linux system user will own and run the Nginx server | |
worker_processes 1; | |
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores. | |
#error_log logs/error.log; #error_log logs/error.log notice; | |
#Specifies the file where server logs. |