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
@hugows
hugows / .screenrc
Last active March 7, 2018 16:26 — forked from jbeluch/.screenrc
Basic .screenrc (Good enough for 2018 - hugo)
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{..G}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a"
export function items(state = [], action) {
switch (action.type) {
case 'ITEMS_FETCH_DATA_SUCCESS':
return action.items;
default:
return state;
}
}

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

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"

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:

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
@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"
@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
}
Originally: https://gist.github.com/vurtun/8da6c0ec7820ec002044579f84547a2e
LIBRARY WRITING REFERENCE LIST
===============================
1.) Designing and Evaluating Reusable Components (Casey Muratori: http://mollyrocket.com/casey/stream_0028.html)
----------------------------------------------------------------------------------------------------------------
_THE_ reference on API design up to this day on the internet. Nobody should write a library without having seen this.
I come back to this talk every N number of weeks it is that good.
2.) stb_howto (Sean Barrett: https://github.com/nothings/stb/blob/master/docs/stb_howto.txt)
@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