Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Nicola Del Gobbo NickNaso

🎯
Focusing
Block or report user

Report or block NickNaso

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View omg-this-works.js
const {createServer} = require('http');
const {promisify} = require('util')
const hostname = '127.0.0.1';
const port = 3000;
const server = createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
@NickNaso
NickNaso / carray2slice.go
Created Nov 19, 2019 — forked from nasitra/carray2slice.go
Convert 'C' array to golang slice
View carray2slice.go
func carray2slice(array *C.int, len int) []C.int {
var list []C.int
sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&list)))
sliceHeader.Cap = len
sliceHeader.Len = len
sliceHeader.Data = uintptr(unsafe.Pointer(array))
return list
}
@NickNaso
NickNaso / binding.cpp
Last active Nov 8, 2019
Pass object to AsyncWorker
View binding.cpp
#include<napi.h>
#include <chrono>
#include <thread>
use namespace Napi;
class EchoWorker : public AsyncWorker {
public:
EchoWorker(Function& callback, Object& options, std::string& echo)
@NickNaso
NickNaso / upload.js
Created Sep 26, 2019 — forked from virolea/upload.js
Tracking file upload progress using axios
View upload.js
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@NickNaso
NickNaso / nvm-node-nightlies.md
Created Aug 13, 2019 — forked from chicoxyzzy/nvm-node-nightlies.md
Installing Node Nightlies via nvm
View nvm-node-nightlies.md

You can install Node Nightlies/RCs via nvm using NVM_NODEJS_ORG_MIRROR environment variable.

Install latest Node RC

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc/ nvm i node

Install latest Node.js Nightly

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm i node
@NickNaso
NickNaso / addon.js
Created Jun 27, 2019 — forked from gabrielschulhof/addon.js
Send modules to native
View addon.js
const addon = require('bindings')('addon');
addon.receiveModule('fs', require('fs'));
addon.receiveModule('crypto', require('crypto'));
console.log(addon.sendModule('fs') === require('fs'));
console.log(addon.sendModule('crypto') === require('crypto'));
@NickNaso
NickNaso / CMakeLists.txt
Created Jun 12, 2019
CMake file to build cerberus addon with cmakejs
View CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set (CMAKE_CXX_STANDARD 11)
# Name of the project (will be the name of the plugin)
project(Cerberus)
set(VLC_LIB_DIR ${CMAKE_SOURCE_DIR} "libvlcpp/vlcpp")
if(MSVC)
@NickNaso
NickNaso / webpack-bundle-for-node.js
Last active May 27, 2019
Configuration sample to create bundle for node.js application using webpack
View webpack-bundle-for-node.js
const path = require('path')
const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
module.exports = {
entry: {
server: './server.js',
},
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
@NickNaso
NickNaso / closures-basic.c
Created Mar 17, 2019 — forked from vidarh/closures-basic.c
A number of ways to implement closures in C, in preparation of an upcoming blog post
View closures-basic.c
#include <stdio.h>
#include <stdlib.h>
struct closure {
void (* call)(struct closure *);
int x;
};
View callbacks-promises-asyncfuncs.js
// From callbacks to Promises to async functions
function callbackFunc(x, callback) {
f1(x, (err1, result1) => {
if (err1) {
console.error(err1);
callback(err1);
return;
}
f2(result1, (err2, result2) => {
You can’t perform that action at this time.