teleren/devto huggingface dataset:
Client-side data storage with IndexedDB
Tags: webdev, javascript, beginners, database
Published: 2023-10-01 05:45:00

IndexedDB is a well sophisticated database for persisting data in a user's browser.
Although, there are other storage options like localStorage or Cookies, they are rather limited and cannot handle complex data types.

In this article, we'll delve into what IndexedDB is and its key features, so get ready to learn something new today.

What is IndexedDB?

IndexedDB is a client side database for 
storing data directly in the the browser. It is based on the same origin policy, meaning that web pages of different domains cannot access the same IndexedDB database.

An IndexedDB Database is simply a collection of object stores.

So called object stores as their name implies are the storage of IndexedDB. It is where the actual data is stored. An IndexedDB database may have multiple object stores.

An object store holds records which are key 🗝️-value pairs. The keys of an object store can be a string, date, float, a binary blob, or an array.

Objects that can be stored must support the structured clone algorithm.

Haven't heard of the structured clone algorithm 🤔?

The structured clone algorithm is a mechanism that JavaScript engines use when copying objects using certain APIs. These objects can be arrays, maps, sets, objects and other built-in JavaScript data types (with the exception of functions, DOM nodes and Error objects).

The IndexedDB API uses many requests for its operation. What do I mean?

An IndexedDB API usage can happen in these steps: 

- You send a request to open a connection to the database. This request can either fail or succeed, so you can add event listeners 👂 to the success event.

- Inside the success event handler, you create a transaction, get an object store from the transaction, then add or delete data to the object store. 

Note: every attempt to add, delete or update data in an IndexedDB database object store must be wrapped 🎁 in a transaction 😲.

Now, what is a transaction? 

A transaction is a group of operations to be performed on a database that should either all succeed or all fail. If you’re doing a lot of writes to an object store, it’s much faster if they happen in one transaction.

This is just the surface level of the IndexedDB API ad want it can do. 

If you would like me to explain more about IndexedDB and other client-side storage options, you can tell me in the comments.

Image credits: [Matt Anderson](https://dribbble.com/mattandersondesign)


Do like 👍 and follow 🏃 for more content.
Job Automation Process
Tags: webdev, programming, api, job
Published: 2023-10-01 05:43:13

## Job Automation Process
Why even apply, send an email, find a company, or simply automate this process, right?

Well, layoffs are still on the way and it's expected that till 2024 recession will exist.

How to find a job is a bit tricky task, so here is the cool way

I found this API call jobsdataapi, https://jobdataapi.com/

This basically gives all the available jobs in one go.
That is so cool but the API is not free, so you can use the test version and simply fetch the top trending remote jobs to find the matched one #jugaad has to be there 😁

Or you can use Chat GPT and the scraping algorithm to scrap the available jobs from the Application Tracking System, if you know nothing about it, simply use Chat GPT to learn and understand.

All the top companies use this tool in the hiring process and we can too use to fetch all the available jobs in the world.

Following this, we can use Chat GPT to even write emails for us for each of the job posts hence automating the entire job automation process.

I've created a video around this process, feel free to watch it.
[https://lnkd.in/dYQKgGgJ](https://lnkd.in/dYQKgGgJ)

Keep developing
Shrey
[iHateReading](ihatereading.in)
WATCH THE LIVE STREAM EITHER ON PIKASHOW
Published: 2023-10-01 05:33:51

When it comes to enjoying live streams of your favorite shows and movies, you have a couple of options, whether on Pikashow or Amazon Prime. For those looking for an alternative platform, Pikashow offers a convenient solution by providing the latest movies, tv shows, etc, in HD. With the Pikashow APK download, users can access diverse content, including live streams, movies, TV series, and more. 
**[Click](https://quirkyquillsq.blogspot.com/watch-live-stream-either-on-pikashow)**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2fvbklwjjbipkxokf1lm.jpg)
Optimizing Image Loading for Lightning-Fast Performance in NEXT.js
Tags: react, nextjs, javascript, webdev
Published: 2023-10-01 05:26:17

Hey there, fellow developers! 👋

I wanted to share some tips and techniques for speeding up image loading in your Next.js applications. Images play a crucial role in web performance, and optimizing their delivery can significantly enhance user experience. So, let's dive right in!

1. **Use the next/image Component**

Next.js provides a fantastic next/image component that makes it a breeze to optimize image loading. It automatically generates multiple image sizes and formats, serving the most suitable one based on the user's device and screen size. Here's how you can use it:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45lwg7nm44oqmkma9ria.png)

2. **Implement Lazy Loading**

Lazy loading is a technique that defers loading of offscreen images until the user is likely to scroll to them. You can enable this feature by adding the loading="lazy" attribute to your next/image component or regular img tag:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8fjbh53qwqybtrxm9kr.png)

3. **Image Optimization with Next.js**

Next.js provides automatic image optimization through the next/image component. Make sure to configure the domains array in your next.config.js to specify which domains should be optimized. For example:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/147jfazw79t9385ziafg.png)

