Skip to content

Instantly share code, notes, and snippets.

View gabrielschulhof's full-sized avatar

Gabriel Schulhof gabrielschulhof

  • California, USA
View GitHub Profile
@gabrielschulhof
gabrielschulhof / binding.cc
Last active February 13, 2019 22:35
static function address reuse on OSX
#include <assert.h>
#include <node.h>
#include "common.h"
namespace {
void Init(v8::Local<v8::Object> exports,
v8::Local<v8::Object> module,
v8::Local<v8::Context> context) {
v8::Local<v8::Name> propName =
Process 15817 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.4
frame #0: 0x0000000105b66385 binding_noexcept.node`Napi::AsyncWorker::AsyncWorker(this=0x0000000105915dd0, receiver=0x00007ffeefbfca10, callback=0x00007ffeefbfcad0, resource_name="TestResource", resource=0x00007ffeefbfca78) at napi-inl.h:3537
3534 auto runner = AsyncWorker::OnExecute;
3535 auto completer = AsyncWorker::OnWorkComplete;
3536
-> 3537 status = napi_create_async_work(_env, resource, resource_id, runner,
3538 completer, this, &_work);
3539 NAPI_THROW_IF_FAILED_VOID(_env, status);
3540 }
OpenSSH_7.5p1, OpenSSL 1.1.0h-fips 27 Mar 2018
debug1: Reading configuration data /home/nix/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 56: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-]
debug3: kex names ok: [[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]
debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *
#include <stdio.h>
class Signature;
class FunctionTemplate;
template <class V8Type>
class Local {
public:
// Local(const char* x, Local<FunctionTemplate> y):
// val_(nullptr), realval_(x, y) {}
#include <assert.h>
#include <stdio.h>
#include <node_api.h>
static napi_value AcceptTypedArray(napi_env env, napi_callback_info info) {
napi_value typed_array = nullptr;
size_t argc = 1;
assert(napi_get_cb_info(env,
info,
&argc,
#cloud-config
password: vubuntu
chpasswd: { expire: False }
ssh_pwauth: True
network:
version: 2
ethernets:
enp0s3:
dhcp4: true
gateway4: 192.168.56.1
{
'variables': {
'node_iconv_use_system_libiconv%': 0,
},
'targets': [
{
'target_name': 'iconv',
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'sources': ['src/binding.cc'],
struct IconvObject : public Napi::ObjectWrap<IconvObject> {
IconvObject(const Napi::CallbackInfo& info):
Napi::ObjectWrap<IconvObject>(info) {
conv_ = info[0].As<Napi::External<iconv_t>>().Data();
}
iconv_t conv_;
~IconvObject() {
iconv_close(conv_);
}
};
@gabrielschulhof
gabrielschulhof / binding.cc
Last active September 19, 2018 18:44
Doing extends on the native side
#include <stdio.h>
#include <node.h>
static void
NativeClassConstructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
}
static void
NativeClassProtoMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
fprintf(stderr, "NativeClassProtoMethod was called\n");
@gabrielschulhof
gabrielschulhof / patience.patch
Created August 29, 2018 13:23
patience vs. plain
diff --git a/src/node_api.cc b/src/node_api.cc
index 7b6e43d0ce..1dd31107dc 100644
--- a/src/node_api.cc
+++ b/src/node_api.cc
@@ -827,6 +827,336 @@ napi_status ConcludeDeferred(napi_env env,
return GET_RETURN_STATUS(env);
}
+class ThreadSafeFunction : public node::AsyncResource {
+ public: