I wanted to implement a super simple OTP system to help some of our team members log in more easily (without having to remember a password). I didn’t want to use the legacy system because it was overly complex or include yet another gem.

Be warned: I wouldn’t use this…

I’m surprised this isn’t a more common topic… or maybe I did some very poor Google searches! I was trying to use my Rails backend to generate a PDF and render it in a new tab from my Vue app(without downloading).

In my Rails API controller:

I was using PrawnPDF to create a rendered PDF string, but you can get the same result with something like WickedPDF too.

In VueJS (or any other front-end JS with axios):

(if you want to open the file in a new tab)

If you want to download the file instead, replace link.target = '_blank' with link.download = ‘file.pdf' .

References

https://gist.github.com/javilobo8/097c30a233786be52070986d8cdb1743

Slides from the talk (Things I learned reading and writing production code)

As promised, here are the slides from my talk at the meetup.

P.S. For those who weren’t there: Daniel Goh, my instructor from Alpha Camp, was helping to organize this iteration of the Ruby Meetup in Singapore, and he asked me to give a talk. It’s my first tech talk ever!

Just uploaded a screenshot so there’s a thumbnail for the story

Learning Elixir and Phoenix (A URL Shortener)

Now that I’m done with Alpha Camp (and I’m back from holidays), I finally have time to sit down and write something! So let’s see… I’ll need to work on my Github page to get it somewhat accessible (start with Readmes)… will keep you guys updated on that!

Since Alpha…

Some React work (A React Note-taking app)

8th Jan 2018: Again, finding out I never published this. Incomplete blog post from that week.

Spent a few hours building this! Was really happy when I got it to work. It’s a really simple app, but it was tough because I’m not at all familiar with React.

Oh, and got the pretty form style from https://www.sanwebe.com/2014/08/css-html-forms-designs

Finally! After all those hours of work.

Code:

You can test it out here:

I wasn’t satisfied with it, though, because the code was all mashed up. Redid it here:

Kenneth Teh

Software Engineer primarily working with Rails and Vue.JS... sometimes DevOps and shell stuff too

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store