Spicy Blog
We're the Spicy Sea Shells and this is our blog.
Who are we? We are a collective of software developers, business analysts and quality analysts who met on a training course by ThoughtWorks
Latest
Setting up Storybook for React Native
Storybook is a tool for documenting a design system and developing modular apps. It is popular in the web development community and I've used it in all my bigger projects. So when I transitioned from web development to working on a React Native codebase, I set up Storybook too. Here's how I did it: If you install Storybook using the built in initializer, it will do most of the setup work for you. In the root directory of your project run When you get asked if you want to install the storybook server, type yes. The server will show your story tree in a web UI but won't actually show you the rendered components. It's very handy for navigating the stories though when you amass enough of them. If you use TypeScript, don't forget to install the types and convert all files: If everything went well, your folder structure should look like this: (Assuming you use TypeScript) The export coming from storybook/index.tsx is a simple React component. This means you can render it like you would any other component. The simplest way to show the UI in your simulator is by mounting it instead of the actual app. That would mean changing the root index.js like so:
Introduction to Golang [Part I]
Working for one of the clients here at ThoughtWorks, I found myself working a lot on Golang. Go has been a great language to work on but it never felt that way the first time I started on it. To begin with, it has a strange syntax, as opposed to most other strongly typed languages. The Golang tour is a great place to start with. Over the next few articles, I will walk you through the basic Setup and CRUD operations in Golang using PostgreSQL database. You can find the repository here. As part of this project, I will be using Mux as a request router and dispatcher for matching incoming requests to their respective handler. Let's start with /ping, the basic health-check route. There you go. You have your Golang server up and running, ready to serve more requests. In the next article, I will demonstrate the usage of .yml files in Golang.
How to add SSR to a CRA
Oh God, I feel so millennial with this title, oh wait This article is heavily inspired by this one. The idea behind creating a new tutorial is to explain step by step, error by error. If you wanna a more quick/intermediate tutorial, I highly recommend going directly here. Alright then. Firstly, what is SSR and why would someone want to add that to a Create React App. SSR: Server side rendering is a good way to delivery HTML faster to ur clients and also have good SEO. CRA: Create react app is a tool to create react apps without wasting time configuring stuff. Ok, now you should have your CRA up and running, it's time to add SSR to it, so as obvious as it seems we need a server in our application (you didn't see that coming huh?)
Mocking stdin, stderr and stdout for python unittest
Working on my latest project, todoster, forced me to learn all about input/output mocking using python's built-in unittest library. The way I've been using the mock output or error stream is by getting its contents as a string. For this, there is a very simple method: With this string you can do assertions as normal. However, since mock_err and mock_output aren't actually strings but streams you need to be very careful when trying to use the same stream a second time. The streams don't get cleared automatically so you need to either re-declare the mocks or make sure they're manually cleared out before every re-use. If you want to have one mock for one test case (class) just make sure you're resetting mock_out and mock_err after every test like so: On the other hand, you can mock on a test by test basis by using decorators like so: Now you don't have to worry about clearing out the mocks after every test but it does come with having to add a new decorator for every test method that needs the mock.
