teleren/devto huggingface dataset:
1603. LeetCode's Design Parking System - EXTREMELY SIMPLE & LOGICAL Java Solution Beats 90%
Tags: java, simulation, math
Published: 2023-05-30 20:37:10

For a more in-depth explanation, please view my GitHub repository: https://github.com/VerisimilitudeX/LeetCode

# Intuition
The problem is to design a parking system that can accommodate different types of cars (big, medium, small) and has a fixed number of slots for each type. The system should be able to check if there is a slot available for a given car type and park the car if possible.

# Approach
One possible approach is to use three variables to store the number of slots for each car type. The constructor of the class should initialize these variables with the given values. The addCar method should check the car type and decrement the corresponding variable if there is a slot available. It should also return true or false depending on whether the car was parked or not.

# Complexity
- Time complexity: $$O(1)$$
- Space complexity:$$O(1)$$

# Code
```java
class ParkingSystem {
    private int big;
    private int medium;
    private int small;

    public ParkingSystem(int big, int medium, int small) {
        this.big = big;
        this.medium = medium;
        this.small = small;
    }
    
    public boolean addCar(int carType) {
        if (carType == 1 && big > 0) {
            big -= 1;
            return true;
        } else if (carType == 2 && medium > 0) {
            medium -= 1;
            return true;
        } else if (carType == 3 && small > 0) {
            small -= 1;
            return true;
        } else {
            return false;
        }
    }
}

/**
 * Your ParkingSystem object will be instantiated and called as such:
 * ParkingSystem obj = new ParkingSystem(big, medium, small);
 * boolean param_1 = obj.addCar(carType);
 */
```

My LeetCode Solutions: https://leetcode.com/VerisimilitudeX/
Create a trigger in MySQL in SQLAlchemy migration
Tags: python, sqlalchemy, mysql
Published: 2023-05-30 20:19:21

Create a trigger in MySQL in SQLAlchemy migration with op.execute.

I wanted to have an update in last_update field, every time a user or an admin changed the data directly in the database (without python sqlalchemy). Instead of using signal, I created trigger inside `op.execute` method

```
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('new_table',
        sa.Column('no_id', sa.Integer(), nullable=False),
        sa.Column('car', sa.Integer(), nullable=False),
        sa.Column('house', sa.Integer(), nullable=False),
        sa.Column('tier_id', sa.Integer(), nullable=False),
        sa.Column('last_updated', sa.TIMESTAMP(), nullable=True),
        sa.Column('timestamp', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
        sa.ForeignKeyConstraint(['no_id'], ['companies.company_id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['tier_id'], ['tiers.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('no_id')
    )
    op.execute('''
        CREATE TRIGGER tier_after_insert_trigger
        BEFORE UPDATE ON tier_table
        FOR EACH ROW
        BEGIN
            SET NEW.last_updated = CURRENT_TIMESTAMP();
        END;
    ''')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute('DROP TRIGGER IF EXISTS tier_after_insert_trigger')
    op.drop_table('new_table')
```
Being lazy is healthy
Tags: mentalhealth
Published: 2023-05-30 20:09:41

## My understanding of "laziness" 🦥
I've been brought up to believe that it's healthy to keep one steady workflow for months on end, but is that really true? Many of us have been taught to believe that being lazy is bad, and that the only way to succeed is to be constantly productive. However, in my experience, it's in fact quite healthy.

## The creative aspect of it 🎨
Being lazy can lead to greater creativity. When we’re constantly working, our brains get overloaded with information and our creativity greatly declines. But when we take a break and allow our minds to fool around a little bit, I think we can start to see the bigger picture. So even if you don’t feel like doing something, it’s important to take time off and give your brain a rest.

## The bigger picture 📸
As I mentioned, being lazy can help you focus on the bigger picture. When we’re constantly working, it’s easy to get bogged down and lose sight of the "finish line", so to speak. But when you take a break from your work, you can step back, gain a little bit of clarity, and then get back to it!

However, as someone in the comments of this post already noted, it's important for us (mainly me) to remember that you can't always do this. I think "scheduled" laziness is a good idea, and it's a habit that I'd like to try and get into.

## Recharging 🔋
Finally, being lazy can help you recharge, and really get back into it! When you never take a break, it’s easy to get worn out and burned out. Taking a break and allowing yourself to be lazy can give your body and mind the rest they need to stay productive.

## Be lazy. 
To sum it all up, being lazy is good. In fact, with my somewhat loose schedule, I sometimes just decide to not do anything on a certain day. Its nice to get up, say "I feel horrible today", and just relax for the rest of the day. I think the best thing you can do, is do nothing.

