Skip to content

Instantly share code, notes, and snippets.

View mrpossoms's full-sized avatar

mrpossoms

  • Loveland CO
View GitHub Profile
@mrpossoms
mrpossoms / broadcast.c
Created December 26, 2022 16:48
Linux UDP Broadcast minimal example
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
int enable = 1;
/*
* GccApplication1.c
*
* Created: 1/23/2020 10:04:20 PM
* Author : Kirk
*/
#include <avr/io.h>
#include <util/delay.h>
#include <math.h>
#define RESULT_TO_STRING( r )
@mrpossoms
mrpossoms / server.c
Created September 17, 2018 13:54
detect connection closure
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
#define ME "[server] "
void add(int* list, int* size, int val)
@mrpossoms
mrpossoms / pingme.sh
Created January 26, 2018 17:47
Script for sending email alerts from a unix cli
#!/bin/bash
msg_file=/tmp/$(hexdump -n 16 -e '4/4 "%08X" 1 "\n"' /dev/random).mail
echo "subject:ping" > $msg_file
echo $1 >> $msg_file
sendmail $1 YOUR-EMAIL@DOMAIN.com < $msg_file
rm $msg_file
@mrpossoms
mrpossoms / rabbit.sh
Created November 21, 2017 14:54
Run this script in the background to remember your last working directory. Useful for ssh sessions when working in deep directory structures.
#!/bin/zsh
shell_pid=$PPID
last_link=$(readlink -f /proc/$shell_pid/cwd)
while true; do
link=$(readlink -f /proc/$shell_pid/cwd)
if [ $link==$last_link ]; then
readlink -f /proc/$PPID/cwd/ > ~/.hole
last_link=$link
fi
@mrpossoms
mrpossoms / framerate.c
Last active September 8, 2017 19:31 — forked from TIS-Edgar/framerate.c
set v4l2 framerate
bool set_framerate(int fd)
struct v4l2_streamparm parm;
parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
// 1/15 seconds per frame. Or 15 frames/second
parm.parm.capture.timeperframe.numerator = 1;
parm.parm.capture.timeperframe.denominator = 15;
# Name: makefileEDIT
#
# A simple program for the ATtiny84 that blinks an LED.
#
# electronut.in
DEVICE = attiny84
CLOCK = 8000000
PROGRAMMER = -c avrisp2
OBJECTS = main.o
@mrpossoms
mrpossoms / libkf_filter.c
Created April 28, 2016 21:54
libKF simple 1D filter example
// build with...
// gcc -I/usr/local/include filter.c -lKF -lindicurses -lncurses
#include <kf.h>
#include <indicurses.h>
int main()
{
kf_t filter = {};
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,
snap->data,
snap->current.width * snap->current.height * 4,
NULL);
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
CGImageRef imageRef = CGImageCreate(snap->current.width,