Last active
August 26, 2016 16:05
-
-
Save akatov/5160253 to your computer and use it in GitHub Desktop.
Some quines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* C++.cpp | |
* | |
* Copyright 2013 Dmitri Akatov (@akatov) | |
* | |
* $ g++ -o C++ C++.cpp && ./C++ | diff - C++.cpp | |
*/ | |
#include <iostream> | |
using namespace std; | |
int main() { | |
char e = 32; | |
char q = 34; | |
char c = 44; | |
string s[] = { | |
"/* C++.cpp", | |
" *", | |
" * Copyright 2013 Dmitri Akatov (@akatov)", | |
" *", | |
" * $ g++ -o C++ C++.cpp && ./C++ | diff - C++.cpp", | |
" */", | |
"", | |
"#include <iostream>", | |
"", | |
"using namespace std;", | |
"", | |
"int main() {", | |
" char e = 32;", | |
" char q = 34;", | |
" char c = 44;", | |
" string s[] = {", | |
" };", | |
" for (int i = 0; i < 16; ++i) cout << s[i] << endl;", | |
" for (int i = 0; i < 23; ++i) {", | |
" cout << e << e << e << e << q << s[i] << q << c << endl;", | |
" }", | |
" for (int i = 16; i < 23; ++i) cout << s[i] << endl;", | |
"}", | |
}; | |
for (int i = 0; i < 16; ++i) cout << s[i] << endl; | |
for (int i = 0; i < 23; ++i) { | |
cout << e << e << e << e << q << s[i] << q << c << endl; | |
} | |
for (int i = 16; i < 23; ++i) cout << s[i] << endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env clj | |
;; Clojure.clj | |
;; | |
;; Copyright 2013 Dmitri Akatov (@akatov) | |
;; | |
;; $ clj Clojure.clj | diff - Clojure.clj | |
(use 'clojure.pprint) | |
(pprint | |
((fn | |
[x] | |
(println "#!/usr/bin/env clj") | |
(println) | |
(println ";; Clojure.clj") | |
(println ";;") | |
(println ";; Copyright 2013 Dmitri Akatov (@akatov)") | |
(println ";;") | |
(println ";; $ clj Clojure.clj | diff - Clojure.clj") | |
(println) | |
(pprint '(use 'clojure.pprint)) | |
(println) | |
(list 'pprint (list x (list 'quote x)))) | |
'(fn | |
[x] | |
(println "#!/usr/bin/env clj") | |
(println) | |
(println ";; Clojure.clj") | |
(println ";;") | |
(println ";; Copyright 2013 Dmitri Akatov (@akatov)") | |
(println ";;") | |
(println ";; $ clj Clojure.clj | diff - Clojure.clj") | |
(println) | |
(pprint '(use 'clojure.pprint)) | |
(println) | |
(list 'pprint (list x (list 'quote x)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
{- Haskell.hs | |
- | |
- Copyright 2013 Dmitri Akatov (@akatov) | |
- | |
- $ runhaskell Haskell.hs | diff - Haskell.hs | |
-} | |
import Control.Applicative | |
import Data.List | |
main :: IO () | |
main = putStrLn | |
. ( (++) | |
<*> ( (" [ " ++) | |
. (++ "\n ]") | |
. intercalate "\n , " | |
. map show | |
. lines | |
) | |
) | |
. init | |
. unlines | |
$ [ "#!/usr/bin/env runhaskell" | |
, "" | |
, "{- Haskell.hs" | |
, " -" | |
, " - Copyright 2013 Dmitri Akatov (@akatov)" | |
, " -" | |
, " - $ runhaskell Haskell.hs | diff - Haskell.hs" | |
, " -}" | |
, "" | |
, "import Control.Applicative" | |
, "import Data.List" | |
, "" | |
, "main :: IO ()" | |
, "main = putStrLn" | |
, " . ( (++)" | |
, " <*> ( (\" [ \" ++)" | |
, " . (++ \"\\n ]\")" | |
, " . intercalate \"\\n , \"" | |
, " . map show" | |
, " . lines" | |
, " )" | |
, " )" | |
, " . init" | |
, " . unlines" | |
, " $" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Java.java | |
* | |
* Copyright 2013 Dmitri Akatov (@akatov) | |
* | |
* $ javac Java.java && java Java | diff - Java.java | |
*/ | |
class Java { | |
public static void main(String[] a) { | |
String o = "/* Java.java" | |
+ "\n *" | |
+ "\n * Copyright 2013 Dmitri Akatov (@akatov)" | |
+ "\n *" | |
+ "\n * $ javac Java.java && java Java | diff - Java.java" | |
+ "\n */" | |
+ "\n" | |
+ "\nclass Java {" | |
+ "\n public static void main(String[] a) {" | |
+ "\n String o = ;" | |
+ "\n char q = 34;" | |
+ "\n String m = o;" | |
+ "\n m = m.replace(\"\\\\\", \"\\\\\\\\\");" | |
+ "\n m = m.replace(\"\\\"\", \"\\\\\\\"\");" | |
+ "\n m = m.replace(\"\\n\"," | |
+ "\n \"\\\"\\n + \\\"\\\\n\");" | |
+ "\n System.out.println(o.substring(0, 193) + q + m + q" | |
+ "\n + o.substring(193));" | |
+ "\n }" | |
+ "\n}"; | |
char q = 34; | |
String m = o; | |
m = m.replace("\\", "\\\\"); | |
m = m.replace("\"", "\\\""); | |
m = m.replace("\n", | |
"\"\n + \"\\n"); | |
System.out.println(o.substring(0, 193) + q + m + q | |
+ o.substring(193)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* JavaScript.js | |
* | |
* Copyright 2013 Dmitri Akatov (@akatov) | |
* | |
* $ node JavaScript.js | diff - JavaScript.js | |
*/ | |
(function f() { | |
console.log('/* JavaScript.js'); | |
console.log(' *'); | |
console.log(' * Copyright 2013 Dmitri Akatov (@akatov)'); | |
console.log(' *'); | |
console.log(' * $ node JavaScript.js | diff - JavaScript.js'); | |
console.log(' */'); | |
console.log(''); | |
console.log('('+f+')();'); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Ruby.rb | |
# | |
# Copyright 2013 Dmitri Akatov (@akatov) | |
# | |
# $ ruby Ruby.rb | diff - Ruby.rb | |
puts <<EOF*2,'EOF' | |
#!/usr/bin/env ruby | |
# Ruby.rb | |
# | |
# Copyright 2013 Dmitri Akatov (@akatov) | |
# | |
# $ ruby Ruby.rb | diff - Ruby.rb | |
puts <<EOF*2,'EOF' | |
EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copyright (C) 2013 Dmitri Akatov (@akatov) | |
Permission is hereby granted, free of charge, to any person obtaining a copy of | |
this software and associated documentation files (the "Software"), to deal in | |
the Software without restriction, including without limitation the rights to use, | |
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the | |
Software, and to permit persons to whom the Software is furnished to do so, | |
subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment