Skip to content

Instantly share code, notes, and snippets.

@orlp

orlp/pipes.c Secret

Last active September 17, 2016 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orlp/8e45655732ebd0ef4b13637479e44847 to your computer and use it in GitHub Desktop.
Save orlp/8e45655732ebd0ef4b13637479e44847 to your computer and use it in GitHub Desktop.
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define R rand()%
struct winsize W;int X,Y,d,e,w,h,s,l;void S(n){s=1;}
int main(c){srand(time(0));signal(SIGINT,S);
ioctl(STDOUT_FILENO,TIOCGWINSZ,&W);w=W.ws_col;h=W.ws_row;
printf("\033[?1049h\33[?25l");
for(;!s;usleep(19999)){
if(X%-~w*(Y%-~h)<1){(d=e=R 4)&2?X=1+R w,Y=d&1?1:h:(Y=1+R h,X=d?1:w),c=R 8;
if(l++%100<1)printf("\33[2J");}
e^=R 5?0:2+R 2;
printf("\33[%dm\33[%d;%dH\xe2\x94%c\33[H\n",30+c,Y,X,2*"@_JF_@LHHFA_LJ_A"[d*4|e]);
*((d=e)&2?&Y:&X)+=e%2*2-1;}return!printf("\33c\33[?25h\33[2J\033[?1049l");}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment