Skip to content

Instantly share code, notes, and snippets.

View ast's full-sized avatar
🥸
Let's code!

Albin Stigo ast

🥸
Let's code!
View GitHub Profile
@ast
ast / main.go
Last active December 30, 2020 20:31
Using epoll with go. Packages like fsnotify does not work with sysfs. Then you need epoll, poll or select.
package main
import (
"golang.org/x/sys/unix"
"log"
"os"
)
func main() {
file, err := os.Open("/sys/class/somefile")
@ast
ast / qe.c
Created September 9, 2017 13:28
How to read a quadrature encoder in C on the Raspberry Pi GPIO, using the wiringPi library.
//
// qe.c
// hidtest
//
// Created by Albin Stigö on 09/09/2017.
// Copyright © 2017 Albin Stigo. All rights reserved.
//
// License BSD
// https://opensource.org/licenses/BSD-2-Clause
@ast
ast / gnu.emacs.daemon.plist
Created June 3, 2017 09:23
plist I use for running Emacs as a daemon on OSX.
<?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">
<dict>
<key>Label</key>
<string>gnu.emacs.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/emacs</string>
@ast
ast / writeimage.sh
Created June 3, 2017 08:54
Writing a disk image to an SD card/USB flash drive on OSX.
# List disks so you know which ones which.
$ diskutil list
# Unmount if mounted.
$ diskutil unmountDisk /dev/diskX
# Write iso with dd.
$ sudo dd if=ubuntu-17.04-desktop-amd64.iso of=/dev/diskX bs=1M
# You can press ctrl-t to check progress.
@ast
ast / iwantmyname.sh
Created May 15, 2017 12:55
Shell script that detects changes to your public ip address and updates your iwantmyname.com nameservers.
#!/usr/local/bin/bash
# Q: What is this?
# A: It's a shell script that updates what ip address your iwantmyname.com domain resolves to.
# I use it from cron.
# Q: What do I have to do?
# A: Add your username and password. Change the domain. Add it to your crontab.
set -e
@ast
ast / doubleentry.pegjs
Last active February 3, 2020 03:25
Double entry bookkeeping in pegjs
/*
Use pegjs online evaluator to try
https://pegjs.org/online
Input sample:
albin food 100.00
juliana food 100
@ast
ast / liquid-dsp.rb
Created October 26, 2016 09:11
homebrew formula for building liquid-dsp
# homebrew formula for building liquid-dsp
# cp to /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/liquid-dsp.rb and
# brew install -i --HEAD liquid-dsp
class LiquidDsp < Formula
desc "liquid-dsp, a free and open-source signal processing library for software-defined radios written in C."
homepage "http://liquidsdr.org/"
head "https://github.com/jgaeddert/liquid-dsp.git"
depends_on "fftw"
@ast
ast / listgmail.py
Created November 12, 2015 11:06
I had to produce a (text) list of all the mail I had received, in my gmail, from two addresses. Here's how I did it. Adjust it to your taste.
#!/usr/bin/env python
import imaplib
from email.parser import HeaderParser
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('yourmail@gmail.com', 'yourpassword')
mail.select("[Gmail]/All Mail")
# Execute an IMAP search query
status, data = mail.search(None, '(OR (FROM "example1@gmail.com") (FROM "example2@gmail.com"))')
@ast
ast / Makefile
Last active August 29, 2015 14:13
Makefile for creating iOS app icons as required by xcode 6. Uses ImageMagick.
SHELL = /bin/sh
.SUFFIXES: .png
# Should be square
ICON=Icon-1024.png
all: Icon-29.png Icon-29@2x.png Icon-29@3x.png Icon-40.png Icon-40@2x.png Icon-40@3x.png Icon-60@2x.png Icon-60@3x.png Icon-76.png Icon-76@2x.png
clean:
-rm Icon-29*
-rm Icon-40*