Skip to content

Instantly share code, notes, and snippets.

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

Matthias brutella

🏠
Working from home
View GitHub Profile
@brutella
brutella / go-modules.md
Created December 7, 2018 12:57
Go modules

Go supports modules since v1.11+.

Go modules require that GOPATH is empty => unset GOTPATH

Define a module

Run go mod init {module name} to create a go.mod file for the current directory.

For example go mod init github.com/brutella/dnssd creates the following content.

@brutella
brutella / rpi-enable-camera-module.md
Last active February 9, 2024 09:48
How to enable the camera module on a Raspberry Pi

Enable camera module

Edit your /boot/config.txt file and make sure the following lines look like this:

start_x=1             # essential
gpu_mem=128           # at least, or maybe more if you wish
disable_camera_led=1  # optional, if you don't want the led to glow

Load bcm2835-v4l2 module

@brutella
brutella / icons
Last active August 29, 2023 15:10
Generate iOS, watchOS, and macOS app icons from one image
#! /bin/sh
function print_example() {
echo "Example"
echo " icons ios ~/AppIcon.pdf ~/Icons/"
}
function print_usage() {
echo "Usage"
echo " icons <ios|watch|complication|macos> in-file.pdf (out-dir)"
@brutella
brutella / headless-rpi.md
Last active March 12, 2022 13:00
How to set up a Raspberry Pi

Install Rasbian

Most of the time I use a headless Raspberry Pi which I want to access via ssh. These are the steps to do that.

  1. Download Rasbian
  2. Install the downloaded file on a SD card
  • Find the disk number of the SD card with diskutil list
  • Unmount the disk with diskutil unmountDisk /dev/disk<number>
  • Copy data on the SD card with sudo dd bs=1m if=<img-file> of=/dev/rdisk<number> conv=sync
@brutella
brutella / runit.md
Created August 9, 2018 13:48
Get started with runit
@brutella
brutella / install-go.md
Created April 3, 2019 08:43
Install Go on Raspberry Pi

Install Go

  1. Download the latest stable version from golang.org with wget -c <url> – use armv6 architecture for Rasbperry Pi 3 Model B.
  2. Extract with sudo tar -C /usr/local -xvzf <file>
  3. Setup the Go workspace
@brutella
brutella / git-diff.sh
Last active July 30, 2019 07:50
Git diffs in your favourite diff tool
#!/bin/sh
function print_example() {
echo "Example"
echo " git-diff develop master"
}
function print_usage() {
echo "Usage"
echo " git-diff <branch|tag|commit> <branch|tag|commit>"
@brutella
brutella / cheat-sheet.md
Created February 13, 2019 17:01
TextMate cheat sheet
  • ^s Incremental search

  • ^w Select in scope

  • cmd t Open documents

@brutella
brutella / gist:f3e2e2b3d3658f01403cfe12dbaf66fa
Created November 26, 2018 10:58
Password-less ssh access
  1. Check if there is an existing ssh key available
$ ls ~/.ssh

If id_rsa (private key) and id_rsa.pub (public key) are available, go to step 3.

  1. Generate new keys
@brutella
brutella / gist:3899619
Created October 16, 2012 14:32
NSUserDefaults macros
#define jn_defaults_get_object(key) [[NSUserDefaults standardUserDefaults] objectForKey:key]
#define jn_defaults_set_object(key, object) \
[[NSUserDefaults standardUserDefaults] setObject:object forKey:key]; \
[[NSUserDefaults standardUserDefaults] synchronize]; \
jn_defaults_post_notification(key)
#define jn_defaults_get_float(key) [jn_defaults_get_object(key) floatValue]
#define jn_defaults_set_float(key, float) jn_defaults_set_object(key, [NSNumber numberWithFloat:float])
#define jn_defaults_observe(key, block) \