Skip to content

Instantly share code, notes, and snippets.

Avatar

Kirk Roerig mrpossoms

View GitHub Profile
View gist:e364ce92293b1f16dfc30502374d6721
/*
* GccApplication1.c
*
* Created: 1/23/2020 10:04:20 PM
* Author : Kirk
*/
#include <avr/io.h>
#include <util/delay.h>
#include <math.h>
@mrpossoms
mrpossoms / server.c
Created Sep 17, 2018
detect connection closure
View server.c
#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 Jan 26, 2018
Script for sending email alerts from a unix cli
View pingme.sh
#!/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 Nov 21, 2017
Run this script in the background to remember your last working directory. Useful for ssh sessions when working in deep directory structures.
View rabbit.sh
#!/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 Sep 8, 2017 — forked from TIS-Edgar/framerate.c
set v4l2 framerate
View framerate.c
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;
View Makefile
# 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 Apr 28, 2016
libKF simple 1D filter example
View libkf_filter.c
// build with...
// gcc -I/usr/local/include filter.c -lKF -lindicurses -lncurses
#include <kf.h>
#include <indicurses.h>
int main()
{
kf_t filter = {};
View Debuggerator
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,
@mrpossoms
mrpossoms / ssss.c
Created Oct 3, 2015
Super Stupid Simple Sort
View ssss.c
void sort(int* arr, int len)
{
for(int i = 0; i < len; ++i){
for(int j = len - 1; j > i; j--){
if(arr[i] > arr[j]){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
You can’t perform that action at this time.