JavaScript Utilities 🔧

This is a collection of useful code snippets that I use over and over.

Maybe they're useful to you as well.
Take away 👇
Create a unique string.
Great for quickly creating unique IDs.

👉 gist.github.com/SimonHoiberg/a…
Generate a random number in a range.
If you need to generate a random number between a minimum and maximum value.

👉 gist.github.com/SimonHoiberg/0…
Generate a number range.
It's one of the cool inbuilt utility functions in Python, but unfortunately, we're missing this in JavaScript.

👉 gist.github.com/SimonHoiberg/f…
Get the last item of either an Array, Set, Map or object.
Great for quickly accessing the last item dynamically without having to make any transformation.

👉 gist.github.com/SimonHoiberg/a…
Inserting, replacing, and removing items in a list is one of the things we do over and over.

I have these helpers (in TypeScript) that I use everywhere.

👉 gist.github.com/SimonHoiberg/c…
Create a deep clone of an object.
It does exactly what you would expect - creating a copy of an object, without any pointers to the original object.

👉 gist.github.com/SimonHoiberg/b…
Deep Freeze an object.
If you enjoy working with immutable JavaScript, this utility function is really handy.

👉 gist.github.com/SimonHoiberg/b…
If you've been working with the AWS SDK for Node.js, you probably know that the DynamoDB client returns entries in a quite annoying format.

Use this utility function to unwrap it into a normal-shaped object.

👉 gist.github.com/SimonHoiberg/4…
Sometimes you end up with a lot of Providers in React.
It can make your root component quite nested and hard to read.

Use this utility function to combine a list of Providers into a single Provider.

👉 gist.github.com/SimonHoiberg/8…
Working with async state updates in React often includes a bit of boilerplate.

I created this custom hook to deal with async state.
It optionally supports Recoil atoms as well.

👉 gist.github.com/SimonHoiberg/7…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Simon Høiberg

Simon Høiberg Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @SimonHoiberg

10 Aug
How to start and run an Open-Source project.

Let's take a look 👇🧵
If you have never Open-Sourced a project before, the whole thing might feel very intimidating.

You probably fear what people will say? Will they throw shade at your project? Will it even be noticed at all?

You’re not alone in feeling this way. Believe me!
🔸 Finding a problem to solve

Most popular projects have a clear goal of solving a problem.

There are exceptions, but generally, great Open-Source projects consist of ready-made solutions to a problem that you can easily consume or incorporate into your own software.
Read 20 tweets
5 Aug
3 things we are extremely proud of as SaaS founders:

🔸 We are bootstrapped 💪
🔸 We've been driving sales from day 1
🔸 We had product-market-fit from day 1

How did we do that? 👇🧵
🔸 We are bootstrapped

Even though we generated revenue from the beginning, we were not profitable.

Of course, it costs money to get started.

There are two main reasons why this was possible to us 👇
1. Both my Co-Founder, @SimonGronborg and I are software developers with a lot of experience.

No doubt! When running a SaaS business, paying engineers to build your product will be the biggest expense for a long time!

In our case, we've been able to do that part ourselves.
Read 16 tweets
5 Aug
JavaScript 💡

14 Array Methods that will land you the next job.
Learn and understand what they do and how to use them.

Explanation and examples below 🧵👇
🔸 map

The map() method creates a new array populated with the return value of the callback function for each element in the array.
🔸 forEach

The forEach() method executes a provided function once for each array element.
The callback function does not expect a return value, and the forEach() method itself also returns undefined.
Read 16 tweets
3 Aug
You should start contributing to Open-Source.

Here are 6 ways you can heavily benefit from it.

👇🧵
1️⃣ Become a better developer

Maybe you are still entry-level.
Or maybe you are an experienced developer.

No matter the level, the world of tech is a place where you can (and should) strive to learn something new.

Open-Source allows you to build up skills and become better.
If you are an entry-level or newly graduated junior, you may find yourself stuck in the famous “cannot-get-hired-because-I-don’t-have-experience” deadlock.

Open-Source doesn’t require you to be hired, nor does it require you to have a degree or a resume.
Read 26 tweets
22 Jul
How to make a contribution to an Open-Source Project.

If you are new to this, it may all seem a bit intimidating!

Let me explain the process and give you some tips and best practices.

🧵👇
First of all - why even care about Open-Source?

🔹 Become a better developer
🔹 Become a great collaborator
🔹 Improve the software that you use
🔹 Grow a reputation
🔹 Attract recruiters.
...Just to name a few!

Now that we got that straight - let's get started 👇
🔹 Find a good project to contribute to (1/2)
You want to look for a project that accepts new contributors and is likely to review PRs.

You also want to find a place that has a healthy tone in the discussions and polite and grateful maintainers.
Read 18 tweets
20 Jul
Did you know that FeedHive is built using a fully serverless architecture with monthly server costs of <$10?

This is how we did it 🚀

Learn how to create a Full Stack Serverless Application using React and Amazon Web Services.

🧵👇
First of all - there are many different ways to compose a Serverless Stack application.

With that said, let's start.

Tech Stack:
🔹 DynamoDB
🔹 GraphQL
🔹 AWS Lambda
🔸React
🔸Static hosting in AWS S3

Tools:
🔵 AWS Amplify
🔵 Serverless
🔹 DynamoDB (1/3)

A managed database provided by AWS.

It supports both key-value entries and documents.
That means that a field can contain a single value, such as a string or a number, but can also contain a document, i.e. a JSON-object.
Read 22 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(