4. **Use the WebP Format**

WebP is a highly efficient image format that provides excellent compression and quality. You can use it by specifying the layout attribute as "fill" in your next/image component. Next.js will automatically generate WebP images for modern browsers:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bbyoe5e7t02yk0rr776.png)


5. **Serve Images from a CDN**

Consider serving your images from a Content Delivery Network (CDN) for improved loading speed and reliability. CDNs can cache and distribute your images globally, reducing latency for users around the world.

6. **Compress and Optimize Images**

Before uploading images to your server or CDN, make sure they are properly compressed and optimized for the web. Tools like ImageMagick, TinyPNG, and Squoosh can help you reduce image file sizes without sacrificing quality.

7. **Enable Browser Caching**

Leverage browser caching to store images locally on users' devices. This reduces the need to re-download images on subsequent visits, improving page load times.

By implementing these best practices, you can ensure that images load lightning-fast in your Next.js application, enhancing both performance and user experience. Feel free to share your thoughts, questions, or additional tips below! Happy coding! 😊✨
Start Your Journey to Wealth with CapitalKing.co's Comprehensive Coaching Courses!
Tags: career, ai, news, community
Published: 2023-10-01 04:49:43

Embark on a transformative journey with [CapitalKing.co](url)'s coaching courses. Our experienced coaches will guide you through the intricacies of wealth creation, helping you develop a winning financial strategy tailored to your goals and aspirations.
Unlock Financial Freedom with CapitalKing.co: Join Our 100 Wealth Creation Courses and Coaching Programs!
Published: 2023-10-01 04:48:17

Are you ready to take control of your financial future? CapitalKing.co offers a comprehensive range of 100 modern wealth creation courses and coaching programs designed to empower you on your journey to financial freedom. Whether you're a beginner or a seasoned investor, we have the resources you need to succeed.
TailwindCss e PHP rola?
Tags: tailwindcss, php, frontend, backend
Published: 2023-09-30 17:53:37

Ultimamente tenho utilizado muito o tailwind para projetos de front-end, por ser mais prático (para mim), só que agora comecei um projeto simples em PHP e resolvi usar o tailwind também, enquanto estava só no front com o html e Js, estava indo bem, mas quando comecei a criar os arquivos PHP me deparei com um problema: o css não estava sendo entregue ao navegador na hora de rodar, até consegui mexer, resolveu uma parte, mas outra que recebia uma tabela continuou com a configuração do navegador e não a do framework. 

Como sou iniciante queria saber dos mais experientes na linguagem e no frame se realmente dá problema de compatibilidade, ou se é configuração do localhost.

- Uso o xampp, mas testei no wamp e ficou pior ainda rs; 
- Sistemas só front-end e fora do servidor roda bem;
- Ele já estava rodando no servidor normalmente, só foi começar implementar o PHP que começou a gerar problemas;
- Já fiz limpeza de cache, revi o código, procurei por erros e parece tudo normal, apenas o navegador parou de receber;
- Testei em mais de um navegador.
207. Course Schedule
Tags: leetcode, medium
Published: 2023-10-01 03:55:00

