Skip to content

Instantly share code, notes, and snippets.

@rbobillot
Last active September 6, 2017 14:21
Show Gist options
  • Save rbobillot/60e12837c9e8829337ff8465c2621493 to your computer and use it in GitHub Desktop.
Save rbobillot/60e12837c9e8829337ff8465c2621493 to your computer and use it in GitHub Desktop.
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
char *swag = " #include <time.h>\n #include <stdio.h>\n #include <unistd.h>\n #include <stdlib.h>\n #include <string.h>\n #include <termios.h>\n\n char *swag = \"[SOME CODE HERE]\";\n\n void showContent(char *content)\n {\n int i, ran;\n char buf, c;\n struct termios oldt, newt;\n\n i = 0;\n tcgetattr(STDIN_FILENO, &oldt);\n newt = oldt;\n newt.c_lflag &= ~(ICANON | ECHO);\n tcsetattr(STDIN_FILENO, TCSANOW, &newt);\n write(1, \"\\033c\", 2);\n while (read(0, &buf, 1) && buf != 4)\n {\n ran = rand() % 2 + 1;\n while (--ran > -1)\n {\n write(1, \"\\033[92m\", 5);\n\n c = content[i % strlen(content)];\n write(1, &c, 1);\n i++;\n\n write(1, \"\\033[0m\", 5);\n }\n }\n tcsetattr(STDIN_FILENO, TCSANOW, &oldt);\n write(1, \"\\n\", 1);\n}\n\n int main(void)\n {\n srand(time(NULL));\n showContent(swag);\n return (0);\n }\n\n";
void showContent(char *content)
{
int i, ran;
char buf, c;
struct termios oldt, newt;
i = 0;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
write(1, "\033c", 2);
while (read(0, &buf, 1) && buf != 4)
{
ran = rand() % 2 + 1;
while (--ran > -1)
{
write(1, "\033[92m", 5);
c = content[i % strlen(content)];
write(1, &c, 1);
i++;
write(1, "\033[0m", 5);
}
}
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
write(1, "\n", 1);
}
int main(void)
{
srand(time(NULL));
showContent(swag);
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment