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 / get-symbol-from-current-process.h
Created May 10, 2020 15:06
C function to get a symbol from the current process
#ifndef _GET_SYMBOL_FROM_CURRENT_PROCESS_H
#define _GET_SYMBOL_FROM_CURRENT_PROCESS_H
#include <assert.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h>
#endif
@NickNaso
NickNaso / binding.gyp
Created April 30, 2020 09:48
Process JSON on node-addon-api (SImple example)
{
"targets": [
{
"target_name": "json",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"sources": [ "json.cc" ],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")"
],
@NickNaso
NickNaso / binding.gyp
Created April 27, 2020 13:46
N-API register module (the new way)
{
"targets": [
{
"target_name": "hello",
"sources": [ "hello.cc" ]
}
]
}
@NickNaso
NickNaso / binding.gyp
Created April 17, 2020 13:57
How to change default compiler to build native addon for Node.js
# This file inherits default targets for Node addons, see https://github.com/nodejs/node-gyp/blob/master/addon.gypi
{
# https://github.com/springmeyer/gyp/blob/master/test/make_global_settings/wrapper/wrapper.gyp
'make_global_settings': [
['CXX', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
['CC', '<(module_root_dir)/mason_packages/.link/bin/clang'],
['LINK', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
['AR', '<(module_root_dir)/mason_packages/.link/bin/llvm-ar'],
['NM', '<(module_root_dir)/mason_packages/.link/bin/llvm-nm']
],
@NickNaso
NickNaso / enable-gatekeeper.sh
Created March 6, 2020 11:32
Enable Gatekeeper
sudo spctl --master-enable
@NickNaso
NickNaso / disable-gatekeeper.sh
Last active March 6, 2020 11:30
Disable Gatekeeper
sudo spctl --master-disable
@NickNaso
NickNaso / index.html
Created February 28, 2020 20:31 — forked from gaearon/index.html
Add React in One Minute
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Add React in One Minute</title>
</head>
<body>
<h2>Add React in One Minute</h2>
<p>This page demonstrates using React with no build tooling.</p>
@NickNaso
NickNaso / binding.gyp
Created February 28, 2020 11:47
Enable RTTI support for macOS
{
'targets': [
{
'target_name': 'bindings',
'sources': [ 'bindings.cc' ],
'cflags_cc!': [ '-fno-rtti' ],
'conditions': [
['OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_RTTI': 'YES'
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 November 19, 2019 17:57 — forked from nasitra/carray2slice.go
Convert 'C' array to golang slice
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
}