teleren/devto huggingface dataset:
CRUD Operations with PyMongo:
Tags: python, mongodb, pymongo
Published: 2023-09-17 14:31:37

**CRUD Operations with PyMongo:**

CRUD (Create, Read, Update, Delete) operations are fundamental when working with databases. PyMongo, the official MongoDB driver for Python, provides methods to perform these operations seamlessly.

- Creating Documents: Creating documents involves inserting new data into a collection. PyMongo's `insert_one()` and `insert_many()` methods accomplish this.
```python
# Insert a single document
new_doc = {"name": "Ajit", "age": 28}
collection.insert_one(new_doc)

# Insert multiple documents
new_docs = [
    {"name": "Bob", "age": 32},
    {"name": "Charlie", "age": 25}
]
collection.insert_many(new_docs)
```

- Reading Documents: Reading documents involves querying the database to retrieve data. PyMongo's `find()` method and other query methods allow you to retrieve data based on specific criteria.
```python
# Find all documents
all_docs = collection.find()


# Find documents that match a specific condition
young_people = collection.find({"age": {"$lt": 30}})
```

- Updating Documents: Updating documents allows you to modify existing data. PyMongo's `update_one()` and `update_many()` methods help you achieve this.
```python
# Update a single document
collection.update_one({"name": "Ajit"}, {"$set": {"age": 28}})

 
# Update multiple documents
collection.update_many({"age": {"$lt": 30}}, {"$inc": {"age": 1}})
```

- Deleting Documents: Deleting documents involves removing data from a collection. PyMongo's `delete_one()` and `delete_many()` methods enable you to delete documents based on specified criteria.
```python
# Delete a single document
collection.delete_one({"name": "Alice"})


# Delete multiple documents
collection.delete_many({"age": {"$gt": 30}})
```
Setting the Stage: Installing MongoDB and Python:
Tags: python, mongodb, pymongo
Published: 2023-09-17 14:30:12

**Setting the Stage: Installing MongoDB and Python:**

**1. Installing MongoDB:**

- macOS: 
Install MongoDB on macOS using Homebrew. Homebrew is a package manager that simplifies software installation. The following commands tap into the MongoDB formula, install the Community Edition, and start the MongoDB service.
```bash
brew tap mongodb/brew
brew install mongodb/brew/mongodb-community
brew services start mongodb/brew/mongodb-community
```

- Windows: 
Download the MongoDB installer from the official website and follow the installation steps. MongoDB can be set up as a Windows service during installation.

- Linux (Ubuntu): 
On Ubuntu, you can install MongoDB using apt by adding the repository key, updating the repository list, and then installing the MongoDB packages. The service can be started with systemctl.

```bash
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
```
**2. Integrating Python and MongoDB:**
PyMongo is a Python driver for MongoDB that provides an interface to interact with MongoDB databases using Python code. You can install pymongo by using the below command.
```python
pip install pymongo
```
**3. Connecting to a MongoDB instance using PyMongo:** 
Here's how you can connect to a MongoDB instance and perform basic operations:
This will create DB in mongo or you can create it directly in python code and use it as below.
```python
from pymongo import MongoClient


# Connect to the default local MongoDB instance
client = MongoClient() 

# Access a database and a collection
db = client['mydatabase']
collection = db['mycollection']
```
PSRule module for Azure DevOps available for feedback
Tags: azure, devops, opensource, security
Published: 2023-09-17 14:21:33


