Best practice for performance for large left-pad jobs is to call the service recursively using mapreduce. Remember that left-pad(str,pad,n) is equal to left-pad(left-pad(str,pad,n/2),left-pad("",pad,n/2),n). This should run in logarithmic time and is highly parallelizable.
If you don't like the "" magic string in there you could replace it with a call to left-pad(null, null,0).
Re:Left-pad as a service
by paulclinger on Thursday March 24, 2016 @01:48PM
(#11354817)
You should be using emptystring.io instead of the "magic string" or a "null, null" hack.
Re:Left-pad as a service
by rkuykendall-com on Thursday March 24, 2016 @02:45PM
(#11355279)
Here you go: https://api.left-pad.io/?len=0
Re:Left-pad as a service
by capitalsigma on Thursday March 24, 2016 @11:22AM
(#11353491)
oh god it's too real
Poe's law for programming culture extremists
if you put https://api.left-pad.io/?len=1017 or anything higher than 1016 it says:
{"errorMessage":"len exceeds 1007 characters. Contact a left-pad.io sales engineer for an enterprise license","errorType":"Error","stackTrace":["exports.handler (/var/task/index.js:33:22)"]}
wow. they even have an enterprise sales engineer! :)
Shouldn't it be leftpad(leftpad (str,pad,n/2),leftpad("",pad,n/2),1)?
Re:Left-pad as a service
by michaelwww on Thursday March 24, 2016 @04:31PM
(#11356171)
You can get right-pad today by using starboard-pad, which is heavily optimized for marine applications and comes with an open seas license.
Can we also get a containerized on-premise version of this service? We'd like the ability to spin up a couple of these behind a load balancer to let us achieve web-scale.
Re:Left-pad as a service
by richerlariviere on Thursday March 24, 2016 @01:44PM
(#11354770)
This is why I love Hacker News
What kind of load balancing is being used on the back-end? I called leftpad(str, ch, len) with the length I needed and noticed that is not very scalable because it is blocking.
A better approach I would recommend to those using it is to call the API in a for loop. In my tests, it had performance very close to those I see in C or assembly.
I was a bit turned off that the free version can only handle strings up to 1024 in length. I know you need to make some money, but it is big turn off for a lot of my projects.
Edit: I finally signed up for it but still noticed that I am only allowed to use 1024. I called your customer support line and they said I was calling the API from multiple IP addresses and for that I need an enterprise license. Please help me with this issue, it is very crucial at this point as my project is in a complete stop because of this.