Byproduct of Insomnia

Started by
6 comments, last by Bacterius 10 years, 9 months ago

This one needs a little explaining. A while back I was in the middle of a major life crisis and things where looking real bad for me, in a nutshell I couldn't sleep. I was put on ambien by my doctor, and found I did not go to sleep while on it. Instead I turned into a zombie of a person that walked into walls ocassionally. This is something I coded while awake on ambien.


//-----Generate Self Extracting patch installer----->
	if(generatePatch && numDiffs > 0){//-b flag
		//construct base source files
		system("mkdir /tmp/builder");
		system("echo '#include <stdio.h>' > /tmp/builder/headers.c");
		system("echo '#include <stdlib.h>' >> /tmp/builder/headers.c");
		system("echo \" \" >> /tmp/builder/headers.c");//space

		system("echo \" \" > /tmp/builder/decompile.c");//space
		system("echo 'int main(){' >> /tmp/builder/decompile.c");
		system("echo 'FILE *fp = fopen(\"TMP.tar.gz\",\"wb\");' >> /tmp/builder/decompile.c");
		system("echo 'fwrite(xxx, sizeof(xxx[0]), sizeof xxx/sizeof(xxx[0]), fp);' >> /tmp/builder/decompile.c");
		system("echo 'fclose(fp);' >> /tmp/builder/decompile.c");

		//do any additional installation work here-->
		system("ST=\\\"\necho \"system(${ST}> .install.py${ST});//create installer script\" >> /tmp/builder/decompile.c");//create script file
			//write python install script here-->
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'from Tkinter import * ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'from tkFileDialog import askdirectory ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'import os ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'def askd(): ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '	dir1 = askdirectory() ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '	if dir1: ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '		print ${STT}Directory ${STT} + dir1 + ${STT} Will Be Patched.${STT}' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '		os.system(${STT}tar -zxf ./TMP.tar.gz -C .${STT}) ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '		os.system(${STT}mv -f .gamepatch.diff* ${STT} + dir1) ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '		os.system(${STT}rm ./TMP.tar.gz${STT}) ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '		os.system(${STT}cd dir1\\\\\\\ngamepatch -p 10000${STT}) ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");//patch system to latest patch
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '		quit() ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");//exit tkinter
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '		exit() ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");//exit python
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'top = Frame() ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'top.pack() ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'Label(top, text=${STT}${STT}${STT}This patch is only designed for a specific game. ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'Do Not Use If Unsure What Game This Is For! ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '${STT}${STT}${STT}).pack(side=TOP) ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'widget = Button(top, text=${STT}Choose Game Directory To Patch${STT}, command=askd) ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'widget.pack(side=BOTTOM) ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			system("STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo 'top.mainloop() ' >> .install.py${ST});\" >> /tmp/builder/decompile.c");
			//---------------------------------->
		system("ST=\\\"\necho \"system(${ST}gnome-terminal -e 'python ./.install.py'${ST});\" >> /tmp/builder/decompile.c");//run script file
		system("ST=\\\"\necho \"system(${ST}rm .install.py${ST});\" >> /tmp/builder/decompile.c");//remove script file
		//------------------------------------------>

		system("echo 'return 0;}' >> /tmp/builder/decompile.c");


		//build and merge source files
		system("tar -zcf /tmp/builder/TMP.tar.gz .gamepatch.diff*");
		system("cat /tmp/builder/TMP.tar.gz | ( echo \"unsigned char xxx[] = {\"; xxd -i; echo \"};\" ) > /tmp/builder/output_file.c");
		system("cat /tmp/builder/headers.c /tmp/builder/output_file.c /tmp/builder/decompile.c > /tmp/builder/builder.c");
		

		//compile source file
		if(path==NULL){
			system("gcc /tmp/builder/builder.c -o ./patcher");
		}
		else{
			sprintf(buffer, "%s%s","gcc /tmp/builder/builder.c -o ",path);
			system(buffer);
		}
		printf("\n-->Patch Installer Has Been Generated\n");
	}
	//-------------------------------------------------->
Advertisement

Is that.. a system call in a system call in an interpreted system call via a spawned terminal? +_+

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Oh god. The escaping escape-escapes. They've escaped! Again!! .. it's literally making my eyes water..

I hope your crisis improves soon! *man-hug*

Well that's a good use-case for a macro and the string literal concatenation which is done by the preprocessor.

#define PREAMBLE "STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '"

Then you can do system(PREAMBLE "rest of stuff");

You don't even need an operator!

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

One of the mistakes people make with Ambien is not immediately going to and staying in bed. If you take it and stay up, most people go into crazy mode and start doing a lot of weird things. I saw a thread once about the stuff people have done while on ambien. It's an oddball.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

One of the mistakes people make with Ambien is not immediately going to and staying in bed. If you take it and stay up, most people go into crazy mode and start doing a lot of weird things. I saw a thread once about the stuff people have done while on ambien. It's an oddball.

Well that's a good use-case for a macro and the string literal concatenation which is done by the preprocessor.

#define PREAMBLE "STT=\\\\\\\"\nST=\\\"\necho \"system(${ST}echo '"

Then you can do system(PREAMBLE "rest of stuff");

You don't even need an operator!

Very true, now that I'm off the med, I realize how crazy most of my coding was during those couple of months. I am under the firm belief that most new game companies fail because they push their employees too hard and don't let them sleep enough.

Yo dawg, I heard you like escapes...

But seriously, personally I've made a commitment to 8 hours of sleep a night and my productivity has gone through the roof. It can't be ignored.

Eric Finlay

http://www.foosler.com - Win Big. On the Go.

Yo dawg, I heard you like escapes...

But seriously, personally I've made a commitment to 8 hours of sleep a night and my productivity has gone through the roof. It can't be ignored.

Staying up late to get more done is so tempting though unsure.png

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

This topic is closed to new replies.

Advertisement