Skip to content

Instantly share code, notes, and snippets.

View mattshirtliffe's full-sized avatar
🐇
Software Engineer & Co-founder of Studio 200

Matthew Shirtliffe mattshirtliffe

🐇
Software Engineer & Co-founder of Studio 200
View GitHub Profile
@mattshirtliffe
mattshirtliffe / day-1-part-2.ts
Created December 10, 2023 19:28
day 1 part 2
import { readFile } from 'fs/promises';
async function getData(): Promise<string[]> {
try {
const v = await readFile('input.txt', 'utf8');
return v.split('\n');
} catch (error) {
console.error(error);
return [];
}
@mattshirtliffe
mattshirtliffe / app.ts
Created December 10, 2023 15:15
dayonepartone
import { readFile } from 'fs/promises';
async function getData(): Promise<string[]> {
try {
const v = await readFile('input.txt', 'utf8');
return v.split('\n');
} catch (error) {
console.error(error);
return [];
}
age = 31
print(age)
next_age = age + 1
print(next_age)
soup = 9.00
squid = 6.80
@mattshirtliffe
mattshirtliffe / 10-automount.rules
Created February 17, 2020 16:01 — forked from ramnes/10-automount.rules
Automatically mount USB storages when plugged
KERNEL!="sd[b-z][0-9]", GOTO="automount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
@mattshirtliffe
mattshirtliffe / test_spi_client.py
Created September 1, 2019 18:43
getting spi data from zmq
import sys
import zmq
# Socket to talk to server
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://localhost:5556")
@mattshirtliffe
mattshirtliffe / test_spi_server.py
Created September 1, 2019 18:41
reading spi data and sending over zmq
from periphery import SPI
import time
import random
import json
import zmq
from random import randrange
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:5556")
@mattshirtliffe
mattshirtliffe / spi_random.py
Created September 1, 2019 17:41
spi random
from periphery import SPI
import time
import random
# Open spidev1.0 with mode 0 and max speed 1MHz
spi = SPI("/dev/spidev0.0", 0, 1000000)
data_out = [0x00, 0x00, 0xcc, 0xdd]
@mattshirtliffe
mattshirtliffe / Thing.js
Created May 25, 2019 18:04
React hook for state manipulation
import React, {useState} from 'react';
const Thing = props => {
const [thingState, setThingState] = useState({number: 0})
const buttonHandler = () =>{
setThingState({
number: thingState.number + 1
});
@mattshirtliffe
mattshirtliffe / merge.py
Created May 22, 2018 10:35
Merging pdfs
import os
import re
from PyPDF2 import PdfFileMerger
def sorted_nicely( l ):
""" Sorts the given iterable in the way that is expected.
Required arguments:
l -- The iterable to be sorted.
@mattshirtliffe
mattshirtliffe / environment_sensor.ino
Last active April 15, 2018 20:35
Arduino Environment Sensor
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include "DHT.h"
#define DHTPIN 2 // what digital pin we're connected to
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)