Skip to content

Instantly share code, notes, and snippets.

Russell Harmon eatnumber1

Block or report user

Report or block eatnumber1

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eatnumber1
eatnumber1 / wait-with-timeout.c
Created Mar 28, 2017
wait(2) with timeout using a timer
View wait-with-timeout.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <stdbool.h>
#include <limits.h>
@eatnumber1
eatnumber1 / plex.conf
Created Dec 6, 2015
fluentd config for plex
View plex.conf
<source>
type tail
path /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/*.log
pos_file /var/lib/google-fluentd/pos/plex.pos
read_from_head true
tag plex
format multiline
format_firstline /^[^ ]+ \d{1,2}, \d{4} \d{2}:\d{2}:\d{2}/
format1 /^(?<time>^[^ ]+ \d{1,2}, \d{4} \d{2}:\d{2}:\d{2}) [^ ]+ (?<severity>[^ ]+) - (?<message>(?:(?:Request|Completed): \[(?<remotehost>[^:]+):[^\]]+\] (?<method>[^ ]+) (?<path>[^? ]+)(?:\?(?<querystring>[^ ]+))? \([^\)]+\)(?: (?:TLS|GZIP))*(?: [0-9]+ms (?<bytes>[0-9]+) bytes (?<status>[0-9]+))?.*|.+))$/
</source>
@eatnumber1
eatnumber1 / renameat2.c
Last active Jul 1, 2019
Command-line tool to call renameat2(2)
View renameat2.c
#define _GNU_SOURCE
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <getopt.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
@eatnumber1
eatnumber1 / good.c
Last active Aug 29, 2015
The result of a challenge to write in C code that will do the following when run in Python: "good " * 2. I think I got a little carried away.
View good.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
for (char *s = "good ", l = strlen(s), z = 2 * l, d[z], *p = d; p == d + z ? *--p = 0, !puts(d) : 1; p = memcpy(p, s, l) + l);
}
View a.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
int wins = 2;
char *s = "good ";
char *p = malloc(wins * strlen(s) + 1);
for (int i = 0; i < wins; i++) p = strcat(p, s);
printf("%s\n", p);
View -
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: CAPICUE.COM
Registrar: GOOGLE INC.
Whois Server: whois.rrpproxy.net
View goal.c
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#define g(...) "g", h,##__VA_ARGS__
#define h(...) "o", i,##__VA_ARGS__
#define i(...) "o", h,##__VA_ARGS__
View goal.rb
#!/usr/bin/env ruby
require 'continuation'
def newG(prefix = 'g')
proc do |tail = nil|
str = prefix
cont = nil
callcc{ |cc| cont = cc }
if tail == nil
str += 'o'
View a.c
int main() {
int a = 1;
a += 2;
return a;
}
View -
a.out:
(__TEXT,__text) section
_main:
0000000100000f70 pushq %rbp
0000000100000f71 movq %rsp, %rbp
0000000100000f74 movl $0x0, -0x4(%rbp)
0000000100000f7b movl $0x1, -0x8(%rbp)
0000000100000f82 movl -0x8(%rbp), %eax
0000000100000f85 addl $0x2, %eax
0000000100000f8a movl %eax, -0x8(%rbp)
You can’t perform that action at this time.