Skip to content

Instantly share code, notes, and snippets.

# Setup NFS share between Mac (client/host) and Debian/Ubutnu (server/guest)
# Find out IP of host (host-only adapter, sth like vboxnet0 (check settings of guest in Virtualbox). The IP should be sth like 192.168.56.1)
ifconfig
# Get NFS on the guest system
sudo apt-get install nfs-kernel-server nfs-common portmap
# Find out user ID and group ID of your user on the guest system (likely 1000/1000)
id
# Edit /etc/exports
sudo vim /etc/exports
# Insert the user/group IDs and the IP of the host
@michaelsauter
michaelsauter / BasePresenter.php
Last active February 6, 2024 12:56
Simple presenter pattern for Symfony2/Twig. Really useful to get some view logic out of the models and views into its own separate space.
<?php
namespace Acme\DemoBundle\Presenter;
class BasePresenter
{
protected $subject;
public function __construct($subject)
{
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.6.3"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "boot2docker"
config.vm.box = "yungsang/boot2docker"
config.vm.box_check_update = false
@michaelsauter
michaelsauter / gnupg.md
Created November 10, 2014 04:20
gnupg

Encrypt file:

gpg --encrypt --armor --recipient email@example.com file

Decrypt file:

gpg --decrypt file
@michaelsauter
michaelsauter / Makefile
Created January 23, 2017 10:02
Terraform Makefile
check:
@terraform version | grep "Terraform v0\.8\.[0-9]*" >/dev/null; case $$? in \
1) echo You need Terraform version 0.8.x!; exit 1;; \
esac
config: check
@terraform remote config -backend=s3 -backend-config="bucket=xxx-terraform-state" -backend-config="key=yyy/terraform.tfstate" -backend-config="region=eu-central-1"
plan: config
@terraform plan -out terraform.tfplan
@michaelsauter
michaelsauter / gist:297c0a67ba277b9c508f933ef9f70cdf
Last active February 16, 2021 15:21
Find and remove old Git branches
# Update local repo
git fetch origin --prune
# Merged branches at least 2 months old
for branch in `git branch -r --merged | grep -v HEAD`; do echo -e `git show --format="%ci %cr %an" $branch | head -n 1` \\t$branch; done | grep "months" | awk '{print $(NF)}' | sed -e "s/^origin\///" | xargs git push origin --delete --dry-run
# All branches at least a year old
for branch in `git branch -r | grep -v HEAD`; do echo -e `git show --format="%ci %cr %an" $branch | head -n 1` \\t$branch; done | grep "1 year" | awk '{print $(NF)}' | sed -e "s/^origin\///" | xargs git push origin --delete --dry-run

Interview Task

Objective

As a Farmera developer, synchronize temperature data reliably from an external vendor, myfarm.io, with Farmera. What kind of concepts / entities do you need to implement in our service? How will you do the interaction with myfarm.io? If you need more information about the API, please ask.

API Documentation myfarm.io

Example request

curl 'https://api.myfarm.io/devices/123/temperature?start=2019-01-06T00%3A00%3A00Z&amp;end=2019-01-09T00%3A00%3A00Z&amp;groupBy=FIFTEEN_MINUTES' -i -u 'user:secret' -X GET
@michaelsauter
michaelsauter / ODS3.md
Last active January 16, 2020 08:39
ODS 3.0

Work Packages for OpenDevStack 3.0

Release timeline: May 2020. Theme: Quality

Shared Library Testing

Owner(s): ? / Size: M / Benefit: Reliable pipelines, more confidence in changes / Ticket(s): #149, #146

Write automated tests for the shared library. Could be a mixed of tests with mocks and E2E tests. Run e.g. in Travis or Github Actions.

Project Provisioning Testing

import org.ods.service.ServiceRegistry
import org.ods.util.GitUtil
import org.ods.util.Project
def runOnAgentPod(Project project, boolean condition, Closure block) {
if (condition) {
def git = ServiceRegistry.instance.get(GitUtil)
dir(env.WORKSPACE) {
stash(name: 'wholeWorkspace', includes: '**/*,**/.git', useDefaultExcludes: false)
}