> Do you have a problem? If yes, do something about it, and don't worry about it. If no, don't worry about it
2469. LeetCode's Convert the Temperature - SUPER Simple Python Solution Beats 98% in Memory
Tags: math, leetcode, python, beginners
Published: 2023-05-30 20:08:40

For a more in-depth explanation, please view my GitHub repository: https://github.com/VerisimilitudeX/LeetCode

# Intuition
To convert a temperature from Celsius to Kelvin and Fahrenheit, we can use the following formulas:

- Kelvin = Celsius + 273.15
- Fahrenheit = Celsius * 1.80 + 32.00

These formulas are based on the definitions of the temperature scales and the relationships between them.

# Approach
We can implement a function that takes a Celsius temperature as input and returns a list of two elements: the corresponding Kelvin and Fahrenheit temperatures. We can use the formulas above to calculate the conversions and round the results to two decimal places.

# Complexity
- Time complexity: $$O(1)$$


- Space complexity: $$O(1)$$

# Code
```python
class Solution(object):
    def convertTemperature(self, celsius):
        return [celsius + 273.15, celsius * 1.80 + 32.00]
        """
        :type celsius: float
        :rtype: List[float]
        """
```

My LeetCode Solutions: https://leetcode.com/VerisimilitudeX/
#DEVDiscuss: What's New in ES2023?
Tags: devdiscuss, javascript, webdev, es2023
Published: 2023-05-30 20:06:56

Notice our fresh new look? 💅🏻💁🏻‍♀️

Big thanks to DEV's Content Creator @RachelFazio for designing a new header for [#DEVDiscuss](https://dev.to/t/devdiscuss)!