Problem: [207. Course Schedule](https://leetcode.com/problems/course-schedule/description/)

<strong>Implementation:</strong>

```java
/**
What makes the code return false:
- cannot take the class. why?
- there is a cycle. need a for b but then need b for a. like a deadlock => false. 

This looks like a graph. => just need to determine if there is a cycle. 
- we can use BFS for this. Keep traversing until reaching the end. While at the end, make sure to also utilize DP to keep track whether all courses could be taken succesfully

Steps:
1. Establish the mapping representing the courses relationship. If a needs b, c, d then:
{
    a: list(b, c, d, ...)
}

2. Start BFS: on all key:
    DP map: Map<String, Boolean> map 

    for all keys in map: call could_take(key, new HashSet<>())

    could take a?, visited: Set<String>:
        if key in dpMap: return dpMap.get(key)
        else if a not in the map:
            dpMap.put(key, true)
        else if key in visited:
            return false;
        else: 
            can = true?
            visited.add(can)
            for prere in map.get(a):
                can_prere = could take prereq(prere, visited)
                if !can_prere:
                    can = false
                    break
            dpMap.put(key, can);
        return dpMap.get(key);

3. At the end:
    loop through all keys in DP, if there is a course that could not be taken, return false.
*/
```

```java
class Solution {
    Map<Integer, Boolean> dpMap;
    Map<Integer, Set<Integer>> map;

    public boolean couldTake(int course, Set<Integer> visited) {
        if (dpMap.containsKey(course)) {
            return dpMap.get(course);
        } else if (!map.containsKey(course)) {
            dpMap.put(course, true);
        } else if (visited.contains(course)) {
            dpMap.put(course, false);
        } else {
            boolean possible = true;
            visited.add(course);
            for (int pre: map.get(course)) {
                if (!couldTake(pre, visited)) {
                    possible = false;
                    break;
                }
            }
            dpMap.put(course, possible);
        }
        return dpMap.get(course);
    }

    public boolean canFinish(int numCourses, int[][] prerequisites) {
        this.dpMap = new HashMap<>();
        this.map = new HashMap<>();

        // create the mapping
        for (int[] pre: prerequisites) {
            int first = pre[0];
            int second = pre[1];
            // take second before first
            this.map.putIfAbsent(first, new HashSet<>());
            this.map.get(first).add(second);
        }

        // calling could take on all course in map:
        for (int course: this.map.keySet()) {
            boolean possible = couldTake(course, new HashSet<>());
            if (!possible) {
                return false;
            }
        }

        return true;
    }
}
```
Designs are ready Hacktoberfest 2023 with design2code2live
Tags: hacktoberfest23, hacktoberfest, webdeveloper, webdev
Published: 2023-10-01 03:44:25

---
title: Designs are ready Hacktoberfest 2023 with design2code2live
published: true
description: Hacktoberfest 2023 with design2code2live
tags: hacktoberfest23, hacktoberfest, webdeveloper, webdev
cover_image: https://miro.medium.com/v2/resize:fit:640/format:webp/1*egrQcgTNGHfWLSXdjmPzGg.png
# Use a ratio of 100:42 for best results.
# published_at: 2023-09-27 13:57 +0000
---

A hearty welcome to each and every one of you as we step into Hacktoberfest 2023 👏

Introducing design2code2live, our open-source repository where I share designs and our incredible contributors bring them to life using HTML, CSS, and JavaScript.


![designs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f314iewjjan8g0fqct6e.png)

More 20 designs are coming today by EOD


Join the discord server to be notified when the designs are available and also about the event. https://discord.gg/C3PAvsmrKV

And now, let’s talk about the exciting swag! Based on your contributions, we’ll be sending you a digital sticker — a super cool one at that!

reward

1 PR Merged: Level 1 Sticker
2 PRs Merged: Level 2 Sticker
4 PRs Merged: Level 3 Sticker
5 PRs Merged: Level 4 Sticker
6+ PRs Merged: PRO Level Sticker

All the stickers are digital and will be mailed after the event ends

Designs are in progress. Will keep you posted about the designs on my Twitter — https://twitter.com/@AravindkumarV09.
Ruby's main object
Tags: ruby, oop
Published: 2023-10-01 03:20:19

---
title: Ruby's main object
published: true
description: Ruby's main object, top-level methods.
tags: ruby, oop
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-09-30 13:30 +0000
---

In Java, every function must be wrapped by a class, but in Ruby, we can define a function without classes. Therefore, some years ago I used to suppose that:
> There are no functions in Java, only methods. But for Ruby, we can have a function that isn't a method.     
 
However, these days I have realized that: "Every function in Ruby is also a method".  
But why can we define the function at the top-level scope, without creating classes for them, like Java? Or which class does this function belong to?

For example, I have the function `increment`
```ruby
def increment(num)
  num + 1
end
```
We try to call `increment` this way:
``` ruby
self.increment 10
# or
self.send(:increment, 10)
```
Since `self` keyword contains a reference to the current object, the receiver for the current method, `increment` must be a method. Now let's check which object `self` reference to.
```ruby
puts self
# => main
puts self.class
# => Object
```
You can see puts `self` code returns string "main", and it is an instance of `Object`,  the root class of Ruby’s class hierarchy. So we can conclude that  `increment` is an instance method in the `Object` class. 
Technically speaking, Ruby automatically creates a `main` object as the top self object, it is the default receiver for top-level methods. Actually, all Ruby functions are private methods of `Object`.
``` ruby
p Object.private_instance_methods
# [:increment, :DelegateClass, :sprintf, ...]
```

## Conclusion
- Every function in Ruby is also a method. It's an instance method of `Object` class.
- Ruby `main` object allows you to write simple functions and, at the same time, ensure sophisticated OO design.
Finding the right macOS `defaults` command
Tags: macos, shell, productivity, terminal
Published: 2023-10-01 01:40:25

[Automating the setup of a clean macOS install](https://santisbon.github.io/reference/automated/) is a lot easier when you know which keys to edit via the `defaults` command. Since there's no official listing of all the keys, there are places online that give you the most commonly used ones and try to stay up to date with the names of the keys in the latest release of macOS, with varying degrees of success. The best way is to grab the correct names directly from your Mac. 

Note: First, make sure your terminal has *Full Disk Access* in *System Settings > Privacy and Security*.

The format to edit your macOS preferences is
`defaults write $DOMAIN $KEY -$TYPE $VALUE`

And you can list all the domains with
`defaults domains | tr ', ' '\n'`

You can figure out the correct domain and key names by comparing the output of `defaults read` *before* and *after* manually changing a setting in the UI. You can also specify a domain to narrow down the output but it's not required so don't worry if you're not sure which domain is affected by the setting you're interested in. Remember to kill any affected apps to apply the changes.

Example:
```sh
defaults read com.apple.finder > before.txt
# Change Finder Settings in the UI
# to clear "Show warning before changing an extension" 
defaults read com.apple.finder > after.txt
diff before.txt after.txt
# <     FXEnableExtensionChangeWarning = 1;
# ---
# >     FXEnableExtensionChangeWarning = 0;
```
Now check the type and you got a command you can add to any automation you wish.
```sh
defaults read-type com.apple.finder FXEnableExtensionChangeWarning
# Type is boolean
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
killall Finder 2> /dev/null
```

If you can't find a key where you expected it, remove the domain from your query or check the global domain. This one affects Finder but it's in the global domain instead of `com.apple.finder`. Other ways to specify the global domain are `-g`, `-globalDomain`, and `NSGlobalDomain`.
```sh
defaults read "Apple Global Domain" AppleShowAllExtensions
# 1
defaults read-type "Apple Global Domain" AppleShowAllExtensions
# Type is boolean
```

Other commands to try:
```sh
defaults help
defaults find $WORD
defaults read com.apple.dock | grep wvous # Hot Corners
```

Want an example of a setup script? Check out [mine](https://github.com/santisbon/dotfiles/blob/main/macos-defaults.sh).
How to use Tailwind CSS without Node
Tags: tailwindcss, webdev, tutorial
Published: 2023-10-01 01:39:27

Tailwind CSS continues to grow in popularity as it's a framework which allows you to create beautiful websites without needing to write a single line of CSS, while also not making your website look like a template (looking at you Bootstrap websites).

When you go to install tailwind inside your project, the first command you'll come across is `npm install -D tailwindcss`. This is fine if your frontend is a single-page application (SPA) or your backend is in Node.js. However, what if you are using server-side rendering (SSR) for the frontend and your backend is in Laravel, Django, or ASP.NET? One solution is to place the Tailwind CDN script in the head of your HTML. The problem with this is it forces the user to download every single CSS class in Tailwind instead of only the ones actually being used.

This is where the [Tailwind standalone CLI](https://tailwindcss.com/blog/standalone-cli) tool helps. The CLI tool gives you all the benefits of using the npm Tailwind package, such as only bundling the classes you are actively using in your website, but without having to install Node in your project.

I'm sure most of you can figure out how to get the CLI tool setup in your project based on the instructions in the link above, but if you need the extra help:

1. Go to the [Tailwind GitHub](https://github.com/tailwindlabs/tailwindcss/releases) and download the version of the CLI executable which matches the system you are running
2. Place the executable in your project and rename it to `tailwindcss` (not necessary but will mean the following steps will work for everyone)
3. Add `tailwindcss` to your .gitignore (if you are using git)
4. Run the command `./tailwindcss init` and modify `content: []` so it knows which directories to look in for Tailwind classes
5. Create a CSS file called `input.css` and place it wherever you will store your static files
6. In this CSS file add these three lines
    1. `@tailwind base;`
    2. `@tailwind components;`
    3. `@tailwind utilities;`
7. To use Tailwind and have it automatically compile the classes you use, run this command `./tailwind -i ./path/to/static/files/input.css -o ./path/to/static/files/output.css --watch`
8. output.css is the CSS file you will use in your website so add it to your HTML
9. If you want to send an optimised version of your CSS file to your users, run this command `./tailwind -i ./path/to/static/files/input.css -o ./path/to/static/files/output.css --minify`

As a framework, Tailwind CSS provides a great deal of freedom for you to design your websites the way you want them, while making it easy for you to do so. If you have been avoiding using Tailwind because of needing to install Node, I hope this tutorial has helped you in getting it setup in your project.🙂
<=60s - Big O Notation
Tags: computerscience, algorithms
Published: 2023-10-01 01:00:55

## Introduction
Big O notation is a crucial concept in computer science and programming. It helps us analyze the efficiency of algorithms and understand how their performance scales with input size. In under 60 seconds, let's dive into why it's essential.

## Why Big O Notation?
Big O notation provides a standardized way to describe the upper bound of an algorithm's time or space complexity. This allows us to compare algorithms objectively and choose the most efficient one for a specific task. Whether you're optimizing code for a small personal project or working on a massive software application, understanding Big O can save you time and resources.

For example, if you know an algorithm is O(n) (linear time complexity), you can expect it to handle larger inputs more efficiently than an O(n^2) (quadratic time complexity) algorithm.

## Conclusion
In the fast-paced world of programming, every second counts. Learning Big O notation might take a few minutes, but it can lead to significant time and resource savings in the long run. So, invest a little time now to make your code more efficient later.
<=60s - C#
Tags: csharp, programming
Published: 2023-10-01 00:49:55

## Introduction:
C# is a versatile and powerful programming language that allows developers to create a wide range of applications, from desktop software to web and mobile apps. In this quick guide, we'll explore some essential C# syntax and why it's a great language to learn.

## Syntax:
1. Variables:
   ```csharp
   int age = 30;
   string name = "John";
   ```

2. Comments:
   ```csharp
   // This is a single-line comment

   /*
   This is a
   multi-line comment
   */
   ```

3. Console Output:
   ```csharp
   Console.WriteLine("Hello, C#!");
   ```

4. Conditional Statements:
   ```csharp
   if (age >= 18)
   {
       Console.WriteLine("You are an adult.");
   }
   ```

## Why C#?
C# is known for its simplicity, strong type system, and vast libraries, making it ideal for both beginners and experienced developers. It offers seamless integration with Windows applications and is used in game development through Unity.

## Conclusion:
C# is a language that empowers developers to create robust and efficient software quickly. Its clean syntax and extensive support make it an excellent choice for any project, whether you're just getting started or a seasoned pro. Start your C# journey today and unlock a world of programming possibilities in <=60s!