Skip to content

Instantly share code, notes, and snippets.

@baflo
baflo / findCharRegExp.js
Created June 22, 2018 07:46
RegExp to find characters not in symmetric (quotes) or asymmetric (brackes) groups
// Create regExp to find commas that are not within double quote, single quote, parantheses, brackets or braces:
const argsSplitRegExp = findCharRegExp(",", { notInSymm: ["\"", "'"], notInAsymm: ["[]", "()", "{}"]});
// Usage (split at found commas):
"age , [32 , 44] , abc".split(argsSplitRegExp);
// RegExp builder
function findCharRegExp(splittingChar, options) {
const notInSymmRE = (char) => `(?=(?:[^\\${char}]*\\${char}[^\\${char}]*\\${char})*[^\\${char}]*$)`;
const notInAsymmRE = (chars) => `(?![^\\${chars[0]}]*\\${chars[1]})`;
@baflo
baflo / cloud-config.yml
Last active April 27, 2018 11:13
Basic RancherOS config
#cloud-config
hostname: rancheros
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAALAuFA2ZAe1+Zmkr0Ge+idxEw== baflo@anpingen.de
rancher:
services:
rancher-agent1:
image: rancher/agent:latest
ports:
- "8080:8080"
@baflo
baflo / .USAGE.md
Last active May 15, 2018 12:50
VIM default .vimrc
[{"id":"dc3c225.be403e","type":"function","z":"302fd027.c80be","name":"Value","func":"const intent = msg.payload;\n\nfunction captured(re) {\n const match = re.exec(msg.payload);\n return match && match[1];\n}\n\nfunction findInIntent(termsMap) {\n for (let key in termsMap) {\n let t, re, cap;\n let terms = termsMap[key].slice();\n\n do {\n t = terms.shift();\n re = new RegExp(t, 'i');\n cap = captured(re);\n } while (t && !re.test(intent));\n \n if (t) return (cap || key);\n }\n}\n\nmsg.payload = findInIntent({\n TV: ['TV', 'Fernsehen'],\n Game: ['Wii', 'Game'],\n Tuner: ['Radio'],\n Net: ['Internet', 'Internetradio'],\n Aux1: ['Amazon', 'Fire', 'Aux', 'VAux'],\n Cable: ['Chromecast', 'Netflix', 'Google', 'Music'],\n});\n \nreturn msg;","outputs":1,"noerr":0,"x":754.0000457763672,"y":116.00000476837158,"wires":[["2ae25842.f371c8"]]}]

Use OpenCV 3.3 with Python

Just do this tutorial.

Hints

  • NumPy is also available as x64 now. You don't need to build it yourself
  • CMake does not find your installed Visual Studio automagically. Really, select the one you have
  • If you finished BUILD and INSTALL, but in Python you get ImportError: DLL not found, add OpenCV\build\install\x64\vc14\bin or appropriate.
  • I made it work with Python 2.7.14 and Python 2.5.2. On Windows 10.
@baflo
baflo / 1 Introduction.md
Last active October 8, 2017 10:29
From Zero to multilingual Actions on Google

From Zero to multilingual Actions on Google

Actions on Google is Google's platform to provide apps for the Google Assistant and Google Home. Technically speaking, the Actions on Google platform is just a broker connecting services with the Google Assistant system, i.e. invocations by users arrive at Actions on Google, which uses information from the Action Package (or API.AI project, ref) to route the invocation request to the correct service.

There are a couple of ways to create services for Actions on Google. One can use Templates available on the Actions on Google platform, or define a request/response pattern on API.AI, or completely build and self-host the applications using the Actions SDK.

They all have in common that they use the [Actions on Google console](https://console.actions.google.com

Server accounts for Google API

Servers can use any (most?) authentication ways that can also be used by clients. However, those usually involve authentication web pages,redirects, etc. Quite unpractical for your server app. So we may use Service Accounts as well and authenticate with a single JWT (JSON Web Token) file.

Hence, we need to create a Service Account in the cloud console. This service account has its own realm, i.e. access to other users' data is not immediately possible.