Skip to content

Instantly share code, notes, and snippets.

View mplewis's full-sized avatar
🐕
柴犬

Matt Lewis mplewis

🐕
柴犬
View GitHub Profile
@mplewis
mplewis / safe_schedule.py
Last active April 23, 2024 01:12
An implementation of Scheduler that catches jobs that fail. For use with https://github.com/dbader/schedule
import logging
from traceback import format_exc
import datetime
from schedule import Scheduler
logger = logging.getLogger('schedule')
@mplewis
mplewis / threePipeDemo.c
Created March 31, 2013 01:31
Here's an example of how to pipe three commands together using C. This one uses `ps aux | grep root | grep sbin`. This topic is horribly documented online so hopefully this'll help someone else out.
// This program is an example of how to run a command such as
// ps aux | grep root | grep sbin
// using C and Unix.
#include <stdlib.h>
#include <unistd.h>
int pid;
int pipe1[2];
int pipe2[2];

How Do I Into Git?

a helpful primer for users sick of git's poorly-named commands

I've used Git since 2011, and this is the stuff that I've always had to Google to remember. I hope it helps you not hate Git so much.

Learning About the Repo

Learning About History

Dope Shell Stuff

These are my favorite tools for making my terminal a nice place to work.

  • bat: cat, but with pretty syntax highlighting, git, and diff support
  • chezmoi: Sync your dotfiles using a Git repo
  • diff-so-fancy: better-looking diffs for modern terminals
  • exa: ls, but pretty by default
  • Fantasque Sans Mono: A lovely monospace font with ligatures and a friendly shape
  • fasd: navigate between project directories really quickly

HomeKit Service and Characteristic UUIDs

Thanks to HAP-NodeJS

Service UUID
Accessory Information 0000003E-0000-1000-8000-0026BB765291
Air Quality Sensor 0000008D-0000-1000-8000-0026BB765291
Battery Service 00000096-0000-1000-8000-0026BB765291
Bridging State 00000062-0000-1000-8000-0026BB765291
@mplewis
mplewis / android_ble_char_props_cheat_sheet.md
Last active May 15, 2023 17:45
A cheat sheet for the bits in the bitmask of Android characteristic properties.

Characteristic Property Cheat Sheet

for Android Bluetooth Low Energy

Tired of remembering which properties go with which bits in the properties bitmask of a BluetoothGattCharacteristic? Me too. Here's an easy-to-read table. Source.

BluetoothGattCharacteristic

Properties

Bit Value | Meaning

@mplewis
mplewis / flask-uwsgi-nginx-primer.md
Last active October 24, 2022 19:20
Flask + uWSGI + nginx Primer. I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

Flask + uWSGI + nginx Primer

I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

How this shit works

  • Flask is managed by uWSGI.
  • uWSGI talks to nginx.
@mplewis
mplewis / chat.go
Created September 23, 2022 21:14
Demo "chat" app which shows how to use Go and carraige returns to show live messages alongside an editable chat input line
package main
import (
"fmt"
"math/rand"
"time"
"github.com/eiannone/keyboard"
)
@mplewis
mplewis / shenv.sh
Created September 18, 2022 21:16
Put this in your path as `shenv` to source .env file variables and run specific commands: `shenv development.env my-command`
#!/bin/bash
set -euo pipefail
set -a; source "$1"; set +a
"${@:2}"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.