Skip to content

Instantly share code, notes, and snippets.

@mina86
mina86 / rfc1123.c
Created January 16, 2010 00:07
A simple parser converting RFC1123 date into an argument date util accepts.
/*
* RFC1123 date parser.
* Copyright (c) 2010 by Michal Nazarewicz (mina86/AT/mina86.com)
* Distributed under the terms of Academic Free License 3.0
*/
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(void) {
char tmp[128];
while (scanf(" %128s ", tmp) == 1) {
if (!strcmp("Date:", tmp) && fgets(tmp, sizeof tmp, stdin)) {
fputs(tmp, stdout);
return 0;
}
@mina86
mina86 / ltp-2.cpp
Created January 16, 2010 13:28
Program calculating LTPs (Left-Truncatable Primes)
/*
* Oryginal by "ProgramistaBezDoswiadczenia!"
* At this point highly modified.
* See http://hoppke.jogger.pl/2010/01/13/cwiczenie-programistyczne/
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
@mina86
mina86 / fib.c
Created January 16, 2010 22:21 — forked from rsayers/fib.c
#include <stdio.h>
static unsigned long count;
static unsigned long fib(unsigned n) {
++count;
return n > 1 ? fib(n - 1) + fib(n - 2) : n;
}
int main(void) {
unsigned i;
@mina86
mina86 / gist:729036
Created December 5, 2010 11:59
tree.sh
#!/bin/sh
# See http://damienix.jogger.pl/2010/12/01/skrypt-bashowy-wyswietlajacy-drzewko-struktury-katalogow/
clr_dir='\33[1;34m' # Blue
clr_fil='\33[0;33m' # Yellow
clr_rst='\33[0m' # Text Reset
chain() {
# $1 $2 - no change
@mina86
mina86 / self-print.c
Created May 4, 2011 23:33
Self printing C program
#include <stdio.h>
int main() {
const char *fmt = "#include <stdio.h>%c%cint main() {%c const char *fmt = %c%s%c;%c printf(fmt, 10, 10, 10, 34, fmt, 34, 10, 10, 10, 10);%c return 0;%c}%c";
printf(fmt, 10, 10, 10, 34, fmt, 34, 10, 10, 10, 10);
return 0;
}
@mina86
mina86 / xd
Created November 5, 2011 05:58
#!/bin/sh
set -eu
do_zip() {
unzip -x "$2"
}
do_rar() {
@mina86
mina86 / aux.c
Last active November 26, 2021 15:00
Code reading auxiliary vector present in executable binary.
#define _GNU_SOURCE
#include <linux/auxvec.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static unsigned long *getauxv(void) {
char **env = environ;
line() {
local line=--------------------
while [ ${#line} -lt $COLUMNS ]; do
line=$line$line
done
printf "%.$(($COLUMNS - 9))s %(%H:%M:%S)T\\n" "$line" -1
}
@mina86
mina86 / version.py
Last active December 10, 2022 04:07 — forked from dcreager/version.py
Extract a setuptools version from the git repository's tags.
# -*- coding: utf-8 -*-
"""Calculates the current version number.
If possible, uses output of “git describe” modified to conform to the
visioning scheme that setuptools uses (see PEP 386). Releases must be
labelled with annotated tags (signed tags are annotated) of the following
format:
v<num>(.<num>)+ [ {a|b|c|rc} <num> (.<num>)* ]