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.
The network is the computer. ... and the planet is now overheating. Internet, the great CO2 production device. http://www.internetlivestats.com/watch/co2-emissions/ 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.
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.
Hi, On 25/03/16 06:55, Sven Van Caekenberghe wrote:
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.
Thanks for the link. A cautionary tale on how we have become dependent on few centralized points (and the irony that that was what Internet was trying to prevent). Cheers, Offray
2016-03-25 8:55 GMT-03:00 Sven Van Caekenberghe <sven@stfx.eu>:
On 24 Mar 2016, at 22:25, phil@highoctane.be wrote: Internet, the great CO2 production device. http://www.internetlivestats.com/watch/co2-emissions/
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.
Ask bitcoin miners about getting efficient computing. :)
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.
It's interesting, and that's a difference with Debian's apt-get; while npm is both the tool and, mostly, an unique the registry, apt-get decouples that so you can have your custom deb sources. Pharo way of dealing with dependencies is good, but we lack the packaging system and convenient CLI. Dale's tODE is a good example of something done in that direction. Regards, Esteban A. Maringolo
participants (4)
-
Esteban A. Maringolo -
Offray Vladimir Luna Cárdenas -
phil@highoctane.be -
Sven Van Caekenberghe