Skip to content

Instantly share code, notes, and snippets.

View vesse's full-sized avatar

Vesa Poikajärvi vesse

View GitHub Profile
@vesse
vesse / uuid.coffee
Last active April 2, 2018 19:38
Mongo binary UUID to Java legacy string and vice versa
{Binary} = require 'mongodb'
# Put together following https://github.com/mongodb/mongo-csharp-driver/blob/master/uuidhelpers.js
module.exports.toJUUID = toJUUID = (binId) ->
return "" unless binId?.buffer?
hex = binId.buffer.toString 'hex'
msb = hex.substr(0, 16)
lsb = hex.substr(16, 16)
msb = msb.substr(14, 2) + msb.substr(12, 2) + msb.substr(10, 2) + msb.substr(8, 2) + msb.substr(6, 2) + msb.substr(4, 2) + msb.substr(2, 2) + msb.substr(0, 2)
lsb = lsb.substr(14, 2) + lsb.substr(12, 2) + lsb.substr(10, 2) + lsb.substr(8, 2) + lsb.substr(6, 2) + lsb.substr(4, 2) + lsb.substr(2, 2) + lsb.substr(0, 2)
@vesse
vesse / geoserver-setup.md
Last active January 24, 2017 18:45
GeoServer test setup

US Counties on GeoServer

Just a test and a note to self.

Data

wget http://www2.census.gov/geo/tiger/GENZ2015/kml/cb_2015_us_county_500k.zip
unzip cb_2015_us_county_500k.zip
var chai = require('chai'),
should = chai.should(),
expect = chai.expect(),
assert = chai.assert,
supertest = require('supertest-as-promised'),
api = supertest('http://localhost:3000');
describe('Pictures', function () {
it('should add a picture', function (done) {
api.post('/api/v1/pictures')
<!DOCTYPE html>
<html>
<head>
<script src='http://localhost:3000/socket.io/socket.io.js'></script>
<script>
var socket = io.connect('http://localhost:3000/nsa');
socket.emit('request', {
msg : 'appA user is requesting something'
});
socket.on('incoming-request', function(data) {
@vesse
vesse / haproxy.con
Created October 24, 2013 10:30
Basic HAProxy setup for nodejs app
global
daemon
maxconn 4096
user haproxy
group haproxy
defaults
log global
frontend http-in
var express = require('express'),
bodyParser = require('body-parser'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy;
var app = express();
passport.use(new LocalStrategy(function (username, password, cb) {
cb(null, false, {message: 'This can never succeed'});
}));