Ok, time for the main event: Our audiences on [Twitter](https://twitter.com/ThePracticalDev/status/1663594730590961670) and [Mastodon](https://fosstodon.org/@thepracticaldev/110458758223142247) selected an excellent discussion topic today, so let's get into it. 😎

{% embed https://dev.to/jasmin/what-is-new-in-es2023-4bcm %}

Inspired by @Jasmin's [Top 7](https://dev.to/devteam/top-7-featured-dev-posts-from-the-past-week-2dkd) post, tonight’s topic is...**what's new in ES2023?!**

If you're not familiar, updates to ECMAScript for 2023 have been finalized! (Ok, kind of — they're not final until July, but they've reached Stage Four, meaning that they're all-but-certain to be final updates). [You can learn more about the updates from TC39's site](https://tc39.es/ecma262/2023/).

### Questions:

- **Which of these updates are you most excited about?**
- **Did any of these updates confuse, frustrate, or disappoint you?**
- **Are there any updates you were hoping to see this year but didn't?**
- **Any triumphs, fails, or other stories you'd like to share on this topic?**
Creating a Responsive and Stylish Navigation Bar with HTML, CSS, and JavaScript
Tags: webdev, beginners, html, tutorial
Published: 2023-05-30 20:00:00

Hey there, fellow developers! In this post, we'll dive into the process of creating a responsive and stylish navigation bar using HTML, CSS, and JavaScript. As someone who has faced the challenges of designing a standout navigation bar, I'm excited to share my current navigation bar script with you. You can find all the source codes in [my GitHub repository](https://github.com/RhythmusByte/Nav-Bar), and don't forget to check out the [live demo](https://rhythmusbyte.github.io/Nav-Bar) too!

### Why a Responsive Navigation Bar?

A responsive navigation bar is crucial for modern websites and portfolios. It ensures that your site remains user-friendly and accessible across various devices, including desktops, tablets, and smartphones. By adapting to different screen sizes, a responsive navigation bar provides a seamless browsing experience for your visitors, regardless of their device.

### Building the Navigation Bar

To create a responsive navigation bar, we'll leverage the power of HTML, CSS, and JavaScript. HTML will be used to structure the elements, CSS will handle the styling, and JavaScript will add interactivity and functionality.

#### HTML Structure

Let's start by organizing the elements of our navigation bar using HTML. Here's an example of how you can structure the elements:

![HTML Code](https://res.cloudinary.com/dqocmr8iu/image/upload/v1685513834/Blog/Nav%20Bar/HTML_offzag.jpg)

#### CSS Styling

Next, we'll apply CSS styles to transform our navigation bar into a visually appealing and stylish element. This includes defining positioning, colors, fonts, and other visual aspects to match your desired aesthetic. Take a look at the CSS styling:

![CSS Styling](https://res.cloudinary.com/dqocmr8iu/image/upload/v1685513833/Blog/Nav%20Bar/CSS_jlmumz.png)

#### JavaScript Functionality

To add interactivity and make our navigation bar even more engaging, we'll incorporate JavaScript. This will allow us to implement features like a toggle menu button for smaller screens, smooth scrolling to anchor points within the page, and dynamic highlighting of the active section in the navigation bar. Check out the JavaScript functionality:

![JavaScript Functionality](https://res.cloudinary.com/dqocmr8iu/image/upload/v1685513833/Blog/Nav%20Bar/js_heuugg.png)

### Conclusion

Congratulations on creating your own responsive and stylish navigation bar! By combining HTML, CSS, and JavaScript, you've successfully built a crucial component that enhances user experience and accessibility. You can access all the source codes in [my GitHub repository](https://github.com/RhythmusByte/Nav-Bar), and feel free to explore the [live demo](https://rhythmusbyte.github.io/Nav-Bar) as well.

That's it for this post! I hope you found this tutorial helpful and that it inspired you to create unique and eye-catching navigation bars for your projects. If you have any questions or need assistance, don't hesitate to [reach out](https://akhil-linktree.netlify.app). Happy coding and have fun customizing your navigation bar!
#1: On creating landscapes
Tags: devjournal, unreal, gamedev
Published: 2023-05-30 19:38:11

I’m still not really sure how I’m going to schedule or format this blog but firstly I’d like to report some of my findings on building landscapes.

Last week I had the privilege of joining a part time project that involves making an Unreal game. I can’t get into the details of it just yet but right now we’re working on making some realistic terrain for the game. It’s going to be a war simulator type game, and we want it to be based off real life locations so it should be reasonably realistic.

I immediately got to work researching some terrain generation software. I came across several, such as World Machine, Houdini, etc. but I was ultimately drawn to Gaea simply because I figured the interface was clean and the technology was newer.

I also naturally had to figure out how to exactly get real world data in the first place. I looked up tutorials on YouTube and asked ChatGPT and learned that you can actually download data from USGS and NASA. Eventually I came across a GitHub link that was a master doc explaining all the different data sets out there and I settled on some free data from OpenTopography. 

I downloaded the area I wanted and imported the height map as a GeoTIFF to Gaea and I think it looked quite good. However, it needs some fine tuning since the resolution of the heightmaps only go to 30m per pixel (I believe). I’ll be sure to attach pictures next blog post once I get it all sorted out within Unreal itself. We’re looking to have 3km x 3km maps for a semi-open world experience.

Anyway, that’s all I have so far as for the most recent update. Thanks for reading and I hope to write the next one soon, with some cool pictures.
Understanding pointers in Go
Tags: go, pointers
Published: 2023-05-30 19:29:53

---
title: Understanding pointers in Go
published: true
description: Understanding pointers in Go
tags: go, pointers
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-05-30 18:38 +0000
---

We define a variable with a value and a name. The variable name will be [converted to a memory address](https://stackoverflow.com/a/14612359/7358595) and the value gets stored in that address. In case of a pointer variable, an actual memory address of another variable is stored as a value.

The [two unary pointer operators](https://web1.eng.famu.fsu.edu/~haik/met.dir/hcpp.dir/notes.dir/cppnotes/node68.html).
* `&` is used to get the memory address of a variable
* `*` is used to get value at the address stored by a pointer variable. 

Example:
```go
func main() {
	x := 7
	y := &x // creating a pointer variable

	p := fmt.Println
	pf := fmt.Printf

	pf("type of x (non pointer variable) = %T\n", x)
	p("value of x (stores actual data) =", x)
	p("address of x (memory address where x is located) =", &x)
	// invalid operation: cannot indirect x (variable of type int)
	// p("value dereferenced by x =", *x)

	p()
	pf("type of y (pointer variable) = %T\n", y)
	p("value of y (stores memory address of x) =", y)
	p("address of y (memory address where y is located) =", &y)
	p("value at the address stored by y (dereferencing the pointer) =", *y)
}

```
Output
```
type of x (non pointer variable) = int
value of x (stores actual data) = 7
address of x (memory address where x is located) = 0xc00001a0e8

type of y (pointer variable) = *int
value of y (stores memory address of x) = 0xc00001a0e8
address of y (memory address where y is located) = 0xc000012028
value at the address stored by y (dereferencing the pointer) = 7
```

Resources:
1. [Passing by reference and value in Go to functions](https://stackoverflow.com/q/47296325/7358595)
2. [Reference (computer science)](https://en.wikipedia.org/wiki/Reference_(computer_science)#Use)
3. [Pointer (computer programming)](https://en.wikipedia.org/wiki/Pointer_(computer_programming)#Formal_description)
4. [Pointer Operators](https://web1.eng.famu.fsu.edu/~haik/met.dir/hcpp.dir/notes.dir/cppnotes/node68.html)
5. [How are variable names stored in memory in C?](https://stackoverflow.com/questions/14612314/how-are-variable-names-stored-in-memory-in-c)
GTA Mzansi Apk Download (Updated v4.0.5.13) Free Download
Published: 2023-05-30 19:18:09

[](https://apksaw.com/gta-mzansi-apk/)
Grand Theft Auto, also known as GTA, is one of history’s most popular and beloved gaming franchises. With the release of GTA Mzansi, the latest installment in the series, fans of the game have much to be excited about. In this article, we will take a deep dive into everything you need to know about GTA Mzansi Apk, from the storyline to the gameplay, graphics, and more.

What is GTA Mzansi?
[GTA Mzansi](https://apksaw.com/gta-mzansi-apk/) is the latest game in the Grand Theft Auto series, developed by Rockstar Games. It is set in a fictional version of South Africa, called Mzansi. The game features a new protagonist, Ayanda, who is a member of a criminal organization known as the Marashea Family. also visit the website.

The Storyline
The storyline of GTA Mzansi revolves around Ayanda’s rise to power within the Marashea Family. As she completes various missions and tasks for the organization, she becomes more and more involved in the criminal underworld of Mzansi. Along the way, she must navigate various challenges and obstacles, including rival gangs, corrupt police officers, and more.

The Gameplay
GTA Mzansi features a similar gameplay style to previous games in the series, with an open-world environment that allows players to explore and interact with the game’s world in various ways. Players can complete missions and tasks, engage in combat, drive various vehicles, and more. The game also features new mechanics, such as the ability to recruit and manage members of Ayanda’s crew.

The Graphics
One of the standout features of GTA Mzansi is its graphics. The game features stunning visuals that bring the world of Mzansi to life in vivid detail. The developers have put a lot of effort into creating a realistic and immersive environment, from the bustling streets of the city to the sprawling countryside.

Multiplayer Mode
Like previous games in the series, GTA Mzansi features a multiplayer mode that allows players to team up with friends and engage in various activities together. The multiplayer mode includes various missions and tasks that players can complete together, as well as more competitive gameplay modes like racing and death matches.

Conclusion
GTA Mzansi is an exciting addition to the Grand Theft Auto series, offering players a new and immersive world to explore and enjoy. With its engaging storyline, diverse gameplay mechanics, and stunning graphics, it is sure to be a hit with fans of the franchise and newcomers alike.
How to fix React/Vite redirect issue in Vercel
Tags: tutorial, react, coding, webdev
Published: 2023-05-30 18:31:55


If you're experiencing redirect issues when deploying your React application with React Router on Vercel, there are a few common solutions you can try:

Vercel supports a redirect configuration file called vercel.json. In your project's root directory, create a file named vercel.json and add the following line to it:

```
{
    "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}
```
This rule tells Vercel to redirect any request to the index.html file, which is the entry point of your React application.

After applying this solutions, rebuild your React application (npm run build) and redeploy it to Vercel. The redirect issue should be resolved, and your application's routing should work as expected.
TIL: adding asdf to arch
Published: 2023-05-30 18:24:17

The instructions on the [asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) website are mostly complete. The things that are missing are how to add the line "source /opt/asdf-vm/asdf.fish" to your config.fish file. If you know how to open the file in the terminal it will be easy for you, but for newbies like myself I had to do some google search to figure it out. 

In my case, I used vim. 
Open a terminal, type:
```
vim ~/.config/fish/config.fish
```
Then, scroll (use arrow keys) to move your cursor all the way down to the bottom of the file(not sure if it matters where you put it, but that's where I did).

Press the "i" key to allow you to insert/edit

paste in ``` source /opt/asdf-vm/asdf.fish ```


type ``` :wq ``` to save and exit. 

restart your terminal and type:
``` asdf --version```
You should see a version now which means it has been added properly.
Next.js Projects
Tags: nextjs, react, javascript, webdev
Published: 2023-05-30 18:15:56

Next.js is a popular open-source framework for building web applications and websites with React. It is based on React, a JavaScript library for building user interfaces, and extends it with additional features and optimizations. Next.js provides server-side rendering (SSR) and static site generation (SSG) capabilities, making it suitable for building both dynamic and static websites.

---

📌 Master Next JS by Building Real Projects
https://youtube.com/playlist?list=PL6QREj8te1P7gixBDSU8JLvQndTEEX3c3

📌 React.js Clones by PAPA React
https://youtube.com/playlist?list=PLf16UKl7nR5AjcrYOe1niifJSAls3spDk

📌 Amazon 5-Day Challenges (Next.js | Tailwind CSS | Stripe | Redux)
https://youtube.com/playlist?list=PLf16UKl7nR5AF9k4ckTG82onvpAv1NAE7

📌 Airbnb 5-Day Challenge (Next.js | Tailwind CSS | Mapbox | API's)
https://youtube.com/playlist?list=PLf16UKl7nR5AOGvcX_WtjqXMge-a1B1Lo

📌 eBay 5-Day Challenge (React.js | Tailwind CSS | Thirdweb | MetaMask)
https://youtube.com/playlist?list=PLf16UKl7nR5D06fAYUq8qy-BgwaWFpv3B

📌 Next.js 13 E-commerce App
https://youtube.com/playlist?list=PLdAEGQHOerPAs67GJpgopqHhIjPk7rW7d

📌 Next.js Projects
https://youtube.com/playlist?list=PLafbzCEkgeieqkLQx8m4djGJgnsi2CE7x

📌 Personal Website Tutorial with Next.js 13, Sanity io, Tailwind CSS, and TypeScript
https://youtu.be/OcTPaUfay5I

📌 Build a NEXT JS Portfolio Website With Tailwind CSS
https://youtu.be/CMx51wpd7g4?list=PLaPfwr_iF3CbwdJhXtRkhiQ4eiAidlMU8

📌 Build Twitch with Next JS and Tailwind CSS
https://youtu.be/W3HulvsuqGI?list=PLaPfwr_iF3CbwdJhXtRkhiQ4eiAidlMU8

📌 5 Projects to Learn React, Next JS, Tailwind, Firebase, APIs, and Hosting
https://youtu.be/gYCOWMbt31k?list=PLaPfwr_iF3CbwdJhXtRkhiQ4eiAidlMU8

📌 Create a To-Do App with Next.js 13: Learn CRUD Operations and Tailwind CSS UI
https://youtu.be/wi2xdrpmJNk

📌 Next.js Projects - Noor Mohammed
https://youtube.com/playlist?list=PLOl4xN4eJVEPU90Yr7ENYu2OUmkURg9xe

📌 Next.js Projects - Hosna Qasmei
https://youtube.com/playlist?list=PL6z3WDBAJuCMaklpb3WgP5ANpBRpNsMvw

📌 Let's build a Modern Responsive Portfolio with NEXT.JS and Kinsta (Framer Motion Animations)
https://youtu.be/x9AkJNMdK7M

📌 Building a Webshop with Next.js, Supabase, and Tailwind CSS: A Step-by-Step Tutorial
https://youtu.be/9dVtFxd4wrY?list=PLoJm358rCfTxuPrKa3NmzTJhl4NzczW-d

📌 How to Create a Stunning Creative Agency Website with Next.js 
https://youtu.be/xpZ8MmRluQE

---

💡 Where to find me: 
- [LinkedIn](https://www.linkedin.com/in/dev-alisamir)
- [Telegram](https://t.me/se_alisamir)
- [Facebook](https://www.facebook.com/alisamir.dev)
- [Instagram](https://www.instagram.com/alisamir.dev)
A better prompt engineering library built for JS. Langchain.js feels like a python team writing JS
Tags: javascript, chatgpt, llm, ai
Published: 2023-05-30 17:51:48

As JS (Mostly TS) devs, we feel like AI or LLM tooling in JS kinda sucks rn, that said most production applications inevitably end up being in JS, so a friend and I started hacking on a new JS native library for making it easier to write prompts.

The idea of the library is to give a much more ergonomic syntax for writing complex prompts, the repo itself goes much more in detail

https://github.com/LevanKvirkvelia/salute

```ts
import { gpt3, gen, assistant, system, user } from "salute";

const agent = gpt3(
  ({ params })=>[
    system`You are a helpful and terse assistant.`,
    user`
      I want a response to the following question: 
      ${params.query}
      Don't answer the question yet.
      Name 3 world-class experts (past or present) who would be great at answering this?
    `,
    assistant`${gen("expertNames")}`,
    user`
      Great, now please answer the question as if these experts had collaborated in writing a joint anonymous answer.
    `,
    assistant`${gen("answer")}`,
    user`Are you sure you gave a good answer? Write the answer again and fix it if necessary.`,
    assistant`${gen("fixedAnswer")}`,
  ]
);

const result = await agent(
  { query: `How can I be more productive?` },
  { render: true }
);

console.log(result);
```