On 24 Mar 2016, at 22:25, phil@highoctane.be wrote:
The network is the computer.
... and the planet is now overheating.
Internet, the great CO2 production device.
It feels to me that those calculations are always too simple, and wrong as well. Multiplying maximum server power usage times maximum dirty electricity generation CO2 emission gives overstated results. There is a huge drive for lower power consumption (because electricity in a data center is VERY expensive), to move datacenters to cooler areas, to power them with clean, renewable electricity. BTW, it seems that I did not fully understand the story about the left-pad.io library, here is one writeup: Rage-quit: Coder unpublished 17 lines of JavaScript and âbroke the Internetâ Dispute over module name in npm registry became giant headache for developers http://arstechnica.com/information-technology/2016/03/rage-quit-coder-unpubl... Quite interesting & food for thought.
Phil
On Thu, Mar 24, 2016 at 8:58 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote: This is a really great joke:
But should you feel the need to implement this extremely valuable web service yourself, here is how you could do it in Pharo (error handling is not 100% bullet proof, this is just a quick demo, but you get the idea):
'paddin'' oswalt' padLeftTo: 68 with: $@.
(ZnServer startDefaultOn: 8080) onRequestRespond: [ :req | | str len ch | str := req uri queryAt: #str ifAbsent: [ '' ]. len := req uri queryAt: #len ifAbsent: [ '' ]. len := Integer readFrom: len ifFail: [ 0 ]. ch := (req uri queryAt: #ch ifAbsent: [ ' ' ]) first. ZnResponse ok: (ZnEntity text: (str padLeftTo: len with: ch)) ].
ZnClient new host: #localhost; port: 8080; queryAt: #str put: 'paddin'' oswalt'; queryAt: #len put: 68; queryAt: #ch put: $@; get.
$ curl 'http://localhost:8080/?str=paddin%27%20oswalt&len=68&ch=@'
Of course, if you are really going this into production, you'll have to pay me and Pharo the necessary royalties ;-)
Sven
PS: Returning a JSON (which does not really make sense here) is left as an exercise.