teleren/devto huggingface dataset:
Let Your "WHY" be Your Fire
Tags: codenewbie, mentalhealth, softwaredevelopment
Published: 2023-12-06 17:43:21

| ✍ **Disclaimer**: |
| --------- |
| This post is enhanced with AI assistance.|


## The Newbie Wondered
> Hey Master, please guide me as I embark on my journey into the software development field.

## The Master Murmured, With Eyes Still Shut


![Find your guiding star](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6mcc5cgh0zrp7cnae05t.jpg)

```
In realms of logic, where code takes flight,
A developer's journey, bathed in digital light,
Embark on this adventure, a quest untold,
Where lines of code weave stories, never to grow old.

It's not just mechanics, nor syntax defined,
But understanding the landscape, where problems reside,
Embracing the challenges, unyielding and true,
Finding purpose in process, a reason to pursue.

Seek your "why" in this intricate maze,
Like a North Star, it guides you through coding's haze,
Is it the thrill of creation, a masterpiece to behold?
Or the joy of functionality, a story to be told?

It's not just about writing, lines strung one by one,
But crafting solutions, a battle well-won,
Solving puzzles, intricate and grand,
Leaving your mark, a digital footprint in the sand.

Ask yourself deeply, with introspection's gaze,
Why software development? In this digital maze,
Is it the power to change, to make a difference profound?
Or the beauty of creation, where innovation resounds?

Let your "why" be your fire, a passion ablaze,
Guiding your steps through coding's intricate maze,
For in the realm of software, a tapestry unfolds,
Where dreams take flight, and stories untold.

So welcome, young traveler, to this digital land,
Where imagination thrives, and knowledge expands,
Embrace the challenge, let your spirit take flight,
And write your own story, bathed in coding's light.
```
How to write nested loop using Java 8 Stream
Tags: java, java8
Published: 2023-12-06 17:38:47

Consider we have two lists List<Student> and List<Subject>. The List of Subject is defined in Student class. 

or consider we have below code that we want to convert into Java 8.

```
List<String> list = new ArrayList();
for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
        if(dataMap[i][j] == 1)
            list.add(new Data(i,j));
    }
}  
```
We want to convert above code into Java 8.

https://javatute.com/core-java/how-to-filter-data-from-nested-list-using-stream-java-8/
Design a parking lot system?
Tags: javascript
Published: 2023-12-06 17:08:34

**What are Functional Requirements?**

The following is a list of functional requirements for a parking lot system:

- The parking lot system should be able to park cars, bikes, and handicapped vehicles.
- The system should be able to calculate the cost of parking for each type of vehicle.
- The system should be able to keep track of the time a vehicle is parked. 
- The system should be able to remove a vehicle from a parking spot.
- The system should be able to check the availability of parking spots and handicapped spots on a specific floor.
- The system should be able to calculate the number of hours a vehicle has been parked.

**Non-Functional Requirements for Parking Lot**

- The system should be efficient and respond quickly to user requests.
- The system should have a well-designed interface to make it easy to use.
- The system should be efficient and respond quickly to user requests



We should have a parent parking spot Class & individual spot classes will derive this spot classes example
- parent parking lot class [ abstract class]
  -individual class derived from parent are
  - =>handicapped
  - =>compact
  - =>large
  - =>2 wheeler


- Parking ticket
  - id
  - parking spot id
  - spot type
  - time


-Terminal[ abstract class]
-individual class derived from parent are
=> Entry Terminal
=> exit Terminal



- Parking strategy / nearest spot
  we can use a min-heap data structure.
- let say we have created a 4 min heap & now we have spot added under this min-heap in order of distance from enterance
- when we call min head from any gate it will give the nearest spot
- mark spot as reserved & moved to reserved spots from available slots
- mark spot as reserved & remove from all min heap structure

Payment Processing
- credit card
- cash



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8vmg02nbik9ecaec9l6.png)
Google Gemini: in 7 Questions and Answers
Tags: ai, news
Published: 2023-12-06 16:51:59

In this article, I answer those 7 questions:

1. What is Google Gemini?
2. What are Gemini Ultra's capabilities in coding?
3. How does AlphaCode 2, based on Gemini, perform in programming competitions?
4. What infrastructure does Gemini 1.0 use for training?
5. In which Google products is Gemini being integrated?
6. How can developers access Gemini Pro?
7. When will Gemini Ultra be available?

