teleren/devto huggingface dataset:
Representing Graphs: Adjacency List
Tags: beginners, learning, tutorial
Published: 2024-01-13 18:33:48

We went through Adjacency matrix in the last post and understood how they work and why they are not really a viable solution in many places. However in this post we will discuss the better alternative: Adjacency lists 

## Adjacency List
Adjacency list use a HashMap, and if you don't know what that is let me give you a quick run down. A HashMap is an array where each element stores two things a key and a value. The position of the value in the array is determined by the key, as it is fed to a hashing algorithm to get a index number, which is where the key and the value is stored. 

Now that we know what a HashMap is we can continue with adjacency lists. When we store a node in an adjacency list we have to input three things, the source node, the destination node, and the weight(if the graph is weighted). The source node is what you use as your key value. Now is where it gets interesting, instead of a value we store a list in that position. In this list we store pairs of destination nodes and weights. Thus we can represent which node connects to which and what weight this edge holds. 

A simple example is (credit to GeeksForGeeks for the image):

![adjacency list](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90cyo3ro1uhj6zr4zjbs.png)

## Advantages and disadvantages 
Advantages of this method include saving space on graphs with not too many connections, it also makes adding new nodes and connections much easier and can be used to represent undirected and directed graphs. 

Disadvantages include the fact that for large graphs with many connections it is going to take more memory than an adjacency matrix, and also it takes longer in an adjacency matrix to access and edge. 

## Conclusion
While most of the time an adjacency list is preferred because of how easy it to expand and shrink it, and how it also saves you space. There are also some cases where a matrix would make more sense because of the disadvantages listed above.

Thank you for reading, I do hope you found the article informative and useful.
🚀 Kickstart: the fastest way to setup your JS projects!
Tags: javascript, webdev, node, tooling
Published: 2024-01-13 19:33:36


![Kickstart demonstration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16t0slt1ea4ksl2oh9j0.gif)

Picture this: you just had a new project idea and you are to buzzing with ideas and ready to code. 

But then, before the actual good coding, you have to configure ESLint and Prettier, hook up Husky, add your testing framework, and so on.

Hours slip by, and you're still not writing the code for the project itself. **Sound familiar?**

Here comes **🚀 Kickstart** - a CLI tool designed to _turn these hours into seconds!_

----

**In less than a minute and just answering questions, you're able to setup:**

✍️ Linters (ESLint or StandardJS), formatter (Prettier)
🎨 CSS frameworks (Tailwind, Sass or Material UI)
🧪 Unit testing (Jest or Jasmine)
🖥️ E2E testing (Cypress or Playwright)
🐶 Husky, lint-staged 
📝 README, CHANGELOG, .gitignore

## How to use it?

**🚀 Kickstart** is a NPM package that you run in the CLI. So to install it just run:

```sh
npm install -g kickstart-it
```

In a new folder, run the command: 
```
kickstart-it
```

Then you just have to answer the questions and your project will be quickly set up!

After you run **🚀 Kickstart** once, you're able to save a `config.json` file of what you picked.

That way you can skip answering questions next time, and just go straight to the setup.

