Skip to content

Instantly share code, notes, and snippets.

View NatalieWolfe's full-sized avatar

Natalie Wolfe NatalieWolfe

View GitHub Profile
@NatalieWolfe
NatalieWolfe / greeter_service.proto
Created February 9, 2022 06:11
Example for combining Epoll and gRPC event queues.
syntax = "proto3";
package lw;
service GreeterService {
rpc SayHello (HelloRequest) returns (HelloResponse) {}
}
message HelloRequest {
string name = 1;
@NatalieWolfe
NatalieWolfe / watch.sh
Last active April 10, 2020 15:31
Script to watch a directory for changes.
#!/bin/bash
# Usage: ./watch.sh watch_id path_to_watch
touch "/tmp/watch_${1}_1"
ls -x > "/tmp/watch_${1}_2"
cat "/tmp/watch_${1}_1" "/tmp/watch_${1}_2" | sort | uniq
mv "/tmp/watch_${1}_2" "/tmp/watch_${1}_1"
@NatalieWolfe
NatalieWolfe / server.js
Created October 11, 2017 23:41
Simple async-hook server use.
'use strict'
var asyncHooks = require('async_hooks')
var ids = new Map()
var toReturn
var noopHook = asyncHooks.createHook({
init: function initHook(id, type) {
if (type !== 'PROMISE') {
return
}
@NatalieWolfe
NatalieWolfe / smart_compare.cpp
Created March 9, 2017 22:50
Compares strings composed of mixed digits and letters
#include <cctype>
#include <iostream>
#include <string>
int get_int(const std::string& str, std::size_t& i) {
int val = 0;
for (; i < str.size() && std::isdigit(str.at(i)); ++i) {
val *= 10;
enum class Type : int {
Song,
Artist,
Release,
Playlist
};
static const std::map< Type, std::string > TypeStrings{
{ Type::Song, "song" },
@NatalieWolfe
NatalieWolfe / Results
Last active February 22, 2022 18:53
Testing various methods of passing functions around.
natalie@WorkBook:funcSpeed$ g++ -std=c++11 test.cpp main.cpp -o funcSpeed && ./funcSpeed
--- Direct Call Tests ---
testInline 9317ms.
testExternal 9433ms.
tester.testInlineMember 9252ms.
tester.testExternalMember 9328ms.
--- Pointer Call Tests ---
(&testInline) 9401ms.
(&testExternal) 9642ms.
(tester.*(&Test::testInlineMember)) 9515ms.