-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
ONERNG=/dev/ttyACM0 | ||
t=onerng.out | ||
|
||
stty -F $ONERNG raw -echo clocal -crtscts | ||
echo "cmd0" >$ONERNG # standard noise | ||
echo "cmdO" >$ONERNG # turn it on | ||
stty -F $ONERNG raw -echo clocal -crtscts | ||
gone() { | ||
echo "cmdo" >$ONERNG # turn it off | ||
echo "cmd4" >$ONERNG # turn off noise gathering | ||
echo "cmdw" >$ONERNG # flush entropy pool | ||
} | ||
trap gone EXIT SIGINT SIGTERM SIGHUP | ||
dd if=$ONERNG iflag=fullblock bs=1k "$@" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
TMPFILE=`mktemp` | ||
BOOK=$(ssh germinate "/home/zachary/bin/random_book" epub pdf txt html mobi) | ||
scp -q germinate:$BOOK "$TMPFILE" | ||
echo "$BOOK" | ||
case $BOOK in | ||
*.pdf) | ||
evince "$TMPFILE" >/dev/null 2>/dev/null | ||
;; | ||
*.html) | ||
w3m -T text/html "$TMPFILE" | ||
;; | ||
*.txt) | ||
less "$TMPFILE" | ||
;; | ||
*.epub|*.mobi) | ||
cr3 "$TMPFILE" >/dev/null 2>/dev/null | ||
;; | ||
esac | ||
rm "$TMPFILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// 'xor' | ||
// by zachary vance, released into the public domain (see CC0 1.0 license) | ||
// Given two streams (exactly) as filenames on the command line, print to stdout the 'xor' of the two files. Pads the shorter file with zeros, so the length of the output is always the length of the longer file | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
|
||
#define MAX_FILES 10 | ||
#define BUFFER 1024 | ||
|
||
int main(int argc, char *argv[]){ | ||
FILE *fp[MAX_FILES]; | ||
char inbytes[BUFFER], outbytes[BUFFER]; | ||
int bytes_read, max_bytes_read; | ||
int files, files_done; | ||
int f,b; | ||
|
||
files = argc-1; | ||
if (files < 2) { | ||
printf("usage: xor FILE1 FILE2\n"); | ||
return 2; | ||
} else if (files > MAX_FILES) { | ||
printf("Too many files. Please recompile with a faster number of files maximum\n"); | ||
return 2; | ||
} | ||
|
||
for (f=0;f<files;f++){ | ||
fp[f]=fopen(argv[f+1],"rb"); | ||
if(fp[f] == NULL){ | ||
printf("File %d not found: %s\n", f, argv[f+1]); | ||
return 1; | ||
} | ||
} | ||
|
||
while(1) { | ||
files_done=0; | ||
for(f=0;f<files;f++) | ||
if(feof(fp[f])) files_done++; | ||
if(files == files_done) break; | ||
|
||
memset(outbytes, 0, BUFFER); | ||
max_bytes_read=0; | ||
for(f=0;f<files;f++) { | ||
bytes_read = fread(&inbytes, 1, BUFFER, fp[f]); | ||
for(b=0;b<bytes_read;b++) outbytes[b] ^= inbytes[b]; | ||
if(bytes_read > max_bytes_read) max_bytes_read=bytes_read; | ||
} | ||
|
||
write(1, outbytes, max_bytes_read); | ||
} | ||
|
||
for(f=0;f<files;f++) fclose(fp[f]); | ||
|
||
return 0; | ||
} |