Skip to content

Instantly share code, notes, and snippets.

View NickNaso's full-sized avatar
🎯
Focusing

Nicola Del Gobbo NickNaso

🎯
Focusing
View GitHub Profile
@NickNaso
NickNaso / Dockerfile
Created August 10, 2018 19:34 — forked from PurpleBooth/Dockerfile
Create a static binary in go and put it in a from scratch docker container
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"]
@NickNaso
NickNaso / cgo1.go
Created July 7, 2018 11:05 — forked from tejainece/cgo1.go
Examples of calling C code from Golang
package main
//#include<stdio.h>
//void inC() {
// printf("I am in C code now!\n");
//}
import "C"
import "fmt"
func main() {
@NickNaso
NickNaso / binding.cc
Created July 6, 2018 08:32 — forked from gabrielschulhof/binding.cc
GC behaviour wrt. native function vs. plain object vs. JS function
#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);
}
@NickNaso
NickNaso / gist:181974062972fb83b877e586c9b97687
Created May 22, 2018 20:57 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
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
@NickNaso
NickNaso / load-from-stream.c
Created March 29, 2018 20:22 — forked from jcupitt/load-from-stream.c
test libvips load from stream
/* 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
*/
@NickNaso
NickNaso / nodejs-custom-es6-errors.md
Created January 19, 2018 14:45 — forked from slavafomin/nodejs-custom-es6-errors.md
Custom ES6 errors in Node.js

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.

Defining our own base class for errors

errors/AppError.js

{
"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\")" ]
}
]
}
@NickNaso
NickNaso / README.md
Created January 9, 2018 23:26 — forked from joyrexus/README.md
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@NickNaso
NickNaso / svg-to-vector-pdf.sh
Created January 6, 2018 13:48 — forked from tpitale/svg-to-vector-pdf.sh
Loop to rsvg-convert all SVG files to Vector PDF
for i in `ls *.svg`
rsvg-convert -f pdf -o PDF/${i}.pdf $i
@NickNaso
NickNaso / nginx.conf.default
Created October 5, 2017 04:44 — forked from nishantmodak/nginx.conf.default
Default Nginx Conf
#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.