Skip to content

Instantly share code, notes, and snippets.

View buxtonpaul's full-sized avatar

Paul Buxton buxtonpaul

  • Codasip
View GitHub Profile
@buxtonpaul
buxtonpaul / consumer.py
Created June 19, 2017 13:13
Sample python fifo consumer
while True:
a=raw_input()
if not a:
continue
print a[::-1]
if a == "Hello 9":
break
@buxtonpaul
buxtonpaul / producer.c
Created June 19, 2017 13:17
Sample producer for mknod ipc
#include <stdio.h>
#include <unistd.h>
int main(int argc,char*argv)
{
FILE *fp;
int i;
fp=fopen("myfifo.txt","w");
@buxtonpaul
buxtonpaul / run.sh
Created June 19, 2017 13:21
Bash script to compile the producer code, create the fifo and run the producer and consumer together
#! /usr/bin/bash
gcc producer.c -o producer
mknod myfifo.txt p
python consumer.py <myfifo.txt &
./producer
rm myfifo.txt
from sense_hat import SenseHat
sense = SenseHat()
r = (255, 0, 0)
o = (255, 127, 0)
y = (255, 255, 0)
g = (0, 255, 0)
b = (0, 0, 255)
i = (75, 0, 130)
import numpy as np
import matplotlib.pyplot as plt
import scipy.misc
import png
#import pil
import matplotlib.image as mpimg
def write_pgm(image, filename):
@buxtonpaul
buxtonpaul / beegee.sh
Created January 9, 2018 13:56
Stay alive bash script. Runs until it sees a file ~/aah.txt, checking every 5 secs
#!/bin/bash
# loop checking for a file, if the file exists exit
for (( ; ; ))
do
if [ -f ~/aah.txt ]; then
#echo "File Found!"
exit
fi
sleep 5
@buxtonpaul
buxtonpaul / readbinaryfloats.cpp
Created May 1, 2018 11:49
Quick function to read a binary file into a vector
template <class T>
std::vector<T> readFile(const char *filename)
{
std::vector<T> results;
std::ifstream fin(filename, std::ios::binary);
T n;
while (fin.read(reinterpret_cast<char *>(&n), sizeof(T)))
results.push_back(n);
return results;
}
@buxtonpaul
buxtonpaul / for-each.htm
Last active November 27, 2018 14:59 — forked from bennadel/for-each.htm
Mutating An Array During .forEach() Iteration In JavaScript
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>
Mutating An Array During .forEach() Iteration In JavaScript
</title>
</head>
<body>
@buxtonpaul
buxtonpaul / qtbase_i686-w64-mingw32.shared.posix.dw2
Created August 23, 2019 16:58
qtbase_i686-w64-mingw32.shared.posix.dw2
This file has been truncated, but you can view the full file.
make[1]: Entering directory '/home/paul/src/mxe'
uname -a
Linux paul-gpu 4.15.0-58-generic #64~16.04.1-Ubuntu SMP Wed Aug 7 14:10:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
git log --pretty=tformat:"%H - %s [%ar] [%d]" -1
1b81e99cf78df3b0f89173d6f1bc71159cf190ca - Update packages.json & build-matrix.html [2 days ago] [ (HEAD -> master, origin/master, origin/HEAD)]
lsb_release -a 2>/dev/null || sw_vers 2>/dev/null || true
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
@buxtonpaul
buxtonpaul / wsldisplay.py
Created May 14, 2020 15:10
Quick'n'dirty python script to create the display variable for use with WSL2
#!/usr/bin/python3
import os
for line in os.popen('ipconfig.exe'):
if not line[0] in [' ', '\n']:
current_section = line
active = False
if 'Link-local IPv6 Address' in line:
active = True