teleren/devto huggingface dataset:
What I learned today 5.8.24
Tags: python
Published: 2024-05-09 00:08:00

Here's what I learned today from studying Python.....

I didn't know defining a class property with '__' in Python its referred as private. 

In this example the property '.__height', if you try to set it will throw an Attribute error.

`class Square:
      def __init__(self):
          self.__height = 2
          self.__width = 2
    def set_side(self, new_side):
          self.__height = new_side
          self.__width = new_side

  square = Square()
  square.__height = 3 # raises AttributeError `

There's a caveat...... You can still set the class property by using the following code:

`square = Square()
square._Square__height = 3 # is allowed `

The solution is uses decorators for our getters and setters methods. This allows us to validate the data before setting the internal __height property value. Check out the code below. 

`class Square:
    def __init__(self, w, h):
        self.__height = h
        self.__width = w
  
    def set_side(self, new_side):
        self.__height = new_side
        self.__width = new_side

    **@property**
    def height(self):
        return self.__height

    **@height.setter**
    def height(self, new_value):
        if new_value >= 0:
            self.__height = new_value
        else:
            raise Exception("Value must be larger than 0")`

Decorators are functions that take your function as input. This will allow you to decorate one function and then reuse and add the decorated function on different function to extend the new function's capabilities. Pretty cool. 

That's it. Let me know what you think and/or correct anything I missed.

Thanks for stopping by,
Cheers
On the road to ramen profitability 🍜 💸
Tags: startup, webdev, rails
Published: 2024-05-08 23:43:13

