Skip to content

Instantly share code, notes, and snippets.

View slw287r's full-sized avatar
Working from home

Richard slw287r

Working from home
View GitHub Profile
@slw287r
slw287r / kgzl.c
Created May 20, 2024 14:05
Using zlib's gzgets with kgetline in kstring
#include <stdio.h>
#include <stdlib.h>
#include <zlib.h>
#include "kstring.h"
// alias to gzgets with input order swapped
char *kzgets(char *buf, int siz, gzFile fp) { return gzgets(fp, buf, siz); }
int main(int argc, char *argv[])
{
@slw287r
slw287r / ttrt.sh
Last active March 23, 2020 02:21
total run time in bash
START=$(date +%s)
sleep 100
END=$(date +%s)
DIFF=$(( $END - $START ))
printf '%dh:%dm:%ds\n' $(($DIFF/3600)) $(($DIFF%3600/60)) $(($DIFF%60))
# another way
SECONDS=0
@slw287r
slw287r / tart.sh
Created March 23, 2020 02:20
total run time in bash
START=$(date +%s)
sleep 100
END=$(date +%s)
DIFF=$(( $END - $START ))
printf '%dh:%dm:%ds\n' $(($DIFF/3600)) $(($DIFF%3600/60)) $(($DIFF%60))
# another way
SECONDS=0
@slw287r
slw287r / tart.sh
Created March 23, 2020 02:20
total run time in bash
START=$(date +%s)
sleep 100
END=$(date +%s)
DIFF=$(( $END - $START ))
printf '%dh:%dm:%ds\n' $(($DIFF/3600)) $(($DIFF%3600/60)) $(($DIFF%60))
# another way
SECONDS=0