Skip to content

Instantly share code, notes, and snippets.

@freezer333
freezer333 / array_prop.cpp
Created March 22, 2017 21:37
Access array in object via NAN
// JS calling code
var obj = {
a: 5,
b : [1, 2, 3]
}
addon.add_array(obj);
assert(obj.b[0] == 6);
assert(obj.b[1] == 7);
assert(obj.b[2] == 8);
@freezer333
freezer333 / prime_sieve.c
Created December 12, 2015 14:31
Prime Sieve C implementation written by Achim Flammenkamp, Bielefeld, D, achim@uni-bielefeld.de
#include <stdio.h> /* Achim Flammenkamp, Bielefeld, D, achim@uni-bielefeld.de */
#include <malloc.h>/* ifdefs: LONG=uns64 _ANSI_EXTENSION true_64bit_words */
#include <stdlib.h>/* SUM_{p<x} 1/p= ln(ln(x))+0.5772156649015-0.315718451893 */
#include <math.h> /* extern double sqrt(double), log(double), floor(double); */
#ifndef uns32 /* Version 1.0a 1998-05-19 source availible */
#define uns32 unsigned /* Version 2.0a 1998-05-23 5 years in the WWW */
#endif /* Version 2.0b 2003-06-03 0-1-typo fixed Argh! */
#ifndef uns64 /* Version 2.0c 2003-06-04 works up to 2^64-1 */
# ifdef _ANSI_EXTENSION /* uses < 1938 MB for minimal sieve size to 2^64 */
# define uns64 unsigned long long