Skip to content

Instantly share code, notes, and snippets.

View Orc's full-sized avatar
🚎
On fire

Orc

🚎
On fire
View GitHub Profile
@Orc
Orc / diff.text
Last active August 17, 2023 08:38
diff.text
diff --git a/generate.c b/generate.c
index ee6159a..2ffe03f 100644
--- a/generate.c
+++ b/generate.c
@@ -775,26 +775,29 @@ linkylinky(int image, MMIOT *f)
else {
int goodlink, implicit_mark = mmiottell(f);
- if ( isspace(peek(f,1)) )
- pull(f);
@Orc
Orc / battery.sh
Created August 4, 2020 20:20 — forked from andreibosco/battery.sh
battery status for C.H.I.P.
#!/bin/sh
# This program gets the battery info from PMU
# Voltage and current charging/discharging
#
# Nota : temperature can be more than real because of self heating
#######################################################################
# Copyright (c) 2014 by RzBo, Bellesserre, France
#
# Permission is granted to use the source code within this
# file in whole or in part for any use, personal or commercial,
#! /bin/sh
HOSTS="tinyd gateway gehenna credit downbelow netbsd"
if [ ! "$1" ]; then
echo "usage: $0 {cmd}" 1>&2
exit 1
fi
cmd=$1
@Orc
Orc / orphans.sh
Last active March 30, 2019 09:09
orphans: a q&d shell script to look for orphan functions in my code
#! /bin/sh
#
# Find functions that are defined but not referenced in a body of C code
test -f tags || ctags -M *.c
test -f tags || exit 1
FILES=`awk -F' ' '{print $2}' < tags | sort |uniq`
@Orc
Orc / tgoto.c
Created March 27, 2019 03:21
A tgoto() implementation for systems that don't have termcap
/*
* partial implementation of termlib's tgoto() function, with
* the optimization of caching compiled strings so they don't
* need to be recompiled evey time tgoto is called.
*
* "partial implementation" because I've got yet implemented %<xy
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@Orc
Orc / cu.c
Created July 18, 2017 02:09
A cu wrapper to fill the time between realizing that apple shipped an insufficiently privileged cu & being able to boot the machine into recovery mode for a `csrutil disable`
#include <stdio.h>
#include <unistd.h>
main(argc, argv)
char **argv;
{
/* to get around the goddamn macos privilege protection racket */
execv("/usr/bin/cu", argv);
perror("cu");
}
@Orc
Orc / pull.sh
Created May 19, 2017 20:02
create a git repository from a pile of tarballs (one tarball per commit, ordered cronologically, with the git dates forged to match the tarball dates)
#! /bin/ksh
#
extractomatic() {
tarball=$1
first_in_archive=`tar tzf $tarball | head -1`
path=`dirname ${first_in_archive}/thing`
when=`dateof $tarball`
export GIT_COMMITTER_DATE="$when"
@Orc
Orc / dateof.c
Created May 19, 2017 20:00
print a file date in a git-aware form (needed by pull.sh)
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libgen.h>
#include <time.h>
main(argc, argv)
char **argv;
@Orc
Orc / dehtml.c
Last active May 15, 2017 21:19
Q&D html stripper for mutt
#include <stdio.h>
#include <string.h>
actualspace(register c)
{
return (c=='\r') || (c=='\n') || isspace(c);
}
int
@Orc
Orc / md5s.c
Last active April 25, 2017 18:11
Q&D md5sum clone that uses Solar Designer's md5 implementation
/* Q&D md5sum clone that uses Solar Designer's md5 implementation */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "md5.h"