Skip to content

Instantly share code, notes, and snippets.

View nakedible-p's full-sized avatar

Nuutti Kotivuori nakedible-p

View GitHub Profile
const c = new WebSocket(
'wss://api.poplatek.com/api/v2/terminal/35516/jsonpos',
['jsonrpc2.0']
);
c.send(
JSON.stringify({
jsonrpc: '2.0',
method: 'Purchase',
params: { amount: 150, currency: 978, receipt_id: 15335 }
})
@nakedible-p
nakedible-p / index.js
Created May 15, 2018 20:11
HTTP to HTTPS redirect
require('http').createServer((req, res) => {
const host = req.headers['x-forwarded-host'] || req.headers.host;
res.setHeader('Location', `https://${host}${req.url}`);
res.statusCode = 301;
res.end();
}).listen(80);
@nakedible-p
nakedible-p / proxy.js
Created October 19, 2015 19:55
AWS ES proxy
var AWS = require('aws-sdk');
var http = require('http');
var httpProxy = require('http-proxy');
var express = require('express');
var bodyParser = require('body-parser');
var stream = require('stream');
if (process.argv.length != 3) {
console.error('usage: aws-es-proxy <my-cluster-endpoint>');
process.exit(1);