Skip to content

Instantly share code, notes, and snippets.

@ericherman
ericherman / float-transmission.c
Created December 21, 2020 09:54
simple float persistance to byte device
/* float-transmission.c: simple float persistance to byte device */
/* Copyright 2020 (C) Eric Herman */
/* License: WTFPL – Do What the Fuck You Want to Public License */
/* http://www.wtfpl.net */
/*
$ gcc -Wall -Wextra -o ./float-transmission ./float-transmission.c
$ ./float-transmission
sizeof(float) == 4
original == 0.666667
#!/usr/bin/env bash
DEV_VIDEO=v4l2:///dev/video2
# aplay -l
DEV_AUDIO=alsa://hw:3,0
err() {
echo >&2 "ERROR: $*"
exit 1
}
@ericherman
ericherman / gist:429dc81d7691c5d9fc3b613f8674f416
Created March 31, 2020 11:22
Calendar fixed to avoid april fools posts
eric@titan:~/src/cal$ cal
March 2020
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32
eric@titan:~/src/cal$ cal 2020
@ericherman
ericherman / to-archive-org.sh
Last active September 18, 2019 12:15
proof of concept of deployment archival of our links
#!/bin/bash
# TODO FIXXXME: use something better than bash
rm -f urls.txt
# find . -type f -name '*.md' -print0 |
# while IFS= read -r -d '' FILE; do
BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
@ericherman
ericherman / try1.out
Created September 18, 2019 08:01
archive.org submission from commandline?
$ curl http://web.archive.org/save/https://about.publiccode.net/
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="/static/js/analytics.js"></script>
<script type="text/javascript">archive_analytics.values.server_name="wwwb-app52.us.archive.org";archive_analytics.values.server_ms=0;</script>
@ericherman
ericherman / container-issue.cpp
Created February 23, 2019 19:19
demonstrates a problem I ran into with custom allocators which require a constructor argument and generic containers
#include <limits>
#include <list>
template <typename T> class FooAllocator {
char my_c;
public:
typedef T value_type;
typedef value_type *pointer;
typedef const value_type *const_pointer;
@ericherman
ericherman / keybase.md
Created August 24, 2018 20:06
keybase.io/eric_herman

Keybase proof

I hereby claim:

  • I am ericherman on github.
  • I am eric_herman (https://keybase.io/eric_herman) on keybase.
  • I have a public key ASAqdb4_ke__Oks4xjQEC0xLg8frhe1VqJ67g96KWIYTawo

To claim this, I am signing this object:

@ericherman
ericherman / gist:9d1a646ad380b27d42b9ff8497e69f32
Last active July 10, 2016 14:08
except in some rare cases, xor swapping is probably silly
eric@titan:~/src/code-snips/c$ cat swap-em.c
#include <stdio.h>
#include <stdint.h>
/* this is the way to swap pointers */
void standard_swap(char **left, char **right)
{
char *tmp;
tmp = *left;