Skip to content

Instantly share code, notes, and snippets.

View papandreou's full-sized avatar
💭
🤗

Andreas Lind papandreou

💭
🤗
View GitHub Profile
@papandreou
papandreou / app.js
Last active October 28, 2020 03:06
graphqlInMultipartFormDataMiddleware.js
const { graphqlExpress } = require('graphql-server-express');
const graphQlTools = require('graphql-tools');
const schema = graphQlTools.makeExecutableSchema({
typeDefs: schemaText,
resolvers: {
Mutation: {
async uploadFiles(obj, { input }, req, info }) {
// ...
try {
@papandreou
papandreou / assertion_structure.dot
Created May 8, 2017 06:40
Unexpected: Idea for a new internal assertion data structure
digraph "state machine" {
start [style=solid];
start_boolean [style=solid, label = ""];
start_boolean_tobetrue [shape="doublecircle", style="solid", label = ""]
start_boolean_tobefalse [shape="doublecircle", style="solid", label = ""]
start_string_nottocontain [style="solid", label = ""];
start_string_nottocontain_string [shape="doublecircle", style="solid", label = ""];
@papandreou
papandreou / numberOfSupportedAnsiColors.js
Last active August 16, 2016 23:13
Count ansi colors with node.js
var fs = require('fs');
function awaitEcho() {
var buf = new Buffer(100);
var numRead;
var offset = 0;
var startTime = Date.now();
do {
if (offset >= buf.length) {
[sharp-mem-usage]$ node --trace-gc test.js
[20872] 72 ms: Scavenge 2.0 (34.0) -> 1.7 (36.0) MB, 1 ms [allocation failure].
[20872] 87 ms: Scavenge 2.6 (37.0) -> 2.2 (37.0) MB, 0 ms [Runtime::PerformGC].
[20872] 104 ms: Scavenge 3.1 (38.0) -> 2.6 (38.0) MB, 0 ms [Runtime::PerformGC].
[20872] 125 ms: Scavenge 4.9 (38.0) -> 3.5 (38.0) MB, 0 ms [allocation failure].
example before iteration #1 { rss: 30646272, heapTotal: 10324992, heapUsed: 4529480 }
interpolateWith: Please use resize(w, h, { interpolator: ... }) instead
Nan::NewBuffer 0x7f4394140030
example before iteration #2 { rss: 39936000, heapTotal: 10324992, heapUsed: 4731056 }
Nan::NewBuffer 0x7f43503e64d0
[sharp-mem-usage]$ node --trace-gc test.js
[14826] 51 ms: Scavenge 2.0 (34.0) -> 1.7 (36.0) MB, 0 ms [allocation failure].
[14826] 62 ms: Scavenge 2.6 (37.0) -> 2.2 (37.0) MB, 0 ms [Runtime::PerformGC].
[14826] 76 ms: Scavenge 3.1 (38.0) -> 2.6 (38.0) MB, 0 ms [Runtime::PerformGC].
[14826] 104 ms: Scavenge 4.9 (38.0) -> 3.5 (38.0) MB, 0 ms [allocation failure].
example before iteration #1 { rss: 30654464, heapTotal: 10324992, heapUsed: 4529480 }
interpolateWith: Please use resize(w, h, { interpolator: ... }) instead
vips_tracked_get_mem 0
vips_tracked_get_mem_highwater 0
vips_tracked_get_allocs 0
[sharp-mem-usage]$ node --trace-gc test.js & while true; do smem |grep -P 'PID|node' ; done
[1] 6993
[6993] 52 ms: Scavenge 2.0 (34.0) -> 1.7 (36.0) MB, 0 ms [allocation failure].
[6993] 64 ms: Scavenge 2.6 (37.0) -> 2.2 (37.0) MB, 0 ms [Runtime::PerformGC].
[6993] 78 ms: Scavenge 3.1 (38.0) -> 2.6 (38.0) MB, 0 ms [Runtime::PerformGC].
[6993] 107 ms: Scavenge 4.9 (38.0) -> 3.6 (38.0) MB, 0 ms [allocation failure].
example before iteration #1 { rss: 30470144, heapTotal: 10324992, heapUsed: 4537384 }
interpolateWith: Please use resize(w, h, { interpolator: ... }) instead
PID User Command Swap USS PSS RSS
6993 andreas node --trace-gc test.js 0 617176 617220 620712
@papandreou
papandreou / gist:18eb731ea156d7b73930423e10a19bdc
Last active May 23, 2016 16:49
papandreou/sharp-mem-usage#5c9736924 (stream-based input)
[20376] 25 ms: Scavenge 2.0 (34.0) -> 1.7 (36.0) MB, 0 ms [allocation failure].
[20376] 33 ms: Scavenge 2.6 (37.0) -> 2.2 (37.0) MB, 0 ms [Runtime::PerformGC].
[20376] 42 ms: Scavenge 3.1 (38.0) -> 2.6 (38.0) MB, 0 ms [allocation failure].
[20376] 63 ms: Scavenge 4.9 (38.0) -> 3.6 (38.0) MB, 0 ms [allocation failure].
example before iteration #1 { rss: 32428032, heapTotal: 10324992, heapUsed: 4781072 }
example before iteration #2 { rss: 143507456, heapTotal: 11344896, heapUsed: 5253888 }
example before iteration #3 { rss: 259825664, heapTotal: 11344896, heapUsed: 5508976 }
[20376] 1679 ms: Mark-sweep 5.5 (40.0) -> 4.3 (40.0) MB, 3 / 7 ms [external memory allocation limit reached] [GC in old space requested].
example before iteration #4 { rss: 212398080, heapTotal: 11344896, heapUsed: 4582152 }
example before iteration #5 { rss: 221171712, heapTotal: 11344896, heapUsed: 4827872 }
@papandreou
papandreou / gist:3c30e0b5a11b5c70c87601430656cb6a
Last active May 23, 2016 16:49
papandreou/sharp-mem-usage#0678a2a38 (Buffer-based input)
[sharp-mem-usage]$ node --trace-gc test.js
[21672] 28 ms: Scavenge 2.0 (34.0) -> 1.7 (36.0) MB, 0 ms [allocation failure].
[21672] 35 ms: Scavenge 2.6 (37.0) -> 2.2 (37.0) MB, 0 ms [Runtime::PerformGC].
[21672] 44 ms: Scavenge 3.1 (38.0) -> 2.6 (38.0) MB, 0 ms [allocation failure].
[21672] 65 ms: Scavenge 4.9 (38.0) -> 3.6 (38.0) MB, 0 ms [allocation failure].
example before iteration #1 { rss: 36028416, heapTotal: 10324992, heapUsed: 4784416 }
example before iteration #2 { rss: 38891520, heapTotal: 10324992, heapUsed: 4971272 }
example before iteration #3 { rss: 44457984, heapTotal: 10324992, heapUsed: 5021840 }
example before iteration #4 { rss: 48631808, heapTotal: 10324992, heapUsed: 5039168 }
example before iteration #5 { rss: 57774080, heapTotal: 10324992, heapUsed: 5056496 }
@papandreou
papandreou / gist:2f81c12b47a9900b790f14db06e6cd24
Last active May 23, 2016 16:47
sharp memory test, node.js 0.10.45, Buffer input, papandreou/sharp-mem-usage#0678a2a3
[sharp-mem-usage]$ node --trace-gc test.js
[21672] 28 ms: Scavenge 2.0 (34.0) -> 1.7 (36.0) MB, 0 ms [allocation failure].
[21672] 35 ms: Scavenge 2.6 (37.0) -> 2.2 (37.0) MB, 0 ms [Runtime::PerformGC].
[21672] 44 ms: Scavenge 3.1 (38.0) -> 2.6 (38.0) MB, 0 ms [allocation failure].
[21672] 65 ms: Scavenge 4.9 (38.0) -> 3.6 (38.0) MB, 0 ms [allocation failure].
example before iteration #1 { rss: 36028416, heapTotal: 10324992, heapUsed: 4784416 }
example before iteration #2 { rss: 38891520, heapTotal: 10324992, heapUsed: 4971272 }
example before iteration #3 { rss: 44457984, heapTotal: 10324992, heapUsed: 5021840 }
example before iteration #4 { rss: 48631808, heapTotal: 10324992, heapUsed: 5039168 }
example before iteration #5 { rss: 57774080, heapTotal: 10324992, heapUsed: 5056496 }
@papandreou
papandreou / gist:ec40cdf768043fe0b33cea6097f55483
Last active May 23, 2016 16:41
sharp memory test, node.js 0.10.45, stream input
[sharp-mem-usage]$ node --trace-gc test.js
[20376] 25 ms: Scavenge 2.0 (34.0) -> 1.7 (36.0) MB, 0 ms [allocation failure].
[20376] 33 ms: Scavenge 2.6 (37.0) -> 2.2 (37.0) MB, 0 ms [Runtime::PerformGC].
[20376] 42 ms: Scavenge 3.1 (38.0) -> 2.6 (38.0) MB, 0 ms [allocation failure].
[20376] 63 ms: Scavenge 4.9 (38.0) -> 3.6 (38.0) MB, 0 ms [allocation failure].
example before iteration #1 { rss: 32428032, heapTotal: 10324992, heapUsed: 4781072 }
example before iteration #2 { rss: 143507456, heapTotal: 11344896, heapUsed: 5253888 }
example before iteration #3 { rss: 259825664, heapTotal: 11344896, heapUsed: 5508976 }
[20376] 1679 ms: Mark-sweep 5.5 (40.0) -> 4.3 (40.0) MB, 3 / 7 ms [external memory allocation limit reached] [GC in old space requested].
example before iteration #4 { rss: 212398080, heapTotal: 11344896, heapUsed: 4582152 }