Please check the [README](https://github.com/danilovilhena/kickstart-it) to see available flags and config options.

## Can I contribute to 🚀 Kickstart?

Absolutely! It's an open source, and I greatly appreciate contributions from anyone! So report bugs, suggest new features and open pull requests to improve the current code!

---

I hope you give **🚀 Kickstart** a chance and try it out in your next project!

If you do, please give me some feedback, so the tool can improve even further.

Thanks for reading! Have an excellent day 👋
Housing crisis and how to reduce risk
Published: 2024-01-13 19:12:21

Many of the middle to lower class suffer the consequences of a housing crisis. What causes this? It is said that due to inflation the volatility of pricing on the housing market can fluctuate depending on one sole factor, the Federal Reserve. To create an equilibrium of ease, T-bills a.k.a Treasury bills, also Treasury Securities can be purchased. These are considered investments. 

Taxes are a certainty regardless of where anyone stands financially, so the yield return of investment referring to the capital gain received will be taxed. Tips (Treasury Inflation-Protected Securities) creates a fixed rate on the original principle which helps protect your investment risk to a minimum depending on how high or low inflation stands. The U.S. department of Treasury sells these bonds directly with no hidden fees, or they can be purchased in the secondary market which require a fee per purchase. 

In good faith, these bonds are purchased to help prevent inflation from rising. The up-side, interest rates decrease on housing and other governmental-economical issues can subside reducing risk. The down-side interest rates rise on housing and inflation continues to increase. 

Sources:
https://home.treasury.gov/resource-center
https://www.fidelity.com/fixed-income-bonds/individual-bonds/us-treasury-bonds
https://www.treasurydirect.gov/forms/sec0011.pdf
Objects have Class
Tags: codenewbie, oop, ruby
Published: 2021-02-25 21:25:53

---
title: Objects have Class
published: true
date: 2018-02-19 22:48:54 UTC
tags: #codenewbie #OOP #ruby
canonical_url: https://coding-adventures.com/objects_have_class
---

It was mostly smooth sailing for me in my coding adventure until I hit the subject of Object Oriented Programming (“OOP”) in Ruby (so I really didn’t go very far before this first road block). I read the text of the lessons until all these getters, setters, classes and objects were all jumbled up in my head and life did not make sense anymore.

I just had to take a little break from the lessons for a few days and, instead, read some other resources online. I have to admit, at first none of them made sense either, but writing some concepts down in my own words really helped and I started to see a glimmer of light at the end of the OOP tunnel.

So what I figured out is that a Class is really just a blueprint for creating a base version of a Thing. All of the attributes of the Thing can be found within its Class and we can add more attributes by defining new methods within our Class. This means that every new Thing is “born” with a set of predefined, standard attributes. I think this is pretty neat because all you have to do is decide what you want your Things to look like and how they should behave and then every new Thing will act exactly as you expect it to. A standard name for a Thing is an Object; so all of the attributes of an Object are stored within its Class.

I was very happy once I understood that Classes are just blueprints and that really everything in Ruby is an Object. Then came instance variables. These are nifty little things; I’m a big fan of instance variables. A local variable defined within one method cannot be accessed by another method. You get around this by prefacing the variable name with @ symbol. That’s it! You’ve got yourself an instance variable that can be accessed by all methods within you Class.

Setter and getter methods were most difficult for me to understand. I just could not comprehend why you would need two methods to get a Thing to do something. [This](http://instruction.learn.co/student/video_lectures#/231) video lecture helped big time! I had to understand that I am really defining two completely different methods, one would be a name method, for example, and another would be name= (name equals) method. The name method is the getter or reader method, it simply returns information stored in the instance variable. The name= method is the setter or writer method, this is the method that can change information stored in the instance variable. Once I understood the difference between getter and setter methods things became a lot clearer!

It may have taken a while, but I finally had a decent grasp on Object Oriented Programming. It was time to apply my newfound skills and rewrite my Tic Tac Toe using OOP. Boy did that take a while! I guess applying concepts is harder than learning them, but I am done with with Tic Tac Toe now, at least until AI Tic Tac Toe. I’ll let you know how that one goes!
Next.js & React.js: Useful Blogs & Articles
Tags: medcode, nextjs, react, javascript
Published: 2024-01-13 18:32:49

In the ever-evolving landscape of web development, staying updated with the latest trends and best practices is crucial. Next.js and React.js, two powerful technologies in the React ecosystem, have garnered immense popularity. To help you stay ahead in your journey of mastering these frameworks, here's a curated list of some of the most useful blogs and articles:
1.[MedCode blog](https://www.medcode.dev/)
Coding blog for beginners Learning programming is accessible for beginners through free software programming courses These
courses introduce essential best programming languages.
2. Official Documentation:
Next.js Documentation: The official documentation is a goldmine of information. It provides in-depth guides, examples, and API references for both beginners and experienced developers.

React Documentation: Dive into the official React documentation to grasp the core concepts of React.js. It's well-organized, beginner-friendly, and continuously updated.

3. Medium:
Next.js on Medium: Medium hosts a plethora of articles covering various aspects of Next.js. You'll find tutorials, tips, and real-world experiences shared by developers.

React.js on Medium: Similar to Next.js, Medium is a great platform for finding React.js content. From best practices to advanced concepts, you'll find articles catering to all skill levels.

4. Dev.to:
Next.js on Dev.to: Dev.to is a vibrant community of developers, and the Next.js tag is filled with insightful posts, discussions, and code snippets.

React.js on Dev.to: Engage with the React.js community on Dev.to to share your experiences and learn from others. The platform is known for its friendly and inclusive atmosphere.

5. Scotch.io:
Scotch.io - React: Scotch.io offers practical tutorials and guides on React.js, helping you build real-world applications with ease.

Scotch.io - Next.js: Explore their Next.js section for hands-on tutorials and best practices to enhance your Next.js skills.

6. FreeCodeCamp:
FreeCodeCamp - React: FreeCodeCamp covers a wide range of React.js topics, providing detailed explanations and examples suitable for beginners and experienced developers alike.

FreeCodeCamp - Next.js: Explore their Next.js content for practical insights and projects using this powerful React framework.

7. Smashing Magazine:
Smashing Magazine - React: Smashing Magazine is known for high-quality content, and their React.js articles are no exception. Gain insights into best practices, design patterns, and more.

Smashing Magazine - Next.js: Explore their Next.js section for articles on building performant and scalable applications using Next.js.
How to represent graphs: Adjacency Matrix
Tags: tutorial, learning, beginners
Published: 2024-01-13 18:17:12

I talked about what graphs are in terms of not only computer science but just as a general concept in my last post. I suggest you read that first if you don't already have an understanding on what graphs are.

Now I would like to discuss this topic in the context of computer science and how such useful data structures can actually be implemented. This will be a language agnostic tutorial, meaning that these concepts can be implemented in any language.

There are 2 main ways to implement graphs:

- Adjacency Matrix
- Adjacency List

## Adjacency Matrix
Let us take a look at the first method - adjacency matrix. In this method we will be representing a graph using a table. For this example assume we have a undirected, unweighted graph, however this method work for directed and weighted graphs as well. In this method we will label the rows and columns of our table with nodes. Next we look for connections in our graph, assume that node '1' is connected to node '2', then we will put a value of 1 in the square with position [2, 1], where 2 represents the column, and 1 represents the row. We use a value of one because it is standard for representing TRUE. We continue with this process and fill in all the connections. The picture below shows this example (Credit to GeeksForGeeks for the image).

![Adjacency matrix of an undirected graph](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ptlikjqvidr9vieuz22d.png)

If the graph was weighted we would just fill in the squares with the weights instead of 1.

There are not many advantages to this method except for the fact that inserting and deleting connections is very easy. However in a graph with few connections and lots of nodes, a lot of the squares in the matrix would be empty, and this is wasted space which is not very good. Also adding or removing a node to the graph means that you will have to add or remove a row and column which is not recommended.

## Conclusion
This is one way one that graphs are represented, and it is relatively easy to code yourself, however something like this would not be favored in big projects or industry simply because of how much space it wastes and it being hard to rescale.

We will discuss a better way to represent graphs - Adjacency lists - in the next article. I hope you enjoyed reading.
How does the Python Program work in your computer
Tags: python, programming
Published: 2024-01-13 17:42:34

পাইথন খুব সহজ এবং ডিমান্ডিং প্রোগ্রামিং ল্যাঙ্গুয়েজ হওয়ার কারণে আমাদের অনেকেরই পছন্দের প্রোগ্রামিং ল্যাংগুয়েজ এটি। আমরা পাইথন দিয়ে প্রোগ্রামিং করলেও অনেকেই ঠিকমতো জানিনা পাইথন আসলে কিভাবে কাজ করে। এই আর্টিকেল এর মাধ্যমে আজকে আমরা সেটাই জানার চেষ্টা করবো।

**Python**

পাইথন একটি হাই লেভেল ইন্টারপ্রেটেড প্রোগ্রামিং ল্যাঙ্গুয়েজ। C বা C++ এর মতো প্রোগ্রাম রান করতে কম্পাইলার এর প্রয়োজন হয় না। পাইথন লাইন বাই লাইন এক্সেকিউট করে।

**Compiler & Interpreter**

কম্পাইলার মূলত সম্পূর্ণ কোডকে একসাথে মেশিন কোড এ ট্রান্সলেট করে। অপরদিকে ইন্টারপ্রেটার লাইন বাই লাইন ট্রান্সলেট করে।

চলুন মূল আলোচনায় যাওয়া যাক।

একটি প্রোগ্রাম রান করার আগে প্রথমে আমরা প্রোগ্রাম টি কোনো একটা ফাইল এ লিখি। তারপর সেটি নির্দিষ্ট ল্যাঙ্গুয়েজে অনুসারে এক্সটেনশন দিয়ে ফাইল টি সেভ করি। পাইথন এর ক্ষেত্রে আমরা .py দিয়ে লিখি।

ধরুন আমরা একটা Hello World প্রোগ্রাম লিখবো। শুরুতে আমরা একটি ফাইল নিলাম যার নাম দিলাম hello.py

এরপর ফাইলটি যেকোনো এডিটর এ ওপেন করে সেখানে আমরা আমাদের কোড টি লিখব।

যখন আমরা ফাইল টি রান করবো তখন আসলে কি হয় সেটাই আমাদের আজকের মূল আলোচনা।

পাইথন প্রোগ্রাম রান করার পূর্বে অবশ্যই আপনার কম্পিউটার এ পাইথন ইন্টারপ্রেটার ইনস্টল থাকা চাই।

কোড টি রান দেয়ার পর প্রথমে পাইথন ইন্টারপ্রেটার কোড টি লাইন বাই লাইন রিড করে byte code / machine code এ ট্রান্সলেট করবে। কম্পিউটার মূলত মেশিন কোড বুঝে।

byte code হলো ডেভেলপার বা প্রোগ্রামার এর লেখা কোড এর set of instruction. এবং এটি .pyc ফাইল এ সেভ হয়। PVM বা পাইথন ভার্চুয়াল মেশিন এর মাধ্যমে byte code/ machine code এ ট্রান্সলেট হয়ে এক্সেকিউট হয়। এবং এক্সপেকটেড আউটপুট দেখায়।

পাইথন ইন্টারপ্রেটার যখন প্রতিটা লাইন কে রিড করে byte code এ ট্রান্সলেট করে তখন যদি কোনো এরর বা অন্য কোনো সমস্যা পায় তখনই প্রোগ্রাম টি এক্সেকিউট বন্ধ করে দেয়। এবং সেই এরর মেসেজ টি শো করে দেয়।

এভাবেই মূলত পাইথন প্রোগ্রাম একটি কম্পিউটার এ রান হয়।

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

List of some Python interpreter
- Cpython (official Python interpreter and it is standard)

- Jpython/Jython

- PyPy

- RubyPython
How to use Sass or Scss in Svelte/Sveltekit
Tags: svelte, sass, webdev, javascript
Published: 2024-01-13 17:35:16

SASS has a pretty strong fan base, It was something beautiful that Introduced a feature that was never needed but definitely desired and cool to have. This is why sass is not widely adopted and frameworks only do a little to make sure it works out of the box or seamlessly.

Nevertheless, Svelte, a framework that supercharges developers with superpowers and massively increases productivity in the building of the web, making it a more enjoyable process for developers, did not forget about the sass enthusiast.

It does not require much effort to get it working in your svelte project, and not just the global CSS, but also the scoped styles. How beautiful.


## 1. Install Sass and Svelte Preprocess

In order to of course compile your scss, you need to install it preprocessor, there are multiple options for this, stated as follows:


- node-sass, this is deprecated and I strongly recommend not using it.
- dart-sass, this is currently maintained, and better implementation of `node-sass`, also have been transformed into `sass`.
- `sass` this is perfect!


> If you’re using sveltekit, you can skip installing svelte-preprocess and also step 2 below.

Install as a dev-dependency using:

```bash
// npm
npm i -D sass svelte-preprocess

// pnpm
pnpm add -D sass svelte-preprocess

// yarn
yarn add -D sass svelte-preprocess
```

## 2. Svelte Preprocess Config

This step is only required for Svelte and not Sveltekit. Sveltekit by default has the necessary, to handle Sass/Scss preprocessor.

In your `rolloup.config.js`

```svelte
import svelte from 'rollup-plugin-svelte';
import sveltePreprocess from 'svelte-preprocess';

export default {
  // other configs
  plugins: [
    svelte({
      preprocess: sveltePreprocess(),
    }),
  ],
};
```

If you have global CSS written in scss, you can modify the config to include the path:


> These additional config can also be done in sveltekit in your `svelte.config.js`

```svelte
// ... 
preprocess: sveltePreprocess({
  scss: {
    includePaths: ['src/styles'], // Optional, specify additional include paths
  },
}),
// ...

```

> You can learn more about the official svelte-preprocess and other available config [here](https://github.com/sveltejs/svelte-preprocess/blob/main/docs/getting-started.md) 


## 3. Create a Svelte component with Sass enabled

To enable Sass/Scss in scoped styles, all you have to do is add `lang="scss"` in the `<style>` tag.

**Example**

```html
<style lang="scss">
  $primary-color: #3498db;
  $secondary-color: #2ecc71;

  .button {
    background-color: $primary-color;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    transition: background-color 0.3s ease;

    &:hover {
      background-color: darken($primary-color, 10%);
    }
  }
</style>
```

Following these steps, you can now harness the power of Scss and Svelte altogether. 

**Peace ✌**
For Coffee lover
Tags: webdev, beginners, programming, javascript
Published: 2024-01-13 17:31:19

Wear your love for coffee, share a smile, and let your fashion speak volumes. Let’s embrace the joy of coffee culture with my Coffee Quotes Collection, Just visit [[my website](prothasen.shop) and make a chance to entertain you. Thanks 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s6riatd1blka9dvlgim.jpg)
Conquering the Cloud: Your Guide to AWS S3
Tags: aws, s3, cloudcomputing, devops
Published: 2024-01-13 17:21:03

The digital world is bursting with data, and businesses of all sizes are scrambling for secure, scalable storage solutions. Enter **Amazon S3**, **the object storage powerhouse** that's revolutionizing the way we store and manage information in the cloud.

But, with a plethora of cloud storage options out there, why should S3 be your go-to hero? Buckle up, folks, because we're about to dive into the **5 reasons why AWS S3 reigns supreme**:

**1. Scalability on Steroids**:

Need to store a petabyte of photos? Or just a few gigabytes of code? S3 adapts seamlessly to your ever-changing storage needs. Forget clunky hardware upgrades – with S3, you simply pay for what you use, scaling up or down effortlessly. Imagine the agility and cost savings!

**2. Durability that Dares to Defy Disaster**:

Worried about losing precious data to accidental deletions or natural disasters? S3 boasts 99.999999999% data durability, meaning your information is safe even if a meteor strikes (okay, maybe not a meteor, but you get the point). Plus, with multi-region replication, your data is geographically dispersed, adding another layer of disaster-proof protection.

**3. Security like Fort Knox (with a Friendly Face)**:

Security is paramount, and S3 takes it seriously. From granular access controls to encryption at rest and in transit, S3 ensures your data stays locked away tight, only accessible to those you authorize. And with features like auditing and logging, you can always keep track of who accessed what and when.

**4. Cost-Effectiveness, Your CFO's New Best Friend**:

S3 offers a variety of storage classes to cater to diverse needs and budgets. Need blazing-fast access for frequently used data? Opt for S3 Standard. Archiving cold data? Glacier Deep Archive offers near-glacial pricing. This flexibility translates to cost optimization at its finest, making S3 a budget-conscious hero.

**5. A Playground for Developers and DevOps**:

S3 isn't just storage – it's a developer's dream come true. With an intuitive API and a wealth of integrations, S3 seamlessly blends into your existing workflows. Plus, features like lifecycle management and static website hosting empower developers to build innovative applications with ease.

So, is AWS S3 the answer to your cloud storage woes? The resounding answer is a resounding yes! With its unmatched scalability, durability, security, affordability, and developer-friendliness, S3 is the versatile champion you need to conquer the ever-growing world of data.

**Ready to unleash the power of S3**? Head over to the AWS website and create your free account today! Remember, the cloud awaits, and with S3 as your trusty guide, your data will be safe, secure, and always at your fingertips.

P.S. Don't forget to share your S3 experiences and tips in the comments below! Let's build a community of cloud storage champions together!
Why main method in JAVA is declared in Static?
Published: 2024-01-13 17:03:38

The main() method is declared static so that JVM can call it without creating an instance of the class containing the main() method.

### What if the main method is not static?

If the main method of the java class is not static then it will throw an error, here you can try this code on any java compiler and it will throw the error.

Moreover, if a JAVA class is declared without a static keyword, the JVM has to create an instance of the main Class, and because the constructor might be overloaded and include arguments, there will be no reliable and consistent way for the JVM to find the main method in Java.

```
public class MyClass {
    public void main(String args[]) {
      System.out.println("Hello World!!");
    }
}
```
```
Error: Main method is not static in class MyClass, please define the main method as:
   public static void main(String[] args)
```
Document Playwright tests with typedoc
Published: 2024-01-13 16:53:21

Hello Playwright is a opensource testing tool, to test web sites or single page alṕplication.

https://playwright.dev/

I have written many tests and want now to describe the tests and write out the descriptions in a html-file. Therefore I have written my tests in Typescript I tried to use typedoc to create the html-files.

But I can't find a right way.

Typedoc is also an open source tool.

https://typedoc.org/

Maybe someone know a how I can do this