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
@xbmcnut
xbmcnut / shelly_pir.yaml
Last active December 5, 2023 21:19
Making an outdoor motion sensor smart using a Shelly 1
/**
* I figured out you can fit a Shelly 1 inside the case of many outdoor motion sensors.
* Coupled with that fact that recently, Shelly added a feature to de-couple the switch from the relay
* so they act independently, makes this a great combo! Simply wire the output of the PIR motion sensor
* (the wire that normally goes to your outdoor light) to the switch input of the Shelly and wire
* the lightbulb to the L output of the Shelly. Then, in the Shelly app or directly via the devices webpage,
* select the button type as 'Detached Switch' and use the code below to make it work normally.
* Don't forget to adjust the daylight sensitivity to full daylight if you want the motion detection to work 24/7.
*/
@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
@zwaldowski
zwaldowski / Extra Logging for My Great App.mobileconfig
Last active January 19, 2024 00:35
Apple Configuration Profile for Logging in iOS 10 and macOS Sierra
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's
supposed to scale from the kernel, up to frameworks, and up to apps. It defaults
to a more regimented, privacy-focused approach that large apps and complex
systems need.
It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the
Console app in macOS Sierra, hope to help you graduate from caveman debugging to

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@zwaldowski
zwaldowski / Activity.swift
Last active February 15, 2024 18:49
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
@fardjad
fardjad / batch-m4a-to-mp3.md
Last active February 28, 2024 16:37
[How to Convert m4a Files to mp3, Preserving Bitrate and ID3 Tags Using ffmpeg] #ffmpeg #bash

How to convert m4a files to mp3, preserving bitrate and id3 tags using ffmpeg

Prerequisites

  1. ffmpeg
  2. cygwin (on windows)

Commands

cd /path/to/m4a/files
mkdir out
for f in *.m4a; do 
@vsouza
vsouza / .bashrc
Last active April 9, 2024 05:27
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@kristopherjohnson
kristopherjohnson / KDJKeychainItemWrapper.h
Created March 21, 2013 12:18
My version of the KeychainItemWrapper class from Apple's GenericKeychain sample, converted to ARC and modernized
// Based upon code from Apple's "GenericKeychain" sample application
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
@romaonthego
romaonthego / NSDateFormatter cheat sheet
Last active May 3, 2024 07:26
Date Formats for NSDateFormatter
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
@nils-werner
nils-werner / .gitconfig
Created February 15, 2012 10:39
Exceprt of my .gitconfig
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold