Skip to content

Instantly share code, notes, and snippets.

View hugows's full-sized avatar
🏠
Working from home

Hugo Schmitt hugows

🏠
Working from home
View GitHub Profile
#!/bin/bash
# Script should be run daily to move Downloads/ files to an archived folder.
HOME="/home/hugo"
YESTERDAY=$(date -d "yesterday 13:00" '+%Y-%m-%d')
mkdir -p $HOME/ArchivedDownloads/$YESTERDAY
mv $HOME/Downloads/* $HOME/ArchivedDownloads/$YESTERDAY
package main
import (
"fmt"
"net/http"
"time"
)
type server struct {
conns int
@hugows
hugows / timelapse-from-pi.sh
Created September 26, 2019 16:17
Copy stills from Raspberry Pi and turn into timelapse movie
#!/bin/bash
mkdir -p input/
rsync --remove-source-files -a pi@rpi:~/camera/ input/
ffmpeg -r 25 -pattern_type glob -i 'input/*.jpg' -c:v copy timelapse.avi
@hugows
hugows / validate.go
Created March 19, 2019 10:02
gojsonschema and echo
var mySchema = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"color": {
"description": "The price of the product",
"type": "string",
"enum": ["blue", "red", "black"],
"exclusiveMinimum": 0
}
@hugows
hugows / update_go.sh
Last active March 15, 2019 11:22
script to update go to new version on linux ubuntun
#!/usr/bin/env bash
# Original author: Ravi Teja Pothana (@RaviTezu)
# Hugo: removed stuff I didn't need on Linux
set -e
GO_VERSION="invalid"
GO_ROOT=/usr/local/go
function usage {
printf "./update_go.sh <version> \n"

Mount your remote server to easily edit files with VSCODE

sudo mkdir /mnt/droplet
sudo sshfs -o allow_other root@xxx.xxx.xxx.xxx:/ /mnt/droplet

To unmount:

Helpful linux tips

Handy aliases I always type again:

alias sai='sudo apt install -y'
alias sas='sudo apt-cache search'
alias gc="git clone"
alias sshhugo="sshpass -p 'mypass' ssh myserver.com"
alias psqlacme="PGPASSWORD=acmepass psql -h localhost -U acme acmedb"

Quick setup Postgres 10 on Ubuntu 18.10

Paste this into your terminal, replacing acme with your project name:

PGUSER=acme
PGPASS=acmepass
PGDB=acmedb

sudo apt-get install postgres

On the emergence of interfaces

Interfaces naturally emerge as software gets broken down into parts communicating with one another. The larger and more deliberate structures emerge from a deliberate attempt to organize the development process itself. [fn:Liskov2008] Structure often emerge directly from division of labor: as teams take on independent tasks, interfaces are established betweeen domains they become responsible for. (Conway’s Law)

Software developers are responsible for systems built out of very small atoms while ultimately performing tasks for their users of a much greater magnitude. Dijkstra showed this by computing the ratio between grains of time at the lowest and largest atoms of the system (from say, CPU instructions to a human interaction with the system) The span was already quite large by Dijkstra’s time, of about 10^9. Today this ratio would be at least above 10^12 (see grain ratios)

This large span has to be manage

export function items(state = [], action) {
switch (action.type) {
case 'ITEMS_FETCH_DATA_SUCCESS':
return action.items;
default:
return state;
}
}