I have been a long time user of Azure DevOps and I have been using the Microsoft PSRule module for checking my Bicep templates for quite a while now. I like the flexible rule engine allowing to check for a wide range of issues. Now I have developed a PSRule module for checking Azure DevOps projects for common configuration issues. The module is available on [GitHub](https://github.com/cloudyspells/PSRule.Rules.AzureDevOps) and can be installed from the PowerShell Gallery.

![PSRule run with PSRule.Rules.AzureDevOps module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7abab43zf99nz1dzo20.png)

Please note it is in early stage of development so I am very much looking forward to your feedback and contributions.

## Using the module

To use this module, you need to have _PSRule_ installed. You can install it from the PowerShell Gallery:

```powershell
Install-Module -Name PSRule -Scope CurrentUser
```

Once you have PSRule installed, you can install this module from the PowerShell Gallery:

```powershell
Install-Module -Name PSRule.Rules.AzureDevOps -Scope CurrentUser
```

Once you have both modules installed, you can run an export of your Azure DevOps project and run the rules against it. The `-PAT` value needs to be an Azure DevOps Personal Access Token with sufficient permissions to read the project data.

```powershell
Export-AzDevOpsRuleData `
    -Organization "MyOrg" `
    -Project "MyProject" `
    -PAT $MyPAT `
    -OutputPath "C:\Temp\MyProject"
Assert-PSRule `
    -InputPath "C:\Temp\MyProject\" `
    -Module PSRule.Rules.AzureDevOps
```
What Crazy Idea Actually Worked?
Tags: discuss, watercooler
Published: 2023-09-17 14:17:56

What's the silliest solution to a problem that actually worked?

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
I created overbyte - An Online code editor
Tags: git, vscode, github, editor
Published: 2023-09-17 14:10:42

Hey I am thinking about making a code editor online what all would you guys prefer ... i have already added a feature to commit github repos and automatically saving newly edited code in the cloud .... please tell me more features and how i could implement it (_note: i tried to add a terminal but it was too damn irritating _)
if you want to try a mvp like thing go [overbyte.netlify.app/?repo=githubusername/repo](overbyte.netlify.app/?repo=username/repo) to
𝗗𝗼𝘂𝗯𝗹𝗲 𝗡𝗲𝗴𝗮𝘁𝗶𝗼𝗻 (!!)
Tags: javascript, webdev, funfacts, programming
Published: 2023-09-17 13:57:06


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

Have you ever come across the `!!` or "not not" operator? 
Well, I encountered it this morning.

In hashtag #JavaScript, using the double negation (!!) in front of a value or expression is _a shorthand technique to convert a value into its boolean equivalent._

```
const falsyValue = NaN;
const truthyValue = 'JavaScript';
```

**`!` means NOT.**

- The **first** `!` (not) operator converts a value into a Boolean and reverses it, changing truthy values to `false` and falsy values (e.g., `false`, `0`, `null`, `undefined`, `NaN`, or an empty string) to `true`.

```
!falsyValue; // true
!truthyValue // false
```


- The **second** `!` operator negates the result of the first `! `operation, converting the value back to its original boolean representation. If the original value is truthy, it remains `true` after the double negation, and if it is falsy, it becomes `false`.

```
!!falsyValue; // false
!!truthyValue // true
```
As much as we love our engineering industry, it also has some downsides
Tags: discuss, programming, mentalhealth, softwaredevelopment
Published: 2023-09-17 13:52:49

I’ll share with you some of the issues I have been dealing with as an engineer and an engineering leader throughout my career.

## Perfecting my solutions to an extent

I could particularly see this as an issue when I was building something visual. I was not satisfied with the result. This color should be like this, this font should be like that, etc.

And then this also transferred to code as well. I was trying too hard to make things “perfect”, and I was hurting my progression toward getting things done.

Right now, I still find myself sometimes trying to “perfect”, but I remember how important progress is and I try to quickly readjust my mindset. I also have a quote on one of my shirts to remind myself: “Progress over Perfection”.

## Not making decisions fast enough

As engineers, there are so many micro-decisions that we are making daily. I have found myself procrastinating and making decisions a lot of times.

Decisions like:

- naming the variable or a function,
- should we split the file/class differently or not,
- what approach to use to solve a particular problem,
- how to properly test the solution.

This brought me to unnecessary stress, that I could avoid if I would just make a decision.

## Procrastinating on tasks, hard conversations and giving feedback

I was guilty of this a lot of times, the first one is still the case sometimes. And the second and third were obvious when I first started with engineering management.

I saw things that needed to improve but hesitated to have the conversation and give feedback. I thought that things were going to get better eventually. But I was wrong. Therefore it’s really important to react swiftly and not procrastinate.

## Feeling like an imposter

This was the case, especially at the beginning of my career. I thought that engineers with a lot more experience have such amazing abilities. That it would be hard or almost impossible for me to develop.

But then I found out that we are all learning consistently. And I wasn't that far from that. That sparked me to learn even more and be even better every day.

Can you relate to them?

> This is part of the newsletter article on my Engineering Leadership newsletter. If you liked this, you are going to love my newsletter. Join here: [Engineering Leadership newsletter](https://newsletter.eng-leadership.com/), 8600+ engineering leaders are already reading it!
TypeScript Boilerplate
Tags: boilerplate, typescript, javascript, node
Published: 2023-09-17 13:45:19

I present this initial entry both as a resource for my future self and as a source of interest for those who share my passion.

I have created a specific repository with the purpose of establishing a solid foundation from which to start projects using TypeScript from scratch, focused on server-side development (backend).

The repository in question is hosted at the following address:

https://github.com/ProfeJulianLasso/boilerplate-project-typescript

## What does this boilerplate offer?

The focus of this project covers four fundamental aspects:

[**Unit Testing with Jest**](https://jestjs.io/): The ability to perform unit tests using the powerful Jest tool has been incorporated.

[**Static Code Analysis with ESLint**](https://eslint.org/): The code undergoes rigorous static analysis through ESLint to ensure its quality and compliance with standards.

[**Commit Management with Conventional Commits**](https://www.conventionalcommits.org/): The Conventional Commits methodology is adopted to maintain a clear and structured record of changes with the help of [commitlint](https://commitlint.js.org/).

[**Code Formatting with Prettier**](https://prettier.io/): The code is automatically formatted with Prettier, ensuring consistency in writing style.

In addition to these aspects, the repository makes use of [**Husky**](https://typicode.github.io/husky/) to automate certain tasks when making commits and pushing to the repository.

I invite everyone interested to collaborate on this project, and I would greatly appreciate any comments or observations you can provide.

This is a valuable resource for both those who want to start projects with TypeScript from scratch and those looking to improve their skills in server-side development. I am proud to share this contribution with the community, hoping that it will be beneficial for other professionals and technology enthusiasts.
Simple markdown website generation with Rino Docs🚀
Tags: webdev, javascript, tutorial, opensource
Published: 2023-09-17 13:23:06

## I am lazy! Kinda... 😴

Do you find yourself spending too much time adding new pages to your documentation website? If so, you're not alone! Maintaining documentation can be a tedious task, involving copying and pasting files and writing markdown content. So I have created a simple markdown documentation tool, Rino Docs.

## What is Rino Docs? 🤪
Rino Docs is a simple markdown documentation tool powered by Rino.js. It simplifies the process of adding new documentation pages and enables you to customize the design of your documentation website. 

Rino Docs reads markdown files from the `./src/mds` directory and generates HTML pages in the `./dist` directory. What sets it apart is its ability to automatically generate a sidebar component with a list of links for all your documentation pages. No more manual linking!

Installation:
```
npm create rinodocs@latest
```
Development & Build:
```
npm run dev
```
Sitemap generation:
```
npm run sitemap
```

![Markdown Webapge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozv69rjwioshgy0zexz5.PNG)

## Organizing Sidebar Links 🧐

You might wonder how the links in the sidebar are ordered. It's quite simple! Just add a number at the beginning of your markdown file names. Rino Docs will automatically sort the links based on the numeric order of the file names. For example, naming a file as '1. Home' will place it at the top of the sidebar.

![Sidebar of Rino documentation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gcbifst4k3e5t04xdr9d.PNG)

## Customizing Your Documentation Website ✍️

Want to customize the template of your documentation website? You have the flexibility to do so. Simply edit the files located in `./src/pages/` and `./src/components/`. If you need to support multiple languages or make any other adjustments, feel free to edit any files within the project.


![Rino document website](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbzwtncppf6fk9fn1zwx.PNG)

## For the last 🚀
Don't let documentation drain your time and energy. Give Rino Docs a try and simplify your documentation workflow today!

## Useful Links 🌐

- [Rino Docs Github Repository](https://github.com/rinojs/rinodocs)
- [Example of Rino Docs](https://rinojs.org/)
Laravel 10 Get env Variable in Blade Controller
Published: 2023-09-17 13:18:05

## Laravel 10 Get env Variable in Blade Controller

To get an environment variable in a Laravel controller, you can use the env() helper function. The syntax is:

`env('VARIABLE_NAME')
`
For example, to get the value of APP_NAME, you can use:

`$name = env('APP_NAME')
`

To get an environment variable in Laravel Blade, you can use the env() function. The syntax is env('VARIABLE_NAME'). If the variable exists, its value will be returned. If the variable doesn't exist, the default value will be returned, which is null by default.

Read More [Laravel 10 Get env Variable in Blade Controller](https://www.tutsmake.com/how-to-get-env-variable-in-blade-or-controller)
What are hooks in React?
Tags: webdev, react, beginners, programming
Published: 2023-09-17 12:58:48

Hey there! Today, let's dive into the world of React Hooks. 

**So, What are React Hooks?**

Alright, let's start with the basics. React Hooks are functions that let you use state and other React features in functional components. Before hooks, if you wanted to use state or lifecycle methods, you had to use class components. Hooks changed the game, making it possible to do everything you could with class components, but with functional components.

**Why Use Hooks?**

Great question! Hooks make it easier to reuse stateful logic without changing your component hierarchy. This means you can separate logic from presentation. Also, they simplify complex components and encourage a cleaner, more readable codebase.

**The Popular Hooks**

Now, let's talk about some of the popular hooks:

1. **useState:** This one lets you add state to your functional components. No more class components just for state!

2. **useEffect:** It replaces the lifecycle methods `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount`. It helps you manage side effects in your functional components.

3. **useContext:** If you're working with Context API in React, this hook is a lifesaver. It allows you to subscribe to React context without introducing nesting.

4. **useRef:** This hook is used to create mutable objects that persist throughout the component's lifetime. It's great for things like DOM manipulation.

5. **useReducer:** It's an alternative to `useState` for more complex state logic. If your state depends on the previous state, `useReducer` might be your friend.

6. **Custom Hooks:** You can also create your own hooks! They're a way to extract and reuse stateful logic from your components.

**How to Use Hooks?**

Alright, let's get practical! To use a hook, you simply call it inside your functional component. For example, to use `useState`, you'd write something like:

```javascript
const [state, setState] = useState(initialState);
```

That's it! Now, `state` holds your current state, and `setState` is a function to update it.

**Important Tips**

1. **Call Hooks at the Top Level:** Don't call hooks inside loops, conditions, or nested functions. Always call them at the top level of your React function.

2. **Only Call Hooks from React Functions:** You can call hooks in custom hooks, but also ensure they're called from React function components or custom hooks.

3. **Follow Naming Conventions:** Always start your custom hooks with the word "use" to comply with the convention.

**Conclusion**

And there you have it! React Hooks are a fantastic addition to the React ecosystem that allow you to manage state and side effects in functional components. They make your code cleaner, more modular, and easier to reason about.

Give them a try in your next project, and you'll see how they can simplify your React code. Happy coding! 😊
Laravel 10 Get Current Route Name in Blade & Controller
Published: 2023-09-17 12:56:34

You can get the current route name in Laravel using the route() function. You can pass the route name as an argument to the function, and it will return the route using that name.

## Laravel 10 Get Current Route Name in Blade & Controller

Here are some examples of getting the current route name in Laravel:

- $routeName = Route::getCurrentRoute()->getPath(); print($routeName)
- $name = $route->getName(); dd($name)
- $name = Route::currentRouteName(); dd($name)

Read More [Laravel 10 Get Current Route Name in Blade & Controller](https://www.tutsmake.com/how-to-get-current-route-name-in-laravel)
2nd day of my development
Published: 2023-09-17 12:48:45

### Today:
1. just duplicated a previous project using Nest&Prisma, did some modifications, and set up a local database through Docker
, successfully launched the first API to create a record.


### Problems:

- before, I had used Sqlite because it is easy to learn and use, but in this project, I think it's better to use PostgreSQL, as I am using Prisma, so for many situations, I can just use functions provided by Prisma, instead of learning new acknowledgment of PostgreSQL now.
- there was also another thought that came up to me. if you are going to write a simple API such as creating a record, you have to code in controller, service, and dto. I heard that Ruby on Rails is more efficient, but I don't know if it has code recommendations and official plugins for PostgreSQL
- for now, I think it's better to use Nest.js, I can improve my skills in the backend and database through this project soon.

### Tasks for tomorrow:

- setup Axios and React-Query in my frontend project
- post and fetch data from the backend
Laravel 10|9 Enable & Get Query Log Tutorial
Published: 2023-09-17 12:41:57

## Laravel 10|9 Enable & Get Query Log Tutorial

The getQueryLog() method in Laravel allows you to retrieve database queries that were executed during a request. This can be useful for debugging and analyzing SQL queries.

To get the query log, you can use the DB::enableQueryLog() method to enable the query log. This method stores all executed queries in the cache. Then, you can use the DB::getQueryLog() method to access the queries.

You can also log queries by registering a query listener using the DB::listen method. This method can be used in the boot method of an AppServiceProvider class.

Logging queries can help you debug issues such as:

- Users not getting the expected output
- The application getting a slow response from the database server
- Not getting any output because something is wrong with the query

Laravel logging is based on "channels". Each channel represents a specific way of writing log information. For example, the single channel writes log files to a single log file, while the slack channel sends log messages to Slack.

Read More [Laravel 10|9 Enable & Get Query Log Tutorial](laravel-get-query-log-example)
Learn basic algorithms and data structures using Go - for free
Tags: go, algorithms, datastructures, learning
Published: 2023-09-17 12:34:02

Hey Devs! 👋

Ever felt bogged down by complex coding platforms? I get the whole "getting into FAANG" grind on platforms like LeetCode. But I realized, before diving deep, you need a solid foundation in simple algorithms and DS. That's why I built Algoblaze - focusing on letting users iterate over these core concepts repeatedly. Because, in my experience, the more you repeat, the more it sticks.

And I'm releasing it for **free**. Why? It's so basic that charging for it just doesn't feel right. Plus, the foundational knowledge of algorithms and DS is available everywhere online. 
So, give it a shot! 👉 [algoblaze.com](https://algoblaze.com)

Interested in the backstory of the app or its architecture? 
Check out my [blog post](https://kfurgol.github.io/thoughts/devlog/2023/09/16/mvp-deployed.html).

Also, I'm playing with the idea of open-sourcing the code. What do you think?

Stay connected:
🌍 [kfurgol.dev](https://kfurgol.dev)
🐦 [X (formerly Twitter)](https://twitter.com/kfurgol)
🔗 [LinkedIn](https://www.linkedin.com/in/kfurgol/)
🐙 [GitHub](https://github.com/kfurgol)

Happy coding!
Bringing it all together - Pokedex Project 5
Published: 2023-09-17 12:18:20

Thanks for sticking with this series all the way up to here. The fruits of our labour are done and it's time to showcase the final product. 

![Final image](https://github.com/Danarkey/phase-1-project/blob/main/blog%20screenshots/final-1.JPG?raw=true)

![Final image with Tyranitar input](https://github.com/Danarkey/phase-1-project/blob/main/blog%20screenshots/final-2.JPG?raw=true)

As you can see once a user has input a Pokemon into the search field the species, typing and stats update below.

After the final push into github and making the github pages, the favicon and background image were no longer loading. 

![No background image](https://raw.githubusercontent.com/Danarkey/phase-1-project/95559bc7f81ebdc1cff5c65df85c105ca15bdf51/blog%20screenshots/live-test-no-bg.JPG)

This was an easy fix though as I forgot that github doesn't like it when you start your URLs with a /

##Future features
In the future I do hope to add in that functionality where you press the speaker button and you can hear the cry of the Pokemon. Unfortunately that isn't apart of the API but I did find an external site that has all of the saved.

Additionally I would also like to have it so that if you click on the dropdown preview, the input field will auto populate. After hours of trying to get that to work I decided to throw in the towel and focus on finishing the other aspects of the project such as this blog series and the video tutorial on how to use the app. 

If you want to see the app for yourself you can find it [here.](https://danarkey.github.io/phase-1-project/)