Skip to content

Instantly share code, notes, and snippets.

View ataube's full-sized avatar

Andreas Taube ataube

  • collect.ai
  • Hamburg
View GitHub Profile
function makeFunc() {
var name = 'collectAI';
function displayName() {
alert(name);
}
return displayName;
}
var myFunc = makeFunc();
myFunc();
@ataube
ataube / hacks.md
Last active April 19, 2020 21:58
IoT Hacking (ESP32)

Mongoose OS

GPIO2 LED Blinking (blue one)

GPIO.set_mode(2, GPIO.MODE_OUTPUT);
GPIO.blink(2, 1000, 1000)

Keybase proof

I hereby claim:

  • I am ataube on github.
  • I am andreastaube (https://keybase.io/andreastaube) on keybase.
  • I have a public key ASA_NKvCq7f-n8IwflxKjelaG-iHFrHwVvTJO_pRcKRi0Qo

To claim this, I am signing this object:

@ataube
ataube / Readme.md
Last active June 3, 2017 10:43
Docker setup to access from a container a postgres instance installed on the host system

The following steps explain a workaround to connect from a container to a postgres server installed on the host system. This pattern can be applied to other (host) services as well.

Setup

  1. Install postgres
  1. Attach a unused IP to the local lo0 interface sudo ifconfig lo0 alias 10.200.10.1/24
@ataube
ataube / lambda.js
Created May 12, 2017 20:01
Lambda exec example
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda({ region: 'eu-central-1', endpoint: 'http://localhost:3050' });
const params = {
FunctionName: 'hello-world',
InvocationType: 'RequestResponse',
Payload: JSON.stringify({
queryStringParameters: {},
headers: {},
@ataube
ataube / mapstream.js
Created March 3, 2017 18:41
Example proofing the sequential processing of es map
const es = require('event-stream');
const R = require('ramda');
function getRandomInt(min, max) {
var min = Math.ceil(min);
var max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
const readable = es.readArray(R.map(R.toString, R.range(1, 5000)));
@ataube
ataube / authenticate_token.js
Last active May 8, 2017 15:53
Keycloak Learnings
// authenticate
function authenticate() {
const url = [
'http://localhost:8080/',
'auth/realms/collectai/protocol/openid-connect/auth',
'?response_type=code&client_id=portals-api&redirect_uri=http://localhost:3000/merchant',
];
document.location.assign(url.join(''));
}
@ataube
ataube / compose.js
Created February 4, 2017 12:19
ES6 based function composition
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
@ataube
ataube / stream-transform.js
Created January 5, 2017 16:03
Transforms a Json file and write the output back
const fs = require('fs');
const es = require('event-stream');
const JSONStream = require('JSONStream');
const inStream = fs.createReadStream('tests/fixtures/claims10k.json');
const outStream = fs.createWriteStream('tests/fixtures/claims10kPatched.json');
const map = es.mapSync((d) => {
const email = `${d.debtorName.toLowerCase()}.${d.debtorLastName.toLowerCase()}@email.com`;
return Object.assign({}, d, { email });
@ataube
ataube / migrate.js
Created December 22, 2016 09:35
NodeJs db migration wrapper based on Go mattes/migrate
const exec = require('child_process').execFile;
const path = require('path');
const config = require('config');
const url = config.get('datasource');
const command = process.argv[2] || 'up';
const basePath = path.join(process.cwd(), 'migrations')
const args = [`-url=${url}`, '-path=./sql', command];
/*