Skip to content

Instantly share code, notes, and snippets.

View aerobless's full-sized avatar

Theo Winter aerobless

View GitHub Profile
@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 / 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 / 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 / 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-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-config-snippet.js
Created June 28, 2018 12:28
Example of how to have a config for Google Cloud Functions.
const config = {
sample: {
database: {
connection: 'projectId:location:dbInstance',
name: 'dbName',
user: 'dbUser',
password: 'dbPassword'
}
}
};
@aerobless
aerobless / gfc-local-testing-snippet.sh
Last active June 29, 2018 08:52
Commands for local testing of gfc
# 1. Install gfc emulator
npm install -g @google-cloud/functions-emulator
# 2. Set correct project
functions config set projectId YOUR_PROJECT_ID
# 3. Get correct version of Node.js (works for *nix systems)
npm install -g n
n 6.11.5
@aerobless
aerobless / raspberry_headless_201807.md
Last active April 6, 2019 18:20
Raspberry PI headless 2018-07

1. Put wpa_supplicant.conf on boot drive:

country=CH
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
 
network={
	ssid="yourSSID"
	psk="yourWifiPassword"
@aerobless
aerobless / scp.md
Created July 25, 2018 08:30
Using SCP to transfer files between servers
@aerobless
aerobless / versioning.gradle
Created October 29, 2018 09:55
A way to easily increment major, minor or hotfix via gradle
def props = new Properties()
file("gradle.properties").withInputStream { props.load(it) }
int major
int minor
int hotfix
task readVersion() {
doFirst {
String version = props.getProperty("version")