It’s always been a dream of mine to build a kick-ass product. Today I’m starting that product, and will be documenting my progress towards [ramen profitability 🍜](https://paulgraham.com/ramenprofitable.html), with a post every 2 weeks to keep myself accountable and to share my learning along the way.

Let's dive in!

## The problem

Property managers have to track and respond to rental inquiries across a dozen or more sites to find the right tenant.

[HomeSuiteApartment](https://homesuiteapartment.com/) helps property managers track and respond to these inquiries so they can find the right tenant quickly, all in one place.

## Where we're starting

We're starting at the bottom floor, it can only go up from here!

- 0$ MRR;
- and 0 customers

It feels incredibly hard to scale something from 0 to 1, and this won't be any different. It's practically a ∞% increase! 

## What's been built so far

A basic marketing site built-on [Jekyll](https://jekyllrb.com/) and hosted via [Cloudflare Pages](https://pages.cloudflare.com/). 

![Marketing Site Home Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8mqy44xlkx8p1iwbstx.png)

A 7.1 [Ruby on Rails](https://rubyonrails.org/) application hosted on a [Hetzner VPS](https://www.hetzner.com/) and deployed via [Kamal](https://kamal-deploy.org/).

Users can signup and login via the [Devise](https://github.com/heartcombo/devise) gem and create their organizations.

![Login Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hsuxlaayrl45bi9yyep.png)

![Organization create form](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zghlt7a9h2mr4dvh0oat.png)

At the moment, I’m launching into private beta, and 
Until the MVP is launched into open beta, 
Until I'm ready to launch an MVP, you won't be able to do much, and instead will be shown a private beta screen, where they can email me with any ideas.
 
![Private Beta Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/546lrupd05mpclu28thq.png)

## What's next?

- Prepare for an MVP launch with minimal feature set, aggressively cutting requirements where possible
- Reach out to more property managers in the area
- Setup basic subscription with Stripe to unlock MRR and get commitment from new customers.
  - This is an area where there will be lots of exploration in the future, but something simple to start will help me understand who is finding value in the product

See you in 2 weeks for the next update!
Introduction to Data Distribution Unit
Tags: learning, computerscience, beginners, news
Published: 2024-05-08 23:31:58

In maritime applications, NMEA (National Marine Electronics Association) format is widely used for data exchange between various navigation and communication equipment onboard vessels. NMEA messages are ASCII-based and are typically transmitted over serial connections (RS-232 or NMEA 0183) between devices like GPS receivers, autopilots, radars, and chart plotters.

The data distribution unit in maritime using NMEA format typically involves the transmission and reception of NMEA messages. These messages contain information such as GPS position, speed over ground, heading, depth, wind speed, and other relevant navigational data. The data distribution unit acts as a hub, receiving NMEA messages from various sensors and devices on the vessel and distributing them to other systems or equipment that require the information.

Some common NMEA sentences used for data distribution in maritime applications include:

- GGA (Global Positioning System Fix Data): Provides essential fix data such as latitude, longitude, altitude, and time.
- RMC (Recommended Minimum Navigation Information): Provides essential GPS data including latitude, longitude, speed over ground, course over ground, and time.
- GLL (Geographic Position - Latitude/Longitude): Provides latitude and longitude data.
- VTG (Track Made Good and Ground Speed): Provides information about the speed over ground and course over ground.
- HDG (Heading, Deviation, Variation): Provides information about the vessel's heading.
- DBT (Depth Below Transducer): Provides depth information.
- MWV (Wind Speed and Angle): Provides information about wind speed and angle.

The data distribution unit in maritime applications typically collects these NMEA messages from various sensors and systems, processes them as needed, and then distributes them to navigation displays, chart plotters, radar systems, and other equipment where the data is required for navigation, situational awareness, and decision-making.
Node Version Manager (nvm) overview
Tags: node, nvm
Published: 2024-05-08 23:31:12

---
title: Node Version Manager (nvm) overview
published: true
tags: ['node', 'nvm']
canonical_url: https://sevic.dev/notes/node-version-manager-nvm/
---

`nvm` facilitates switching between different Node versions across projects. This post covers its overview from installation to version management.

### Installation

To install `nvm`, execute the following commands in your terminal. This example uses `zsh`, but the process is similar for other shells like `bash`.

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.zshrc
```

### Version management

- Install the specific version. Including the `v` prefix is optional.
```bash
nvm install v21.7.2
```

- Install the latest version
```bash
nvm install node
```

- Install the latest one for the specified major version
```bash
nvm install 22
```

- Switch to a specific installed version
```bash
nvm use 21
```

- Add `.nvmrc` file inside the project directory and run `nvm use` command to use the specified installed version.
```.nvmrc
v21.7.2
```

- Get the list of locally installed versions
```bash
nvm ls
```

- Get the list of available versions for installation
```bash
nvm ls-remote
```

### Boilerplate

Here is the [link](https://sevic.dev/nestjs-starter) to the template I use for the development.
Laravel Tinker: login as another user and generate an injectable session cookie
Tags: laravel
Published: 2024-05-08 23:19:40

## Generating session cookie

- Enter Laravel Tinker

```bash
php artisan tinker
```

- Authenticate

```php
# Login using id
auth()->loginUsingId(1);

# Login using a user instance
auth()->login(User::where('email', 'foo@bar.com')->first())
```

- Save the session

```php
session()->save()
```

If you are not using `EncryptedCookie` for some reason, you can stop at this step and proceed to injecting the session id to your session cookie:

```php
session()->getId()
```

- Generate the cookie value that is about to get encrypted

```php
\Illuminate\Cookie\CookieValuePrefix::create(config('session.cookie'), app(\Illuminate\Contracts\Encryption\Encrypter::class)->getKey()).session()->getId()
```

- Generate the encrypted cookie value

It is highly likely the 2nd parameter here is always `false` for everyone. If not, then you probably know what you are doing.

Here is the reference: https://github.com/laravel/framework/blob/v11.7.0/src/Illuminate/Cookie/Middleware/EncryptCookies.php#L187-L189

```php
app(\Illuminate\Contracts\Encryption\Encrypter::class)->encrypt(<value from previous step>, false)
```

- urlencode it or simply just replace the `=` at the end with `%3D`

```php
urlencode(<value from previous step>)
```

- You can now proceed to injecting the generated string to the browser


## Injecting session cookie to the browser

- Open your website e.g http://localhost
- Open devtools
- Open Application tab
- Open Storage > Cookies > your website (e.g http://localhost)
- Double click on the value column of the session cookie (e.g laravel_session)
- Paste the value from Generate step
- Refresh the page
Cash Gift $750
Tags: gift, cash, 750, airdrop
Published: 2024-05-08 23:13:35

## 🎉CONGRATS so far
Collect your Cash Gift $750 Voucher per person🍔
🎉If  you interested click here🍟
👇🍔👇[join](https://rb.gy/rgeef6)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nvc9t8t9qvead19ez5sq.jpg)
5 Tips for Junior Node Js Developers
Tags: javascript, node, webdev, beginners
Published: 2024-05-08 22:53:37

## 1. Join communities and ask questions 🌐

While online developer communities may sometimes exhibit toxic behavior, great people who are willing to help still exist. Learning by discussing with others is a great way to stay updated.
Hints:
- 🎮 Discord communities
- 🤝 meetups and conferences
- 📱 social networks

## 2. Practice your algorithms 🧠

Regularly practicing algorithms is essential for improving your problem-solving abilities. Engage in algorithmic challenges on platforms like LeetCode, HackerRank, or CodeSignal to enhance your skills and become more comfortable tackling complex problems.

## 3. Securize your backend 🔒

I recently heard a lot of "My discord API has been token grabbed". Those sort of stuffs are due to guys that do not spend time to put in place the basic security measures.
Some tips:
- 💼 use environment variables instead of committing your TOKEN into Git platforms (pleaseeeee )
- ⏳ add rate limits to the API
- 🛡️ prevent SQL Injection
- 🔐 protect your API routes

## 4. Test your codes 🛠️

Testing is crucial for ensuring the reliability and correctness of your backend code. Learn about different types of testing such as unit testing, integration testing, and end-to-end testing. Use testing frameworks like Mocha, Chai, or Jest to write and automate tests for your Node.js applications. By writing tests, you can catch bugs early, improve code quality, and build confidence in your codebase.

Below is an example of a test using Jest:
```
it('should return true for valid email addresses', () => {
        const validEmails = [
            'test@example.com',
            'user123@gmail.com',
            'john.doe@company.co'
        ];

        validEmails.forEach(email => {
            expect(isValidEmail(email)).to.be.true;
        });
    });
```

## 5. Learn debugging techniques 🐞

A lot of bugs when we are starting a programming project may be quickly solved just by having a basic debugging techniques.

Familiarize yourself with debugging techniques specific to Node.js, such as using the built-in debugger, `console.log` statements, and logging libraries like Winston ( [https://github.com/winstonjs/winston](https://github.com/winstonjs/winston) ) or Bunyan. Understanding how to set breakpoints, inspect variables, and trace the flow of execution will help you diagnose and resolve issues more efficiently.

# Conclusion

The list above is of course far from being exhaustive.
What about you ? Any tips that you would recommend for our Node Js Dev friends ? :)

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



---------------------------------------------------
Wanna have some chat with me ? 
🗓️ [Let's schedule a meeting here](https://calendly.com/nji-olaf/meeting-time)

Wanna find a small community to chill and learn with ? Join us at Dev It Out Studio :) 
🎮 [Dev It Out Studio Discord](https://discord.gg/YwfRE8PFGp)

P.S: Wanna support me ? https://ko-fi.com/dev_it_out
Day 961 : Travellin' Man
Tags: hiphop, code, coding, lifelongdev
Published: 2024-05-08 22:48:48

_liner notes_:
- Professional : Not a bad day. Had a couple of meetings. Got to do another demo of the library I'm working on. Got some more stuff working with the library that I meant to add. I think I'm just going to clean it up, make sure it's working and then publish it. I can always do some refactoring later while having people test it out for me. Also, been slowly packing up during the day. Making sure I don't forget anything, which I probably will anyway. There's certain things that I NEED, so making sure I at least have those.

- Personal : Last night was..... not as productive as I would have liked. I was making some pretty good progress. Bought some tracks from Bandcamp. Copied over some tracks from my laptop to a SD card so I can work on the radio show while travelling. Booked all the hotels for my vacation. Turns out I stayed with one chain for the whole trip. They were the cheapest and had some good amenities. Then due to some unforeseen circumstances. I was kind of blocked from really doing anything for like 2 hours. All I could really do is get the social media posts ready for the tracks I purchased, created a new entry on my travelling site https://dwane.in and other things on my laptop while I waited till my laptop battery emptied. Afterwards, I got my clothes ironed and packed and went to bed because it was kind of late. 

![﻿ A overhead photo of a trail. The trail has a body of water on the right side of the photo and there are trees and other vegetation growing on the banks. The water is a deep blue-green color. The trail is a reddish-brown color. The trail is located in Painted Cove Trail, Oregon, USA.﻿](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vglfdvmxvgee9g86nvj8.jpg)

So, like I said, I did some packing during work. Making sure I have all the things I need to bring for work with me. It looks like I may need to remove some things to make space for the work stuff. The problem is that I'm going overseas and the luggage size for carry-on is smaller than the US. I'm not trying to have any checked luggage. Depending if I do any shopping, I may have to pick up some luggage and check that on the way back. We'll see. Well, I won't be posting here during my work trip and vacation, but I will be updating my travel site here: https://dwane.in/RubyKaigi2024 and https://dwane.in/Japan2024. I'll also be doing my radio show remotely at https://kNOwBETTERHIPHOP.com About to be a travellin' man once again! haha

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube p2YUDZZV6H8 %}
The Crossover of Health, Technology and Art: CodeNewbie Podcast S27E6
Tags: podcast, ai, codenewbie
Published: 2024-05-08 22:37:35

We have a new CodeNewbie Podcast episode ready for you today! In this episode @saronyitbarek speaks with [Daniel Bourke](https://twitter.com/mrdbourke?lang=en), founder of mrdbourke Studios and Nutrify! Daniel shares his experiences trying to learn to code four different times before it finally stuck, how he’s combining his passions for health, technology and art.

Daniel is a writer who makes YouTube videos about the crossover of health, technology and art. His mission is to use AI to help people move more and eat better.

---

- [Listen on Apple Podcasts](https://podcasts.apple.com/us/podcast/codenewbie/id919219256?i=1000654908718)

- [Listen on Spotify](https://open.spotify.com/episode/3NMabcHMuNYYRGkKempzh1?si=0e4618a5f73c4edb)

Or, listen wherever you normally get your podcasts!


![Baby sheep from Wallace and Grommet smiling and giving a thumbs up.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ew8v4pa8yckrhhf24bzc.gif)

---

### We will see you next week, happy coding y'all!

PS: Make sure to subscribe to the CodeNewbie Podcast if you haven't yet + review us on your chosen platform!
VSCode App Google Play -SUS!
Tags: google, vscode, beginners, android
Published: 2024-05-08 22:34:42

Where do I begin. This is an amendment of sorts to my previous post found here: https://dev.to/annavi11arrea1/vscode-on-android-phone-4i56

The excitement of coding on your phone. While possible, I wanted to alert everyone about this potential imposter. Thank you everyone that has pointed out some facts. You're the real VIPS here. 

![potential scam app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dyxcghvuw17xabb2xxf.jpg)

What do we have here? 

- They charged me 11.99 for the app (refund requested)
- The logo does not match the real vscode
- They have 0 reviews

Additionally,

![Potential scam app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fb42m7fzq0noqicp765i.jpg)

- They only have one app
- If you google Dev.environments, you do not really find anything
- The photos are extremely generic
- "Environments for Developer" sounds a bit cave-manish. If you are trying to attract developers, shouldn't you have a better description?

When I downloaded this the other day, it had 100 downloads. thats up to 500 now. I wanted to alert all the other excited people out there that this is a very real security threat. 

After jumping through several hoops I discovered that if you simply open vscode in the browser on your phone, click the three dots in the upper right-hand corner, you can simply click "install app" and BAM everything you ever wanted. Logo even matches. XD Please don't do what I did and keep your sanity. Sure lucky to have a forum with intelligent people to keep me in line.
🚀 Want to Boost Your Sports Development? Discover the Benefits of Real-Time Results with SportDevs!
Tags: sports, development, realtime
Published: 2024-05-08 22:01:41

Are you looking to take your sports development to the next level? With SportDevs, you can access real-time results that provide instant feedback and insights. Say goodbye to waiting for data to be processed and hello to immediate analysis. Improve your performance, track progress, and make data-driven decisions faster than ever before. Try SportDevs today and experience the benefits of real-time results for yourself!
Add a custom color to your XCode Project
Tags: xcode, ios, swift, swiftui
Published: 2024-05-08 21:18:00

Every application has a personality, and nothing brings that personality to life quite like a unique and consistent color scheme. 
Not only does your app acquire a personality when using color schemes, but also enhances user experience and strengthens your brand.
This guide will walk you through the steps to add a custom color to your Xcode Project.

**Three main steps in adding a custom color**
1. Define Your Custom Color
2. Adding Color to the Asset Catalog
3. Using the Custom Color in Your Code

## Step 1: Define Your Custom Colors
Before getting onto Xcode, you need to select the color or color combination that will represent your application. Tools like [Adobe Color](https://color.adobe.com/) and [Color Hunt](https://colorhunt.co/) can help you develop a palette that fits your application's brand and consequently appeals to your audience.
Make sure to get the hexadecimal code for the respective color.
## Step 2: Adding Color to the Asset Catalog
- Open your Xcode project
- Navigate to the Asset Catalog

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

- Click on the '+' and select 'New color set' sign on the bottom left of your asset catalog

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

**To adjust the color of the asset, open the inspector on the right. In the inspector;**
- change the name of the color to your preferred name by replacing the default name with your preferred one. In this case, we will set it to 'background-color'
- change which devices this color will be used on in the 'Devices' section
- change the 'Any Appearance' color value. On the 'input Method' field, select '8-bit hexadecimal'
- Paste the RGB hexadecimal color code on the 'Hex' field

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

## Step 3: Using the custom color in Your Code
Now that you have successfully added your color to the assets catalog, you can use it in your code. Below is a code block

```
if let customColor = UIColor(named: "background-color") {
    yourView.backgroundColor = customColor
} else {
    yourView.backgroundColor = UIColor.systemBlue // Fallback color
}
```
Assignment(O'zlashtirish) (=) operatori
Tags: webdev, beginners, programming, tutorial
Published: 2024-05-08 21:05:45


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

- o'zgaruvchiga qiymat o'zlashtirish uchun ishlatiladi.

- o'zlashtirish operatori (`=`) chap tarafida doimo **o'zgaruvchi** turishi shart.

```
200 = x;       // error - chap tarafda qiymat turibdi
x + 1 = 200    // error - chap tarafda ifoda turibdi
```
To'g'ri o'zlashtirishga misollar:

```
x = 5;
x = y;
y = x + 10;
```
Mashq
Quydagi ifodalar natijalarini taxmin qiling!

```
cout << 3 * 4 << endl;
cout << 2.0 * 3.0 << endl;
cout << 2.0 * 4 << endl;
cout << 10 / 2 << endl;
cout << 10 / 3 << endl;
cout << 10 / 3.0 << endl;
cout << 10 % 3 << endl;
cout << 3.0 + 3 / 2 << endl;
```