Skip to content

Instantly share code, notes, and snippets.

View simon-p-r's full-sized avatar
🏠
Working from home

Simon R simon-p-r

🏠
Working from home
  • Hertfordshire, UK
View GitHub Profile
@simon-p-r
simon-p-r / genRandom.c
Last active January 29, 2018 14:36
Windows generate random bytes to uint64_t
// generate random unsigned 64bit integer
#ifdef _WIN32
#define __alignof__ __alignof
#define snprintf(buf, bufSize, format, arg) _snprintf_s(buf, bufSize, _TRUNCATE, format, arg)
#define strtoll _strtoi64
#define strtoull _strtoui64
#define PRId64 "lld"
#define PRIu64 "llu"
@simon-p-r
simon-p-r / joi-throw.js
Created May 17, 2017 14:54
No stack trace throw when running this code on Windows Server 2008 R2
'use strict';
const Joi = require('joi');
const schema = Joi.string();
const attempt = Joi.attempt({}, schema);
D:\Modules\node-taglib2>cmake-js build
(node:15560) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
info TOOL Using Visual Studio 14 2015 Win64 generator.
info CMD CONFIGURE
info RUN cmake "D:\Modules\node-taglib2" --no-warn-unused-cli -G"Visual Studio 14 2015 Win64" -DCMAKE_JS_VERSION="3.2.1" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_JS_INC="C:\Users\Simon\.cmake-js\node-x64\v6.3.1\include\node;D:\Modules\node-taglib2\node_modules\nan" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="6.3.1" -DNODE_ARCH="x64" -DCMAKE_JS_LIB="C:\Users\Simon\.cmake-js\node-x64\v6.3.1\win-x64\node.lib"
Not searching for unused variables given on the command line.
-- The C compiler identification is MSVC 19.0.24210.0
-- The CXX compiler identification is MSVC 19.0.24210.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Vi
@simon-p-r
simon-p-r / bugreport.db
Created April 12, 2016 11:57
Nedb generating duplicate records
{"name":"cui","encodedLicence":"someString","_id":"MQOifltLiOJh68oJ"}
{"name":"cui","encodedLicence":"someString","_id":"MQOifltLiOJh68oJ"}
@simon-p-r
simon-p-r / validate.js
Created September 29, 2015 13:48
Joi issue
internals.Schema = Joi.object({
metaSchema: Joi.object().keys({
description: Joi.string(),
type: Joi.string().required().valid('collection', 'definition', 'record'),
base: Joi.alternatives().when('type', {
is: ['record'],
then: Joi.string().required()
}),
jsonSchema: Joi.string(),
name: Joi.string().required(),
@simon-p-r
simon-p-r / mongodb-install.sh
Last active September 3, 2015 22:54 — forked from chappy84/mongodb-install.sh
Install MongoDB from source on Fedora/RedHat based Linux with SystemD
#!/bin/sh
# MongoDB Version
MONGODB_VER='3.0.6'
# Get all the dependencies up to date
yum -y update
yum -y install scons gcc-c++ glibc-devel
# Get the source
@simon-p-r
simon-p-r / output.txt
Created June 1, 2015 13:14
Lab problem
5 tests complete
Test duration: 27 ms
Assertions count: 9 (verbosity: 1.80)
No global variable leaks detected
Coverage: 100.00%
Linting results: No issues
@simon-p-r
simon-p-r / test.js
Created April 21, 2015 21:19
Test problem
it('should validate data against schema async', function (done) {
var plus = new Plus({
directory: [Path.resolve(__dirname, './schemata')]
});
var data = new Plus({
directory: [Path.resolve(__dirname, './fixtures/lookup')]
});
@simon-p-r
simon-p-r / joi
Last active August 29, 2015 14:17
Joi example
keys: Joi.alternatives().when('type', {
is: ['collection', 'record'],
then: Joi.array().items(Joi.object({
name: Joi.string(),
flds: Joi.object(),
options: Joi.object()
}))
})
#!/bin/sh
wget https://webshare.uchicago.edu/orgs/ITServices/itsec/Downloads/GHOST.c
gcc GHOST.c -o GHOST
./GHOST