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 👇 Image
Create a unique string.
Great for quickly creating unique IDs.

👉 gist.github.com/SimonHoiberg/a… Image
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… Image
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… Image
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… Image
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… Image
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… Image
Deep Freeze an object.
If you enjoy working with immutable JavaScript, this utility function is really handy.

👉 gist.github.com/SimonHoiberg/b… Image
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… Image
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… Image
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… Image

• • •

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

20 Jan
Most in-demand Front End Frameworks in 2020.
You want to bet on these:

⭐ React
⭐ Vue.js
⭐ Angular
⭐ Preact
⭐ Ember
⭐ Svelte

Which one do you like the most? Image
⭐ React

A declarative JavaScript library for building user interfaces.

Currently the most popular in the world.

reactjs.org
⭐ Vue.js

The Progressive JavaScript Framework.
It's been exploding in popularity in recent years.

vuejs.org
Read 7 tweets
20 Jan
FeedHive insights ⚡

Done:
✅ Authentication
✅ Analytics
✅ Chat client
✅ All major features for the beta

Coming up:
⬜ Payment setup
⬜ Bugfixes / making stable
⬜ Writing more tests

Let me share some more details 🧵👇
I started developing FeedHive in early September 2020.

For a long time, it was just a few Lambda's and a small CLI to handle scheduling.

I wrote my tweets in YML files.
Very homemade 😅

I started developing the official FeedHive App in December 2020.
An integral part of the back end is the Twitter API Client I started writing during this time.

It's handling all communication between FeedHive and Twitter.

The client is written in Node.js and TypeScript.
It's Open-Source 👇

github.com/FeedHive/twitt…
Read 10 tweets
14 Jan
Why should you start your own business instead of becoming an employee?

Well, being a business owner isn't for everyone.
But it may be exactly the change you need!

Let me give you some great reasons to quit your job and become self-employed.

🧵👇
1️⃣ You become free and independent

You get the ability to steer the direction of your life in any way you want, instead of working for the whims of others.

You also get to manage your own time and schedule.
Who wants to ask for permission to spend time with your loved ones?
2️⃣ You get to follow your passion

In your own business, you get to do what excites you.
Not only does a passion make your job fulfilling, but it also unlocks hidden powers in you!

Why do you work?

❌ Because my boss wants this done by tomorrow.
✅ Because I love what I do!
Read 9 tweets
12 Jan
JavaScript Testing 🔧

Here are 6 awesome frameworks and utilities to test your JavaScript code.

1️⃣ Jest
2️⃣ Mocha
3️⃣ Jasmine
4️⃣ Enzyme
5️⃣ Protractor
6️⃣ Cypress

🧵👇
1️⃣ Jest

By far the most popular general-purpose JavaScript Testing Framework.
Works for most projects, most frameworks, and libraries and has great support for TypeScript and Babel.

jestjs.io
2️⃣ Mocha

Mocha is another popular choice for general-purpose testing in JavaScript and Node.js applications.

mochajs.org
Read 7 tweets
17 Dec 20
Looking for your dream job in tech?

Use these tips to catch the attention of the tech recruiters.

👇🧵
🔸Have a great LinkedIn profile

Your LinkedIn profile is probably the most important asset for your career.

This is typically going to be the first impression the recruiters get from you, so make sure it stands out GREAT!

Here are so tips on how to improve it 👇
🔹 Have a great profile image

Make sure to have a great profile image:
- Look professional
- Clean background
- Great lighting

You can use this service to analyze the quality of your LinkedIn image.
snappr.com/photo-analyzer/
Read 18 tweets
16 Dec 20
Working with regex can be tedious and frustrating.
But we still need to do it, every now and then.

Here are 5 GREAT online tools to make your life a little easier:

🔹regex101
🔹regexr
🔹regextester
🔹regexpal
🔹myregexp
🔹regex101
regex101.com
🔹regexr
regexr.com
Read 6 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!