----

## What is Google Gemini?

Google Gemini is an advanced AI model capable of understanding, explaining, and generating high-quality code in popular programming languages like Python, Java, C++, and Go​​.

----

{% embed https://www.youtube.com/watch?v=mHZSrtl4zX0 %}

----

## What are Gemini Ultra's capabilities in coding?

Gemini Ultra excels in coding benchmarks such as HumanEval and Natural2Code, making it a leading foundation model for coding, especially in competitive programming and complex math and theoretical computer science​​.


![Google Gamini capabilities](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/piw7578n8b102n1q1k2n.png)



----

## How does AlphaCode 2, based on Gemini, perform in programming competitions?

AlphaCode 2, using a specialized version of Gemini, solves nearly twice as many problems as the original AlphaCode and performs better than 85% of competition participants​​.

----

## What infrastructure does Gemini 1.0 use for training?

Gemini 1.0 is trained on Google's AI-optimized infrastructure using Tensor Processing Units (TPUs) v4 and v5e, designed to be highly reliable, scalable, and efficient​​.

----

## How does Google ensure the safety and responsibility of Gemini?

Google focuses on comprehensive safety evaluations for Gemini, including testing for bias and toxicity, and collaborates with external experts to stress-test and mitigate potential risks. They also use safety classifiers and robust filters to enhance content safety​​.

----

## In which Google products is Gemini being integrated?

Gemini is being integrated into Google products like Bard, Pixel, Search, Ads, Chrome, and Duet AI. For instance, Bard will use a fine-tuned version of Gemini Pro, and Pixel 8 Pro will run Gemini Nano​​.

----

## How can developers access Gemini Pro?

Starting December 13, developers and enterprise customers can access Gemini Pro via the Gemini API in Google AI Studio or Google Cloud Vertex AI. Android developers can build with Gemini Nano using AICore in Android 14 on Pixel 8 Pro devices​.

----

## When will Gemini Ultra be available?

Gemini Ultra is undergoing trust and safety checks and will be available to select customers, developers, partners, and experts for early feedback, before its broader rollout to developers and enterprise customers early next year​​.


---

Godspeed

PS. Follow me on Twitter or LinkedIn and subscript to my **AI YouTube channel**
[https://twitter.com/dom_sipowicz](https://twitter.com/dom_sipowicz)
[https://www.linkedin.com/in/dominiksipowicz/](https://www.linkedin.com/in/dominiksipowicz/)
[https://www.youtube.com/@DominikSipowicz](https://www.youtube.com/@DominikSipowicz)
Advent of Code
Published: 2023-12-06 16:47:32

It's that time of year again - Advent of Code starts! And if this is your first time hearing about Advent of Code, worry not and read on to find out all about it 😊

### What is Advent of Code?

[Advent of Code](https://adventofcode.com/2023/) was created by  Eric Wastl back in 2015 as an advent calendar - but instead of little chocolates you get little  programming puzzles to solve instead!

The puzzles range from beginner friendly and become more advanced as time goes on. You can choose to solve them in any programming language you like.


### But what's the point?

Advent of Code is a nice bit of fun over the Christmas period. 

Make it a bit more of a challenge by competing with a group of friends, co-workers or community group, challenge yourself to complete the puzzles within a set amount of time, use them to boost your understanding while learning a new language, or complete them in each programming language you know - it really is whatever you make of it!

The site hosts a [global leaderboard](https://adventofcode.com/2023/leaderboard), and also allows you to create your own private leaderboards if you wanted to get competitive with them.

The puzzles can also be a nice way of preparing for interview style questions, and get you practicing that problem-solving mindset.


### How can I get involved?

Head over to the calendar section on the [Advent of Code website](https://adventofcode.com/2023) to find the days puzzle.

Puzzles are released daily starting on the 1st of December, midnight EST (5am GMT).

If you're a member of the Codú Discord community, I'll be popping a thread up everyday to allow the community to discuss the daily puzzle - so feel free to to drop a message in to let us know how you got on, what language you used to complete the puzzle, or if you need a bit of help 😊

---

### One Advent not enough?

If you really want to challenge yourself this year, or you're more into cyber security, you may like TryHackMe's [Advent of Cyber](https://tryhackme.com/r/christmas) with the added motivation of prizes

And Scrimba are also joining in the advent fun with [JavaScriptmas](https://scrimba.com/learn/javascriptmas#) - which also has some prizes


---

Have you ever taken part in Advent of Code before? Or will you be giving it a go for the first time this year? Leave me a comment below ⬇️
Adventofcode 🎄 : Day 6 - Forms in React
Published: 2023-12-06 16:46:43

Happy December 6th!! Let's introduce/revise forms in React...

Forms constitute a fundamental component of web applications, serving as a vital channel for user interaction and information acquisition within the application. They not only facilitate user engagement but also play a pivotal role in efficiently collecting valuable data from users. 

Here is an example:

```
<form action={search}>
    <input name="query" />
    <button type="submit">Search</button>
</form>
```

Without forms, numerous tasks we often take for granted on the web—like logging in, signing up, or making purchases—would be  impossible.

There are some key points about forms in React which I will cover at some point within the Adventofcode!!!

I hope that this has helped and remember....**KEEP CODING!!🎄**
Datetime.jsx
Published: 2023-12-06 16:44:05

```
import React from "react";
import { Box } from "@mui/material";
import dayjs from "dayjs";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { DesktopDateTimePicker } from "@mui/x-date-pickers";
import TextField from "@mui/material/TextField";
import Autocomplete from "@mui/material/Autocomplete";
import tz from "../asset/timezones";

const Datetime = ({
  datetime,
  datetimeHandler,
  timezone,
  timezoneHandler,
  side,
}) => {
  const timezoneChangeHandler = (event, newValue) => {
    timezoneHandler(side, newValue);
  };
  const dateTimeHandler = (event) => {
    datetimeHandler(side, dayjs(event));
  };
  return (
    <Box
      sx={{
        width: "400px",
        backgroundColor: "#fae8ff",
        borderRadius: "30px",
        px: "20px",
        py: "40px",
        display: "flex",
        flexDirection: "column",
        justifyContent: "center",
        alignItems: "center",
        my: "20px",
      }}
    >
      <Box>
        <label className="font-semibold">Datetime</label>
        <LocalizationProvider dateAdapter={AdapterDayjs}>
          <DesktopDateTimePicker

            sx={{ width: "100%" }}
            onChange={dateTimeHandler}
            value={datetime}
            // ampm={false}
          />
        </LocalizationProvider>
      </Box>
      <Box sx={{ marginTop: "30px" }}>
        <Autocomplete
          autoHighlight
          value={timezone}
          onChange={timezoneChangeHandler}
          id="controllable-states-demo"
          options={tz}
          sx={{ width: 300 }}
          renderInput={(params) => <TextField {...params} label="Timezone" />}
        />
      </Box>
    </Box>
  );
};

export default Datetime;

```
package.json
Published: 2023-12-06 16:43:26

```
{
  "name": "datetime_epoch_convertor",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.11.1",
    "@emotion/styled": "^11.11.0",
    "@mui/icons-material": "^5.14.18",
    "@mui/material": "^5.14.18",
    "@mui/x-date-pickers": "^6.18.2",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "dayjs": "^1.11.10",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "tailwindcss": "^3.3.5"
  }
}

```
Epoch.jsx
Published: 2023-12-06 16:37:45

```
import React from 'react'
import { Box } from '@mui/material'


const Epoch = ({ epoch, epochHandler}) => {
  const epochChangeHandler = (e) => {
    console.log("epoch value ", e.target.value)
    epochHandler(e.target.value)
  }
  return (
    <Box sx={{ width: "400px", backgroundColor: '#fae8ff', borderRadius: "30px", px: "10px", py: "40px", display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", my: "20px" }}>
      <div className="m-4">
        <label for="epoch" class="block mb-2 text-sm font-bold text-gray-900 ">Epoch</label>
        <input type="number" id="epoch" min={0} value={epoch} class="border border-gray-400 h-12 w-56 text-gray-900 text-sm rounded-lg  bg-fuchsia-100 focus:ring-blue-500 focus:border-blue-500 block  p-2.5   dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="epoch" required onChange={epochChangeHandler} />
      </div>
    </Box>
  )
}

export default Epoch
```
index.js
Published: 2023-12-06 16:31:18

```
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css'


const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);


```
Quick Tip: Counting up to a limit
Tags: miniscript, programming, beginners, tip
Published: 2023-12-06 16:30:13

A very common need is to iterate over all indexes into a list, or more generally, iterate from 0 up to (but not including) some limit or count.  It's tempting to use `range(0, count-1)` for this, but therein lies a gotcha: if `count` is zero, then this will be `range(0, -1)`, which in MiniScript returns `[0, -1]` rather than an empty list.

Fortunately, MiniScript has two easy solutions.

## Use `.indexes`

If your need is actually to iterate over the indexes of some list — let's call it `seq` — then don't use `range(0, seq.len-1)`; instead just use `seq.indexes`.

```
seq = [1,2,3,5,7,11]
for i in seq.indexes
    print "Elem " + i + " is " + seq[i]
end for
```

This is less to type, quick to read, and more clearly expresses your intention.  It's also very MiniScript-idiomatic!

## Use `range(0, count-1, 1)`

The third parameter to `range` is the _step_ value.  If you don't supply a value for this parameter, then it will default to 1 if the end value is greater than the start value, and -1 if it's lesser.  This is how you can count down from 10 to 1 just by doing `range(10, 1)`.  But it's also why `range(0, -1)` returns `[0, -1]`.

However, if you simply specify a step value of 1, then any time the end value is less than the start value, you'll get an empty list!

```
count = input("Count how many? ").val
for i in range(0, count-1, 1)
    print i
end for
```

This is a safe way to express "I definitely want a range of numbers that _increase_ as I go, never decrease, no matter what my start and end values are."  And it's perfect when the end point of your range depends on some variable, like `count - 1`.

## Bonus tip: iterating over _very large_ ranges

Doing the [Advent of Code contest](https://dev.to/joestrout/join-the-miniscript-advent-of-code-contest-3gm5) this year, there have been a couple times where my attempt to use `range` in a `for` loop failed with a "list too large" error.  For example:

```
for i in range(1, 1E9)
    if sqrt(i) % 7 == 0 then result += 1
end for
```
...produces:
```
Runtime Error: list too large [line 1]
```

In such a case, simply switch from a `for` loop to a `while` loop.  Just remember to increment your loop variable, or you'll create an infinite loop!

```
i = 1
while i < 1E9
    if sqrt(i) % 7 == 0 then result += 1
    i += 1
end while
```

Got any other tips for iterating over some range of numbers?  Let us know in the comments below!
Advent of Code #6 (in Crystal)
Tags: crystal, adventofcode
Published: 2023-12-06 16:29:45

Yesterday, I got by without optimizing my program for part 2. Although it took hours to compute, I got the right answer in the end.

Today, that was not an option. The numbers grow so large, that calculating all of them is impractical if not impossible. Thankfully, it was fairly straightforward to come up with a shortcut.

Just like this post, the code is short:
```crystal
input = File.read("input").strip

time, distance = input.split("\n").map do |line|
  line.scan(/\d+/).map(&.[0].to_i)
end

pairs = time.zip(distance)

part1 = pairs.map do |time, distance|
  (1..(time - 1)).map { |x| x * (time - x) }.count { |x| x > distance }
end.product

puts part1

time, distance = input.split("\n").map do |line|
  line.gsub(' ', "").scan(/\d+/)[0][0].to_i64
end

part2 = time - (1..(time - 1)).take_while do |x|
  x.to_i64 * (time - x.to_i64) <= distance
end.size * 2 - (time % 2 == 0 ? 1 : 0)

puts part2
```
pycharm / odoo debugger tips
Published: 2023-12-06 16:24:19


Odoo / pycharm debugger tips : 
1. run a for loop in debugger console 
[x.name for x in ids] -  if you have a collection of ids

2. output two attributes
[x.id, x.name for x in ids]

3. get context -  self.env.context

4. get allowed company ids - self.env.context.get('allowed_company_ids')

5. get current active company - self.env.user.company_id
RoR - extend, < (inheritance), include - know the difference
Tags: ror, ruby, rails, inheritance
Published: 2023-12-06 16:21:25

While going through RoR code I saw `extend, includes and <`. Now for any newbie it is difficult to understand the differences between these. Hence let us understand with a few examples,

`<` 
Is used for inheritance
For example,


```
class Parent
  def some_method
    puts "Hello from Parent!"
  end
end

class Child < Parent
end

my_obj = Child.new
my_obj.some_method #Output: Hello from Parent!
```

In the above example we see that the class Child is able to use some_method defined in the Parent class i.e it inherits the behavior of a parent. This maintains an "is_a" relationship.
Now a child can override a parent's behavior and instead have its own behavior,

```
class Parent
  def some_method
    puts "Hello from Parent!"
  end
end

class Child < Parent
  def some_method
    puts "Hello from Child!"
  end
end

my_obj = Child.new
my_obj.some_method #Output: Hello from Child!
```

`extend`
This keyword gives you the ability to use the class level or module level methods.

```
module SomeModule
  def some_method
    puts "Hello from SomeClass!"
  end
end

class Child
  extend SomeModule
end

Child.some_method #Output: Hello from SomeClass!
```

`include`
include allows you to mix other class functionalities into the included class without having an "is_a" relationship.

```
class SomeClass
  def some_method
    puts "Hello from SomeClass!"
  end
end

class Main
  include SomeClass
end

my_obj = Main.new
my_obj.some_method #Output: Hello from SomeClass!
```

You are still able to override the method in the main class,

```
class SomeClass
  def some_method
    puts "Hello from SomeClass!"
  end
end

class Main
  include SomeClass
  
  def some_method
    puts "Hello from Main!"
  end
end

my_obj = Main.new
my_obj.some_method #Output: Hello from Main!
```

I hope this explains the difference between <, extend and include.
Organize your library with subpath exports 🗄️
Tags: javascript, node, npm, tutorial
Published: 2023-12-06 16:12:34

Sometimes it can be useful to divide the exports of a package into groups. This can help to avoid namespace conflicts and make it clearer what is being exported.

In this article, I'll demonstrate how to achieve imports like this for your library:

```typescript
import { bau } from 'mylib/helpers';
import { useWow } from 'mylib/hooks';
```

It may look like an import from a subdirectory of the library, but it is not.

## 👋 Hello Subpath Exports!

This can be done with so called [subpath exports](https://nodejs.org/api/packages.html#subpath-exports). They were introduced in Node.js v12.7.0. and configuring them is fairly easy. Here's a two-step guide to implement this in your library:

### 1. Create the entry files

In your library directory, create separate files for each subpath you want to expose. For example:

```typescript
// lib/helpers.ts
export const bau = ":-)";
```

```typescript
// lib/hooks.ts
export const useWow = () => "🤯";
```

### 2. Update package.json

Next, update your `package.json` to include the exports field. This provides a [modern alternative](https://nodejs.org/api/packages.html#exports) to the traditional "main" field, allowing multiple entry points to be defined.

```json
{
  "exports": {
    ".": {
      "types": "./dist/main.d.ts",
      "default": "./dist/main.js"
    },
    "./helpers": {
      "types": "./dist/helpers.d.ts",
      "default": "./dist/helpers.js"
    },
    "./hooks": {
      "types": "./dist/hooks.d.ts",
      "default": "./dist/hooks.js"
    }
  }
}

```

> ⚠️ When the "exports" field is defined, all subpaths of the package are encapsulated and no longer available to importers. For example, require('pkg/subpath.js') throws an ERR_PACKAGE_PATH_NOT_EXPORTED error.

That's it, build your library and enjoy your organized imports 🍻

## Conclusion

The "exports" field in the `package.json` provides a clean and modern approach to define the public interface of your package. It not only allows for organized imports but can also encapsulate subpaths, preventing unwanted access.

For further details, you can refer to the Node.js documentation

- [Subpath Exports
](https://nodejs.org/api/packages.html#subpath-exports)
- [Exports Field](https://nodejs.org/api/packages.html#exports)

---

I hope this quick guide has helped you. Feel free to reach out if you have any more questions. Also I appreciate it if you like this article, as it really helps me to stay motivated. Thank you! 

Happy coding! 🚀
Introducing Azure Co-pilot
Tags: azure, techtalks, generativeai
Published: 2023-12-06 16:11:21

Azure Co-pilot is a preview service that uses AI to help you manage your Azure resources and applications. You can interact with Azure Co-pilot using natural language and ask questions, perform tasks, or get recommendations. Azure Co-pilot can also generate code, queries, and commands for you based on your goals and preferences. Azure Co-pilot is powered by large-scale, generative AI models that can understand and produce natural language and code. Azure Co-pilot is designed to be your AI companion and assistant for Azure operations and management.

{% youtube ff0vm0mvrY8 %}