SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
A Self Replicating
Serverless Function
Michael Adda
BINARIS Co-founder
@michael_adda
A quine is a non-empty computer
program which takes no input and
produces a copy of its own source
code as its only output
#!/bin/sh
cat $0
☹
☹
s=‘s=%rnprint(s%%s)’
print(s%s)
🤔
Say twice say twice
😀
Write twice Write twice
😀
Write twice Write twice
the command the stanza
Write twice “Write twice”
☹
Write once without quotes and once
with quotes
“Write once without quotes and once
with quotes”
😀
Write the stanza without quotes.
Write the stanza with quotes.
“Write the stanza without quotes.
Write the stanza with quotes.”
😀
Write the stanza without quotes.
Write the stanza with quotes.
The stanza is: “
Write the stanza without quotes.
Write the stanza with quotes.”
☹
The stanza is: “
Write the stanza with quotes.
Write the stanza without quotes.”
Write the stanza with quotes.
Write the stanza without quotes.
🙁
The stanza is: “
Write ‘The stanza is: ’
Write the stanza with quotes.
Write the stanza without quotes.”
Write ‘The stanza is: ’
Write the stanza with quotes.
Write the stanza without quotes.
😃
const stanza = `
const backtick = String.fromCharCode(96);
const quine = ‘const stanza = ’
+ backtick + stanza + backtick + ‘;’
+ stanza;
console.log(quine);`;
const backtick = String.fromCharCode(96);
const quine = ‘const stanza = ’
+ backtick + stanza + backtick + ‘;’
+ stanza;
console.log(quine); 😃
stanza = “““
marker = chr(34) * 3
quine = ‘stanza = ’ 
+ marker + stanza + marker 
+ stanza
print(quine)”””
marker = chr(34) * 3
quine = ‘stanza = ’ 
+ marker + stanza + marker 
+ stanza
print(quine) 😃
$ node quine.js | diff quine.js -
$ echo $?
0
$ node quine.py | diff quine.py -
$ echo $?
0
&
const stanza = `
exports.handler = (event, context, cb) => {
const backtick = String.fromCharCode(96);
const quine = ‘const stanza = ’
+ backtick + stanza + backtick + ‘;’
+ stanza;
const response = {
statusCode: 200,
body: quine,
};
cb(null, response);
};`;
... 😃
stanza = “““
def lambda_handler(event, context):
marker = chr(34) * 3
quine = ‘stanza = ’ 
+ marker + stanza + marker 
+ stanza
return {‘statusCode’: ‘200’,
‘body’: quine}
”””
... 😃
$ curl -s “https://hn8pe4gd37.execute-api.eu-central-1.amazonaws.com/
dev/lambda_quine_js” | diff lambda_quine.js -
$ echo $?
0
$ curl -s “https://hn8pe4gd37.execute-api.eu-central-1.amazonaws.com/
dev/lambda_quine_py” | diff lambda_quine.py -
$ echo $?
0
&
exports.handler = (event, context, cb) => {
const backtick = String.fromCharCode(96);
const quine = ‘const stanza = ’
+ backtick + stanza + backtick + ‘;’
+ stanza;
hook(event, quine, () => {
const response = {
statusCode: 200,
body: quine,
};
cb(null, response);
};
};
function hook(event, quine, cb) {
// do some stuff
cb();
}
How to generate the zipped file?
• Embed the file binary representation
• Embed zip source code
• Use a serverless zip function
const admZip = require(‘adm-zip’);
exports.handler = (event, context, callback) => {
// creating archives
const zip = new admZip();
// add files directly
Object.keys(event).forEach((key) => {
zip.addFile(key,
new Buffer(event[key]),
‘Just another file’,
0o777 << 16);
});
// return the zip as a buffer
callback(null, zip.toBuffer());
};
function hook(event, quine, cb) {
const Role = process.env.Role;
if (event.queryStringParameters) {
const FunctionName = event.queryStringParameters.FunctionName;
lambda.invoke({
FunctionName: 'zipper',
Payload: JSON.stringify({ 'index.js': quine }),
}, (error, data) => {
const ZipFile = new Buffer(JSON.parse(data.Payload));
const params = {
Code: { ZipFile },
FunctionName,
Handler: 'index.handler',
Role,
Runtime: 'nodejs6.10',
Description: ‘Generated by a quine’,
Environment: { Variables: { Role } },
};
lambda.createFunction(params, cb);
} else {
cb();
}
}
😃
$ curl -s “https://draei6bs56.execute-api.eu-central-1.amazonaws.com/
quine/replicator?FunctionName=replicated" | diff replicator.js -
$ echo $?
0
$ aws lambda invoke --function-name replicated aws_results
$ cat aws_results | jq -j .body | diff replicator.js -
$ echo $?
0
&
const javaScriptStanza = `
const quote = String.fromCharCode(34);
const newline = String.fromCharCode(10);
const marker = quote + quote + quote;
const ouroboros = ‘javaScriptStanza = ’
+ marker + javaScriptStanza + marker + newline
+ ‘pythonStanza = ’
+ marker + pythonStanza + marker
+ pythonStanza;
console.log(ouroboros);`;
const pythonStanza = `
backtick = chr(96)
newline = chr(10)
ouroboros = ‘const javaScriptStanza = ’ 
+ backtick + javaScriptStanza + backtick + ‘;’ + newline 
+ ‘const pythonStanza = ’ 
+ backtick + pythonStanza + backtick + ‘;’ 
+ javaScriptStanza
print(ouroboros)`;
😃
javaScriptStanza = “““
const quote = String.fromCharCode(34);
const newline = String.fromCharCode(10);
const marker = quote + quote + quote;
const ouroboros = ‘javaScriptStanza = ’
+ marker + javaScriptStanza + marker + newline
+ ‘pythonStanza = ’
+ marker + pythonStanza + marker
+ pythonStanza;
console.log(ouroboros);”””
pythonStanza = “““
backtick = chr(96)
newline = chr(10)
ouroboros = ‘const javaScriptStanza = ’ 
+ backtick + javaScriptStanza + backtick + ‘;’ + newline 
+ ‘const pythonStanza = ’ 
+ backtick + pythonStanza + backtick + ‘;’ 
+ javaScriptStanza
print(ouroboros)”””
😃😃
For those interested in replicating this code:
https://github.com/gobinaris/serverlessconf-austin-2017
@michael_adda

Weitere ähnliche Inhalte

Was ist angesagt?

PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
Yusuke Wada
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
Fabien Potencier
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
Kris Wallsmith
 

Was ist angesagt? (20)

AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprima
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
 
Xmpp prebind
Xmpp prebindXmpp prebind
Xmpp prebind
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding Horrors
 
Generated Power: PHP 5.5 Generators
Generated Power: PHP 5.5 GeneratorsGenerated Power: PHP 5.5 Generators
Generated Power: PHP 5.5 Generators
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 
Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)Keep It Simple Security (Symfony cafe 28-01-2016)
Keep It Simple Security (Symfony cafe 28-01-2016)
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
 
Oro meetup #4
Oro meetup #4Oro meetup #4
Oro meetup #4
 
Php course-in-navimumbai
Php course-in-navimumbaiPhp course-in-navimumbai
Php course-in-navimumbai
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
 

Ähnlich wie A Self Replicating Serverless Function

Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Paulo Ragonha
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
Ingvar Stepanyan
 
CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developers
Mehdi Valikhani
 
Getfilestruct zbksh(1)
Getfilestruct zbksh(1)Getfilestruct zbksh(1)
Getfilestruct zbksh(1)
Ben Pope
 
Getfilestruct zbksh
Getfilestruct zbkshGetfilestruct zbksh
Getfilestruct zbksh
Ben Pope
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Jesse Vincent
 

Ähnlich wie A Self Replicating Serverless Function (20)

Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developers
 
Getfilestruct zbksh(1)
Getfilestruct zbksh(1)Getfilestruct zbksh(1)
Getfilestruct zbksh(1)
 
Getfilestruct zbksh
Getfilestruct zbkshGetfilestruct zbksh
Getfilestruct zbksh
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegen
 
NativeBoost
NativeBoostNativeBoost
NativeBoost
 
Rust ⇋ JavaScript
Rust ⇋ JavaScriptRust ⇋ JavaScript
Rust ⇋ JavaScript
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Fabric Python Lib
Fabric Python LibFabric Python Lib
Fabric Python Lib
 
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY SyntaxRubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
 
CoffeeScript Design Patterns
CoffeeScript Design PatternsCoffeeScript Design Patterns
CoffeeScript Design Patterns
 
Odoo from 7.0 to 8.0 API
Odoo from 7.0 to 8.0 APIOdoo from 7.0 to 8.0 API
Odoo from 7.0 to 8.0 API
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new api
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

A Self Replicating Serverless Function

  • 1. A Self Replicating Serverless Function Michael Adda BINARIS Co-founder @michael_adda
  • 2.
  • 3. A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output
  • 5.
  • 6.
  • 8. Say twice say twice 😀
  • 9. Write twice Write twice 😀
  • 10. Write twice Write twice the command the stanza
  • 11. Write twice “Write twice” ☹
  • 12. Write once without quotes and once with quotes “Write once without quotes and once with quotes” 😀
  • 13. Write the stanza without quotes. Write the stanza with quotes. “Write the stanza without quotes. Write the stanza with quotes.” 😀
  • 14. Write the stanza without quotes. Write the stanza with quotes. The stanza is: “ Write the stanza without quotes. Write the stanza with quotes.” ☹
  • 15. The stanza is: “ Write the stanza with quotes. Write the stanza without quotes.” Write the stanza with quotes. Write the stanza without quotes. 🙁
  • 16. The stanza is: “ Write ‘The stanza is: ’ Write the stanza with quotes. Write the stanza without quotes.” Write ‘The stanza is: ’ Write the stanza with quotes. Write the stanza without quotes. 😃
  • 17. const stanza = ` const backtick = String.fromCharCode(96); const quine = ‘const stanza = ’ + backtick + stanza + backtick + ‘;’ + stanza; console.log(quine);`; const backtick = String.fromCharCode(96); const quine = ‘const stanza = ’ + backtick + stanza + backtick + ‘;’ + stanza; console.log(quine); 😃
  • 18. stanza = “““ marker = chr(34) * 3 quine = ‘stanza = ’ + marker + stanza + marker + stanza print(quine)””” marker = chr(34) * 3 quine = ‘stanza = ’ + marker + stanza + marker + stanza print(quine) 😃
  • 19. $ node quine.js | diff quine.js - $ echo $? 0 $ node quine.py | diff quine.py - $ echo $? 0 &
  • 20. const stanza = ` exports.handler = (event, context, cb) => { const backtick = String.fromCharCode(96); const quine = ‘const stanza = ’ + backtick + stanza + backtick + ‘;’ + stanza; const response = { statusCode: 200, body: quine, }; cb(null, response); };`; ... 😃
  • 21. stanza = “““ def lambda_handler(event, context): marker = chr(34) * 3 quine = ‘stanza = ’ + marker + stanza + marker + stanza return {‘statusCode’: ‘200’, ‘body’: quine} ””” ... 😃
  • 22. $ curl -s “https://hn8pe4gd37.execute-api.eu-central-1.amazonaws.com/ dev/lambda_quine_js” | diff lambda_quine.js - $ echo $? 0 $ curl -s “https://hn8pe4gd37.execute-api.eu-central-1.amazonaws.com/ dev/lambda_quine_py” | diff lambda_quine.py - $ echo $? 0 &
  • 23. exports.handler = (event, context, cb) => { const backtick = String.fromCharCode(96); const quine = ‘const stanza = ’ + backtick + stanza + backtick + ‘;’ + stanza; hook(event, quine, () => { const response = { statusCode: 200, body: quine, }; cb(null, response); }; };
  • 24. function hook(event, quine, cb) { // do some stuff cb(); }
  • 25. How to generate the zipped file? • Embed the file binary representation • Embed zip source code • Use a serverless zip function
  • 26. const admZip = require(‘adm-zip’); exports.handler = (event, context, callback) => { // creating archives const zip = new admZip(); // add files directly Object.keys(event).forEach((key) => { zip.addFile(key, new Buffer(event[key]), ‘Just another file’, 0o777 << 16); }); // return the zip as a buffer callback(null, zip.toBuffer()); };
  • 27. function hook(event, quine, cb) { const Role = process.env.Role; if (event.queryStringParameters) { const FunctionName = event.queryStringParameters.FunctionName; lambda.invoke({ FunctionName: 'zipper', Payload: JSON.stringify({ 'index.js': quine }), }, (error, data) => { const ZipFile = new Buffer(JSON.parse(data.Payload)); const params = { Code: { ZipFile }, FunctionName, Handler: 'index.handler', Role, Runtime: 'nodejs6.10', Description: ‘Generated by a quine’, Environment: { Variables: { Role } }, }; lambda.createFunction(params, cb); } else { cb(); } } 😃
  • 28. $ curl -s “https://draei6bs56.execute-api.eu-central-1.amazonaws.com/ quine/replicator?FunctionName=replicated" | diff replicator.js - $ echo $? 0 $ aws lambda invoke --function-name replicated aws_results $ cat aws_results | jq -j .body | diff replicator.js - $ echo $? 0 &
  • 29.
  • 30. const javaScriptStanza = ` const quote = String.fromCharCode(34); const newline = String.fromCharCode(10); const marker = quote + quote + quote; const ouroboros = ‘javaScriptStanza = ’ + marker + javaScriptStanza + marker + newline + ‘pythonStanza = ’ + marker + pythonStanza + marker + pythonStanza; console.log(ouroboros);`; const pythonStanza = ` backtick = chr(96) newline = chr(10) ouroboros = ‘const javaScriptStanza = ’ + backtick + javaScriptStanza + backtick + ‘;’ + newline + ‘const pythonStanza = ’ + backtick + pythonStanza + backtick + ‘;’ + javaScriptStanza print(ouroboros)`; 😃
  • 31. javaScriptStanza = “““ const quote = String.fromCharCode(34); const newline = String.fromCharCode(10); const marker = quote + quote + quote; const ouroboros = ‘javaScriptStanza = ’ + marker + javaScriptStanza + marker + newline + ‘pythonStanza = ’ + marker + pythonStanza + marker + pythonStanza; console.log(ouroboros);””” pythonStanza = “““ backtick = chr(96) newline = chr(10) ouroboros = ‘const javaScriptStanza = ’ + backtick + javaScriptStanza + backtick + ‘;’ + newline + ‘const pythonStanza = ’ + backtick + pythonStanza + backtick + ‘;’ + javaScriptStanza print(ouroboros)””” 😃😃
  • 32. For those interested in replicating this code: https://github.com/gobinaris/serverlessconf-austin-2017 @michael_adda