Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Hermann-SW / flash
Last active July 24, 2023 19:01
"Flash .uf2 file to"/reboot Raspberry Pico with baudrate switching method [+picotool reboot]
#!/bin/bash
sudo stty -F /dev/ttyACM0 1200
echo waiting
while [ ! -d /media/pi/RPI-RP2 ]; do sleep 0.1; done
sleep 0.5
if [ "$*" = "" ]; then echo rebooting; sudo picotool reboot; exit; fi
echo copying
cp $1 /media/pi/RPI-RP2
echo done

How to use GPG/PGP to share passwords

Sometimes we need to transmit passwords over unsecured channels, like Slack or email. There are lots of password managers, but their password sharing functionality is less robust than I like. For example, 1Password lets you share passwords, but to do so you must share your entire keychain - which is not useful.

To solve this, we can use public/private keys to transmit messages over any channel, that can only be decrypted by the end user. This is stuff of the future! It seems like it would be complicated, but common use cases are very easy to set up and use!

Setup

Setting Tags in Terraform

Determine some sensible tags to pass non-critical information to Ansible or other CM solutions:

resource "aws_instance" "main" {
...
  tags {
  ...
    "some_tag" = "waka"
@jasonneylon
jasonneylon / address.rb
Created December 29, 2012 16:27
Uk postcode validation with rails/activerecord
class Address < ActiveRecord::Base
attr_accessible :postcode
validates_format_of :postcode, :with => /^([A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])\s?[0-9][ABD-HJLNP-UW-Z]{2}|(GIR\ 0AA)|(SAN\ TA1)|(BFPO\ (C\/O\ )?[0-9]{1,4})|((ASCN|BBND|[BFS]IQQ|PCRN|STHL|TDCU|TKCA)\ 1ZZ))$$/i, :message => "invalid postcode"
end