Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
king_kilr
May 25, 2007

MutantBlue posted:

You've found the one thing that PHP is good for.

It's not even classy looking.

code:
print open(__file__).read().strip()

Adbot
ADBOT LOVES YOU

Zombywuf
Mar 29, 2008

Bash quine:
code:

qntm
Jun 17, 2009

bobthecheese posted:

php quine

php:
<?
echo file_get_contents($_SERVER['SCRIPT_FILENAME']);
?>
Is that cheating?

No, this PHP quine is cheating:

code:
Any text you like as long as you don't drop into PHP mode

nielsm
Jun 1, 2009



This PHP pattern:
php:
<?php
  include "pages/" $_GET['page'] . '.php';
?>
Makes for great fun if you then fetch index.php?page=../index :haw:

(I'm going to hit someone with a blunt instrument when he shows up.)

tef
May 30, 2004

-> some l-system crap ->

bobthecheese posted:

php quine

php:
<?
echo file_get_contents($_SERVER['SCRIPT_FILENAME']);
?>
Is that cheating?

yes

a quine is a program that prints itself without reading its own code

tef
May 30, 2004

-> some l-system crap ->

Zombywuf posted:

Bash quine:
code:

this is also a c quine too.

Fehler
Dec 14, 2004

.

nielsm posted:

This PHP pattern:
php:
<?php
  include "pages/" $_GET['page'] . '.php';
?>
Makes for great fun if you then fetch index.php?page=../index :haw:

(I'm going to hit someone with a blunt instrument when he shows up.)
Even better: include $_GET['page'] . '.php'; which may let you include arbitrary PHP code via HTTP, including, depending on the security settings, anything from reading config files to shell commands.

EvilJay
Jul 25, 2005

Scaevolus posted:

the best quine

"This is a Ruby program that outputs a Python program that outputs a Perl program that outputs a Lua program that outputs a OCaml program that outputs a Haskell program that outputs a C program that outputs a Java program that outputs a brainfuck program that outputs a Whitespace program that outputs a Unlambda program that outputs the program itself."

We had code in production until I replaced it a few years ago that went something like :

a csh script that writes a perl script that writes a sql script that passes the output to a different csh script that outputs to a file that is picked up by a cronjob 30 minutes later that sent it to a different server where something similar took place. It took me the better part of a day to figure out the workflow.

pseudorandom name
May 6, 2007

tef posted:

this is also a c quine too.
code:
$ touch empty.c
$ clang -Wall -O2 empty.c -o empty
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)

NinjaDebugger
Apr 22, 2008


EvilJay posted:

We had code in production until I replaced it a few years ago that went something like :

a csh script that writes a perl script that writes a sql script that passes the output to a different csh script that outputs to a file that is picked up by a cronjob 30 minutes later that sent it to a different server where something similar took place. It took me the better part of a day to figure out the workflow.

I've seen workflows that absurd as part of the AWIPS system the National Weather Service uses. You are not alone.

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.

nielsm posted:

This PHP pattern:
php:
<?php
  include "pages/" $_GET['page'] . '.php';
?>
Makes for great fun if you then fetch index.php?page=../index :haw:

(I'm going to hit someone with a blunt instrument when he shows up.)

This type of stuff is how c99.php (and others) end up on your server.

At the very least, it should check that the included page is an actual page that exists on your server, otherwise it's open to attack via passing a URL, etc.

PHP would read the URL, and execute any php code found there, which means that people can execute arbitrary code on your server (which they generally do to install a root-kit).

tef
May 30, 2004

-> some l-system crap ->

pseudorandom name posted:

code:
$ touch empty.c
$ clang -Wall -O2 empty.c -o empty
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)

it was an accepted and winning entry into ioccc

shrughes
Oct 11, 2008

(call/cc call/cc)

tef posted:

it was an accepted and winning entry into ioccc

They used weird build settings, I thought.

pseudorandom name
May 6, 2007

code:
smr: smr.c
	@${RM} -rf smr
	${CP} smr.c smr
	${CHMOD} +x smr
It won Best Abuse of the Rules in 1994. But it isn't a quine in C.

Molog
Mar 4, 2004
Title text
I changed names to anonymize it.

code:
bool
CdBurnClass::CopyStuffOnCD( const std::string& currentPath )
{
    if (LocateAndCopyFile(currentPath, "file1") == true)
	{
		if (LocateAndCopyFile(currentPath, "file2") == true)
		{
		    if (LocateAndCopyFile(currentPath, "file3") == true)
			{
		        if (LocateAndCopyFile(currentPath, "file4") == true)
				{
		            if (LocateAndCopyFile(currentPath, "file5") == true)
					{
						if (LocateAndCopyFile(currentPath, "file6") == true)
						{
							if (LocateAndCopyFile(currentPath, "file7") == true)
							{
								if (LocateAndCopyFile(currentPath, "file8") == true)
								{
									if (LocateAndCopyFile(currentPath, "file9") == true)
									{
										if (LocateAndCopyFile(currentPath, "file10") == true)
										{
											if (LocateAndCopyDirectory(currentPath, "file11") == true)
											{
												if (LocateAndCopyDirectory(currentPath, "file12") == true)
												{
													if (LocateAndCopyDirectory(currentPath, "file13 Help.pdf") == true)
													{
														if (LocateAndCopyFile(currentPath, "file14" ) == true)
														{
															if (CreateEmptyFile(file15) == true)
															{
																return true;	// The great pyramid
															}
															RemoveRootFilesystemObject(mSession, "file15" );
															RemoveRootFilesystemObject(mSession, "file14" );
														}
														RemoveRootFilesystemObject(mSession, "file13 Help.pdf");
													}
													RemoveRootFilesystemObject(mSession, "file12");
												}
												RemoveRootFilesystemObject(mSession, "file11");
											}
											RemoveRootFilesystemObject(mSession, "file10");
										}
										RemoveRootFilesystemObject(mSession, "file9");
									}
									RemoveRootFilesystemObject(mSession, "file8");
								}
								RemoveRootFilesystemObject(mSession, "file7");
							}
							RemoveRootFilesystemObject(mSession, "file6");
						}
						RemoveRootFilesystemObject(mSession, "file5");
					}
				    RemoveRootFilesystemObject(mSession, "file4");
				}
			    RemoveRootFilesystemObject(mSession, "file3");
			}
		    RemoveRootFilesystemObject(mSession, "file2");
		}
	    RemoveRootFilesystemObject(mSession, "file1");
	}

	return false;
}

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
     // The great pyramid
    /
:worship:

tripwire
Nov 19, 2004

        ghost flow

Scaevolus posted:

the best quine

"This is a Ruby program that outputs a Python program that outputs a Perl program that outputs a Lua program that outputs a OCaml program that outputs a Haskell program that outputs a C program that outputs a Java program that outputs a brainfuck program that outputs a Whitespace program that outputs a Unlambda program that outputs the program itself."

code:
# ruby
l=92.chr;eval s="s=s.dump[r=1..-2].gsub(/("+l*4+"){4,}(?!\")/){|t|'\"+l*%d+\"'%(t
.size/2)};5.times{s=s.dump[r]};puts\"# python\\nprint(\\\"# perl\\\\nprint(\\\\\\
\"# lua"+l*4+"nprint("+l*7+"\"(* ocaml *)"+l*8+"nprint_endline"+l*15+"\"-- haskel
l"+l*16+"nimport Data.List;import Data.Bits;import Data.Char;main=putStrLn("+l*31
+"\"/* C */"+l*32+"n#include<stdio.h>"+l*32+"nint main(void){char*s[501]={"+l*31+
"\"++intercalate"+l*31+"\","+l*31+"\"(c(tail(init(show("+l*31+"\"/* Java */"+l*32
+"npublic class QuineRelay{public static void main(String[]a){String[]s={"+l*31+"
\"++intercalate"+l*31+"\","+l*31+"\"(c("+l*31+"\"brainfuck"+l*64+"n++++++++[>++++
<-]+++++++++>>++++++++++"+l*31+"\"++(concat(snd(mapAccumL h 2("+l*31+"\"110"+l*31
+"\"++g(length s)++"+l*31+"\"22111211100111112021111102011112120012"+l*31+"\"++co
ncatMap("+l*32+"c->let d=ord c in if d<11then"+l*31+"\"21002"+l*31+"\"else"+l*31+
"\"111"+l*31+"\"++g d++"+l*31+"\"22102"+l*31+"\")s++"+l*31+"\"2100211101012021122
2211211101000120211021120221102111000110120211202"+l*31+"\"))))))++"+l*31+"\","+l
*63+"\""+l*64+"n"+l*63+"\"};int i=0;for(;i<94;i++)System.out.print(s[i]);}}"+l*31
+"\")))))++"+l*31+"\",0};int i=0;for(;s[i];i++)printf("+l*63+"\"%s"+l*63+"\",s[i]
);puts("+l*63+"\""+l*63+"\");return 0;}"+l*31+"\");c s=map("+l*32+"s->"+l*31+"\""
+l*63+"\""+l*31+"\"++s++"+l*31+"\""+l*63+"\""+l*31+"\")(unfoldr t s);t[]=Nothing;
t s=Just(splitAt(if length s>w&&s!!w=='"+l*31+"\"'then 501else w)s);w=500;f 0=Not
hing;f x=Just((if x`mod`2>0then '0'else '1'),x`div`2);g x= reverse (unfoldr f x);
h p c=let d=ord c-48in(d,replicate(abs(p-d))(if d<p then '<'else '>')++"+l*31+"\"
."+l*31+"\");s="+l*31+"\"# ruby"+l*32+"n"+l*31+"\"++"+l*31+"\"l=92.chr;eval s=\"+
(z=l*31)+\"\\\"\"+s+z+\"\\\""+l*31+"\"++"+l*31+"\""+l*32+"n"+l*31+"\""+l*15+"\""+
l*7+"\")"+l*4+"n\\\\\\\")\\\")\"########### (c) Yusuke Endoh, 2009 ###########\n"
(he also wrote the qlobe)

Oh my god

pseudorandom name
May 6, 2007

For those of you playing along at home, QuineRelay needs to be one line of text, not wrapped like the post here or the original web page.

Also, in the comments on the web page, there's a modified version that adds Erlang and sh.

Volte
Oct 4, 2004

woosh woosh
Is there some kind of quine theory that reduces creating quines to some sort of mechanical procedure, or did that guy just spend way too much time on it

Scaevolus
Apr 16, 2007

Volte posted:

Is there some kind of quine theory that reduces creating quines to some sort of mechanical procedure, or did that guy just spend way too much time on it
All the quines after the ruby one are basically just one long print("#next_language language_print("escaped string")), so it's trivial as long as you can get the base quine to set up the escaping properly.

e: okay, the haskell one does a bit of non-trivial escaping into brainfuck (and probably whitespace as well)

Scaevolus fucked around with this message at 00:35 on Apr 17, 2011

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Volte posted:

Is there some kind of quine theory that reduces creating quines to some sort of mechanical procedure, or did that guy just spend way too much time on it

Well, there's Kleene's Recursion Theorem.

BlackMK4
Aug 23, 2006

wat.
Megamarm

Molog posted:

I changed names to anonymize it.

code:
bool
CdBurnClass::CopyStuffOnCD( const std::string& currentPath )
How the gently caress did that guy get a job?

tef
May 30, 2004

-> some l-system crap ->

BlackMK4 posted:

How the gently caress did that guy get a job?

I guess he must have been curious and intelligent :v:

Molog
Mar 4, 2004
Title text
Not sure how he got a job or why he doesn't get fired. Guy causes more problems than he solves. In the last project I did with him we would have finished faster if he had stayed at home for half a year. He gets more more money than most other software engineers at the company too. I added the great pyramid comment because I found the code funny.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Scaevolus posted:

hq9+ quine
code:
q

The best part of hq9+ is the + instruction.

NotShadowStar
Sep 20, 2000
Now this certainly should not be down so far

Let's kick it up with 100% MORE ENTERPRISE

Zombywuf
Mar 29, 2008

NotShadowStar posted:

Now this certainly should not be down so far

Let's kick it up with 100% MORE ENTERPRISE

auaaaaaauioioiuaaaaaaaaaaeeeeeeuaughtaoeunnnnaaaaaaaaaaaaaaeeeeeeeo

drat, the noise I made when I saw that is hard to spell.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
The sound of Tim Bray stamping on a human face - forever.

revmoo
May 25, 2006

#basta

NotShadowStar posted:

Now this certainly should not be down so far

Let's kick it up with 100% MORE ENTERPRISE

What is the point of this? It's just encapsulating JSON into XML?

wwb
Aug 17, 2004

Xml is enterprise. Json works. Discuss.

Bigger scary part: who the gently caress needs an XML security appliance?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

wwb posted:

Xml is enterprise. Json works. Discuss.

Bigger scary part: who the gently caress needs an XML security appliance?

:tinfoil: EVERYONE :tinfoil: needs an xml security appliance; also a boys' band

tripwire
Nov 19, 2004

        ghost flow

NotShadowStar posted:

Now this certainly should not be down so far

Let's kick it up with 100% MORE ENTERPRISE

GHAEERARJKSHJKGHJKGHSJKDHFJKSDHASDH

NotShadowStar
Sep 20, 2000

revmoo posted:

What is the point of this? It's just encapsulating JSON into XML?

pre:
{
  "name":"John Smith"
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": 10021,
  },
  "phoneNumbers": [
    "212 555-1111",
    "212 555-2222"
  ],
  "additionalInfo": null,
  "remote": false,
  "height": 62.4,
  "ficoScore": " > 640"
}
pre:
<?xml version="1.0" encoding="UTF-8"?>
<json:object xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">
  <json:string name="name">John Smith</json:string>
  <json:object name="address">
    <json:string name="streetAddress">21 2nd Street</json:string>
    <json:string name="city">New York</json:string>
    <json:string name="state">NY</json:string>
    <json:number name="postalCode">10021</json:number>
  </json:object>
  <json:array name="phoneNumbers">
    <json:string>212 555-1111</json:string>
    <json:string>212 555-2222</json:string>
  </json:array>
  <json:null name="additionalInfo" />
  <json:boolean name="remote">false</json:boolean>
  <json:number name="height">62.4</json:number>
  <json:string name="ficoScore">> 640</json:string>
</json:object>
This is not a joke.

revmoo
May 25, 2006

#basta
Holy poo poo!

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I wonder if there's a point where something passes being a horror and becomes a crime against coding...

I mean what's next, make a wrapper that de-normalizes an RDB into name value pairs?

wwb
Aug 17, 2004

Relational to key value has disturbingly been done many times. We can start with FOR_XML_AUTO.

Oh, and who the gently caress submitted that xjson poo poo to reddit.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

wwb posted:

Bigger scary part: who the gently caress needs an XML security appliance?

We had a few of those when I worked for the government. No idea what they did but drat were they expensive

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


I'm annoyed that I can't find a video I saw recently of two guys making a presentation about bad ideas done well. Among other things they had, if I remember right, embedded php in the ruby runtime. Why? Because Enterprise!

e: VVVV Yes! Yes!!

Doc Hawkins fucked around with this message at 21:54 on Apr 29, 2011

NotShadowStar
Sep 20, 2000

Doc Hawkins posted:

I'm annoyed that I can't find a video I saw recently of two guys making a presentation about bad ideas done well. Among other things they had, if I remember right, embedded php in the ruby runtime. Why? Because Enterprise!

http://confreaks.net/videos/198-rubyconf2009-worst-ideas-ever

Aaron Patterson is loving hilarious, if a bit awkward hipster.

The best part is transforming the ruby abstract syntax tree, converting it to XML and doing all types of retarded things with it.

Adbot
ADBOT LOVES YOU

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Phuby on Phails :allears:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply