Skip to content

Instantly share code, notes, and snippets.

Trevor Norris trevnorris

Block or report user

Report or block trevnorris

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
@trevnorris
trevnorris / watched-anime_2017-10.txt
Created Apr 24, 2019
List of all anime I've watched
View watched-anime_2017-10.txt
.hack//Roots
In the online RPG know as "The World," Haseo and his guild mates are on the search for a legendary item. When a rival team challenges them, the conflict has deep repercussions both inside and outside the game, and threatens to change the players forever.
.hack//SIGN
Tsukasa wakes up inside The World, a massive online role-playing game full of magic and monsters, and finds himself unable to log out. How did he end up stuck in this digital realm, and what, exactly, is going on in the real world?
A Certain Magical Index
In a world where magic is as real as science, high-school student Kamijo comes to the aid of a young nun named Index. She's on the run from a magic society that covets the massive library of forbidden knowledge stored in her memory.
A Certain Scientific Railgun
@trevnorris
trevnorris / build_steps.txt
Last active Aug 10, 2018
How to build node with shared libuv
View build_steps.txt
libuv:
$ ./gyp_uv.py -f make -Dlibrary=shared_library
$ BUILDTYPE=Release make -j6 -C out
node:
$ ./configure --shared-libuv --shared-libuv-includes=$LIBUV_PATH/include --shared-libuv-libpath=$LIBUV_PATH/out/Release
$ make -j6
binary build:
$ CONFIG_FLAGS="--shared-libuv --shared-libuv-includes=$LIBUV_PATH/libuv/include --shared-libuv-libpath=$LIBUV_PATH/out/Release" DISTTYPE=custom CUSTOMTAG="$(date +'%s')" make -j6 binary
View main.cc
#include <v8.h>
#include <node.h>
#define NEW_FROM_ONEBYTE(iso, name) \
v8::String::NewFromOneByte( \
iso, \
reinterpret_cast<const uint8_t*>(name), \
NewStringType::kInternalized).ToLocalChecked()
#define RUNTIME_TESTS(V) \
@trevnorris
trevnorris / fn_ptr_trampoline.cc
Created Sep 2, 2017
Use a recast function pointer in a lambda trampoline to allow arbitrary callback signatures
View fn_ptr_trampoline.cc
// Hypothetical asynchronous C library call
typedef void (*future_cb)(void* data);
void call_in_the_future(future_cb cb, void* data) {
cb(data);
}
template <class C>
struct Base {
template <typename DataType = void*>
void run(void (*cb)(C*, DataType*) = nullptr, DataType* ptr = nullptr) {
View rethrow_without_verbose.diff
diff --git a/test/addons/async-hello-world/binding.cc b/test/addons/async-hello-world/binding.cc
index da2bd41..5ddd61f 100644
--- a/test/addons/async-hello-world/binding.cc
+++ b/test/addons/async-hello-world/binding.cc
@@ -44,13 +44,11 @@ void AfterAsync(uv_work_t* r) {
v8::Local<v8::Function>::New(isolate, req->callback);
callback->Call(isolate->GetCurrentContext()->Global(), 2, argv);
+ printf("did rethrow: %s\n", !try_catch.ReThrow().IsEmpty() ? "true" : "false");
+
View .tmux.conf
# basic configs #
setw -g mode-keys vi
set -g default-terminal "xterm-256color"
set -g history-limit 10000
# C-a is escape sequence #
unbind C-b
set -g prefix C-a
bind C-a last-window
bind a send-prefix
View udp_client.js
'use strict';
Error.stackTraceLimit = Infinity;
const dgram = require('dgram');
const print = process._rawDebug;
// Problem doesn't exist with localhost, so plug in a Google server's IP.
const HOST = '172.217.5.110';
const client = dgram.createSocket('udp4');
const message = Buffer.alloc((1 << 16) - 29);
@trevnorris
trevnorris / fs-scan-n-read-bench.js
Last active Mar 11, 2017
Benchmark to show performance difference between fs sync and async calls
View fs-scan-n-read-bench.js
'use strict';
const MAX_DEPTH = 4;
const fs = require('fs');
const print = process._rawDebug;
const sep = require('path').sep;
const tmpdir = require('os').tmpdir() + sep + 'data-file-bench-' + genName();
const file_list = newDir();
var current_dir = file_list;
View ab-write.strace
execve("./node", ["./node", "/tmp/test-fs-ab.js"], [/* 81 vars */]) = 0
brk(NULL) = 0x20f2000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2b745f6000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=184604, ...}) = 0
mmap(NULL, 184604, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2b745c8000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
@trevnorris
trevnorris / intercept-stdio.cc
Last active Feb 27, 2017
Example of how to intercept messages to stdout/stderr
View intercept-stdio.cc
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#if defined(__unix__) || defined(__unix) || \
(defined(__APPLE__) && defined(__MACH__))
#include <unistd.h>
#endif
You can’t perform that action at this time.