Skip to content

Instantly share code, notes, and snippets.

View ataube's full-sized avatar

Andreas Taube ataube

  • collect.ai
  • Hamburg
View GitHub Profile
@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 / 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 / transaction.js
Created August 14, 2016 20:25
Loopback async/await transaction example
const Transaction = require('loopback-datasource-juggler');
const update = async (ids, delta) => {
const result = [];
const tx = await models.MyModel.beginTransaction({ isolationLevel: Transaction.READ_COMMITTED });
try {
for (const id of ids) {
const entity = await updateById(id, delta, { transaction: tx });
result.push(entity);
}
@ataube
ataube / gist:1841a4e83991643be04e
Last active February 4, 2016 10:07
Helpful Hadoop and stuff commands
yarn logs -applicationId ...
spark-submit --master yarn-cluster --driver-class-path /usr/share/java/mysql-connector-java.jar --jars /usr/share/java/mysql-connector-java.jar,/usr/hdp/2.3.4.0-3485/spark/lib/datanucleus-core-3.2.10.jar,/usr/hdp/2.3.4.0-3485/spark/lib/datanucleus-rdbms-3.2.9.jar,/usr/hdp/2.3.4.0-3485/spark/lib/datanucleus-api-jdo-3.2.6.jar --files /etc/spark/2.3.4.0-3485/0/hive-site.xml myapp.py
@ataube
ataube / gist:bedee4779bad072a3fa9
Last active August 29, 2015 14:16
Spring Date Rest - Custom Deserialization with entity associations problem
@Entity
public class EntityA {
private String name;
}
@Entity
public class EntityB {
@OneToOne
private EntityA entityA;