Skip to content

Instantly share code, notes, and snippets.

@aallan
aallan / async_webserver.py
Created July 4, 2022 15:38
An asynchronous webserver written in MicroPython to turn an LED on/off on a Raspberry Pi Pico W
import network
import socket
import time
from machine import Pin
import uasyncio as asyncio
led = Pin(15, Pin.OUT)
onboard = Pin("LED", Pin.OUT, value=0)
@szepeviktor
szepeviktor / signal-without-smartphone.md
Last active May 31, 2024 07:26
Install Signal without a smartphone

You probably want the activerecord-postgres_enum gem, because it adds some good stuff for your migrations and allows you to keep using the schema.rb (instead of switching to a schema.sql:

gem 'activerecord-postgres_enum'

Your migration would then look like this:

class AddCountryToCities < ActiveRecord::Migration[5.2]
@ttor
ttor / create_aws_lambda_layer_matplotlib.txt
Last active March 25, 2022 17:47
Create AWS Lambda Layer for Matplotlib (Python3.7)
sudo docker pull amazonlinux
sudo docker run -it amazonlinux:latest /bin/bash
# inside container
yum -y install python37 zip
python3 -m venv python
source python/bin/activate
pip3 install matplotlib
deactivate
rm -rf python/{bin,include,lib64,pyvenv.cfg} python/lib/python3.7/site-packages/{__pycache__,easy_install.py,numpy*,pip*,pkg_resources,setuptools*}
@npearce
npearce / install-docker.md
Last active July 22, 2024 18:07
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@bmweiner
bmweiner / sonos_airplay.md
Last active December 30, 2023 19:30
Stream audio to any Sonos component via AirPlay using a Raspberry Pi.

Sonos Airplay

Stream audio to any Sonos component via AirPlay using a Raspberry Pi (Model B, Raspbian Jessie) and the following software:

  • Shairport Sync: configures the Raspberry Pi as an AirPlay audio player.
  • DarkIce: encodes audio received from AirPlay (system audio) and sends it to Icecast2.
  • Icecast2: serves streaming audio from DarkIce at a network URL.
import sys
import subprocess
import tempfile
import urllib
text = sys.stdin.read()
chart_url_template = ('http://chart.apis.google.com/chart?'
'cht=qr&chs=300x300&chl={data}&chld=H|0')
chart_url = chart_url_template.format(data=urllib.quote(text))