Ynon Perek

49 posts

Writing a Secure Encrypted Chat in Python

When using a stream ciphers to pass encrypted messages to the other, there are some potential traps that we should look out for. Let's explore them and then move on to a demo chat application. Key Storage The first question is where do you store the key. Modern (mobile) platforms provide a secure key storage as part of the operating system. Desktop and server OS still don't. These are the requirements we need to consider: It should be easy to change keys periodically. It should be

Read more

How Microservices Saved My Small SaaS Business

I've been reading a lot about microservices lately and how they're hard to implement. For a long time I was also very much against the architectural complexity they bring. Until I realized that for a single developer maintaining a monolith, microservices gave me something no other architecture could. Problems Maintaining a Monolith My framework of choice is Rails with React and Redux for the client. This is a great choice when you consider how fast you can implement new features and how easy it is to

Read more

Quick Tip: Using Memoization To Speed Up Recursive Functions

A recent visit to hackerrank reminded me of a nice trick to make our recursive functions run faster - and it's called memoization. The Question A hackerrank question asked to find the number of ways a child can climb a staircase in a given height, provided that child can climb 1, 2 or 3 stairs at a time. A recursive solution in Python easy to write: import sys def ways(n): if n < 0: return 0 if n == 0: return 1 return ways(n-1) + ways(

Read more

Embedding discourse comments in a React Single Page App

Discourse provides a simple way to embed a topic's posts in another website as comments. Problem was it didn't work for my React single page app. Here's how I fixed it What Went Wrong The recommendation on discourse site is to use the following code to embed the comments: <div id='discourse-comments'></div> <script type="text/javascript"> DiscourseEmbed = { discourseUrl: 'http://discourse.example.com/', discourseEmbedUrl: 'http://example.com/blog/entry-123.html' }; (function() { var d = document.createElement('script'); d.

Read more

Simple Question Editor CSS

Writing some code to allow users to add quizzes to a site led me to styling a simple multiple choice question editor. The Result Here's the result from codepen: See the Pen rpzxMd by Ynon Perek (@ynonp) on CodePen. UI is not that pretty and JavaScript still not included, but it's a starter and you may find it useful for your projects too.

Read more