Skip to content

Instantly share code, notes, and snippets.

View aerobless's full-sized avatar

Theo Winter aerobless

View GitHub Profile
@aerobless
aerobless / gcf-routing-snippet.js
Last active June 28, 2018 12:27
Example of how to do routing in a Google Cloud Function
const router = require('gcf-api-router')();
router.route('/result')
.get(getAllResults) //GET api/result
.post(storeResult); //POST api/result
router.route('/result/:id')
.get(getSpecificResult); //GET api/result/[id]
function getAllResults(req, res) {
@aerobless
aerobless / gcf-mysql-snippet.js
Created June 28, 2018 12:09
Example of how to use MySQL in a Google Cloud Function
const mysql = require('mysql');
const config = require('./config')['production'];
const pool = mysql.createPool({
connectionLimit: 1,
socketPath: '/cloudsql/' + config.database.connection,
user: config.database.user,
password: config.database.password,
database: config.database.name
});
@aerobless
aerobless / gcf.sh
Last active June 28, 2018 07:47
Deploy a Google Cloud Function
#!/bin/bash
set -e
# Any real application probably has a more elaborate deployment process. Here I
# simply hardcoded my example function name; the first thing to change would be
# to load this from a configuration file or similar source instead.
PROJ=jso-camp
REGION=europe-west1
@aerobless
aerobless / LogEntry.java
Created March 14, 2018 13:52
Fluent Key Value Log Fromatter
public class LogEntry {
private LogKey key;
private String value;
public LogEntry(LogKey key, String value) {
this.key = key;
this.value = value;
}
@aerobless
aerobless / ghost-gist-fix.html
Created February 26, 2018 15:11
Can be injected into a ghost blog to fix the width of a embedded gist.
<style>
.gist {max-width:100%; overflow:auto}
</style>
@aerobless
aerobless / credentials.gradle
Last active February 23, 2018 14:11
Gradle script to access credentials stored in gnome-keyring
String getJFrogPasswordFromSystemKeyring() {
def stdout = new ByteArrayOutputStream()
def stderr = new ByteArrayOutputStream()
exec {
commandLine 'secret-tool', 'lookup', 'server', 'git.company.ch'
standardOutput = stdout
errorOutput = stderr
ignoreExitValue = true
}
@aerobless
aerobless / Jenkinsfile_Angular_SpringBoot.groovy
Created January 29, 2018 12:08
A Jenkinsfile describing the build process of a Angular4 & Spring Boot application
pipeline {
agent {
label 'BUILD' //Executed on agents with this label
}
triggers {
pollSCM('* * * * *') //Polls every minute. If your git repo supports web-hooks this is not necessary.
}
@aerobless
aerobless / Jenkinsfile.groovy
Last active July 25, 2025 04:36
An example Jenkinsfile for a build pipeline using gradle, junit, selenium, checkstyle
pipeline {
agent {
label 'agentId' //The id of the slave/agent where the build should be executed, if it doesn't matter use "agent any" instead.
}
triggers {
cron('H */8 * * *') //regular builds
pollSCM('* * * * *') //polling for changes, here once a minute
}
@aerobless
aerobless / SmartHome.md
Last active March 29, 2017 08:47
How I've setup my smart home with Google Home at it's center and various IFTTT enabled devices.

Google Home

These commands can be issued via Google Home. It is implied that Google Home is triggered with "Okay Google" before a command e.g. "What's the news on BBC" is issued.

  • Entertainment:

    • News:

      • What's the news on BBC
        Plays BBC Broadcast (Setup News Source in Google Home Config)
      • What's the news on CNN
        Play CNN Broadcast (Setup News Source in Google Home Config)
@aerobless
aerobless / pi_ultrahook.md
Last active March 27, 2017 17:38
Make Pi launch ultrahook right away

Make a Raspberry Pi (Raspbian) launch Ultrahook on boot

  1. sudo apt-get install screen
  2. The command we need to start a named screen with ultrahook and then detach it is: screen -S ultrahook -d -m ultrahook googlehome 8080 .
  3. Open /etc/rc.local in vim and add the command from above.
  4. Reboot to make sure it works: sudo reboot, when it's up again screen -X ultrahook