teleren/devto huggingface dataset:
Signing in with google
Published: 2023-10-29 16:08:50

I use node.js in my project and try to make the site can be signed in with google, but after choosing the email(account), it redirect to th right page successfully but without signing in.

passport.js:

```
passport.use(new GoogleStrategy({
    clientID: process.env.GOOGLE_CLIENT_ID,
    clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    callbackURL: "http://localhost:4000/auth/google/callback",
    passReqToCallback: true
},
    function (request, accessToken, refreshToken, profile, done) {

        done(null, profile);
    }
));
```
index.js:

```
router.get('/auth/google',
  passport.authenticate('google', {
    scope: ['email', 'profile']
  }
  ));

router.get('/auth/google/callback',
  passport.authenticate('google', { 
    session: false,
    failureRedirect: 'signup' }),
  (req, res) => {
    res.redirect('/')
  });
```
If I put : 'session:true' an error occurs: The result:

```
[nodemon] app crashed - waiting for file changes before starting...
```
I cann't know what is happening, the redirect is successful to the page http://localhost:4000/ but it doesn't open because [nodemon] app crashed, and
when set session: false, no error occurs but without signing in.
Let me introduce a new PHP tool
Tags: php, programming, beginners
Published: 2023-10-29 15:59:17

I wanted to share with you a tool I recently developed called [ServBay.dev](https://www.servbay.dev/).

It's designed to make PHP development easier by integrating multiple versions of PHP, MySQL,MariaDB, PostgreSQL, as well as Redis and Memcached. The reason I created this software was because I couldn't find the specific PHP version I needed in MAMP and XMAMP. Their PHP versions were a bit outdated and didn't include the latest updates. I figured there must be other PHP developers out there facing the same issue, so I decided to build ServBay.

The best part is, you don't need to worry about setting up the environment. Just download and install ServBay, and you can start using it right away. It's also beginner-friendly, perfect for those who are new to PHP development.

The first version is already live, and if anyone is interested, feel free to download and give it a try.

I'm open to any feedback, suggestions, or opinions you may have.

Thank you all for your support.
Jump Streets Movers Inc
Published: 2023-10-29 15:50:53

Jump Streets Movers Inc is the go-to moving company in Chelsea for all your relocation needs. Our team of professional movers provides a wide range of services to ensure a smooth and efficient move. We specialize in residential and commercial moves, offering affordable rates and top-notch service. Whether you need to move your home or office, our experts are here to help. Our services include packing and unpacking, interstate moving, and furniture relocation. We pride ourselves on being reliable, punctual, and dedicated to making your move a breeze. At Jump Streets Movers Inc, we understand the stress that can come with moving. That's why we're committed to providing you with a hassle-free experience. Contact Jump Streets Movers Inc.

Business Address: 73 Cook Ave, Chelsea, MA 02150, United States
Business Phone Number:  617-490-0276
Website:  [http://www.jumpstreetmovers.com/](http://www.jumpstreetmovers.com/)
Business Hours: [Mon-Sat 8AM–8PM]
SQL - Use Views for Simplified and Reusable Queries
Tags: sql, sqlserver, programming, tutorial
Published: 2023-10-29 15:30:00

Views are virtual tables created by defining a query in your database. They allow you to simplify complex queries, enhance data security, and promote code reusability. Here's how you can benefit from using views:

- **Simplify Complex Queries:** Instead of writing long and complex SQL queries whenever you need specific data, create a view that encapsulates the query logic. This makes your SQL code more concise and easier to read.

   ```sql
   -- Create a view to simplify the query for retrieving product sales
   CREATE VIEW ProductSales AS
   SELECT
       p.product_id,
       p.product_name,
       SUM(o.quantity * o.unit_price) AS total_sales
   FROM
       products p
       JOIN order_details o ON p.product_id = o.product_id
   GROUP BY
       p.product_id, p.product_name;

   -- Now, you can query the view to get product sales
   SELECT * FROM ProductSales;
   ```

- **Enhance Data Security:** Views can restrict access to certain columns or rows, providing an additional layer of security. Users can interact with the view without having direct access to the underlying tables.

   ```sql
   -- Create a view with restricted columns for sensitive data
   CREATE VIEW EmployeesSensitive AS
   SELECT employee_id, first_name, last_name
   FROM employees;

   -- Grant access to the view instead of the underlying table
   GRANT SELECT ON EmployeesSensitive TO some_user;
   ```

- **Code Reusability:** Views can be reused in multiple queries or incorporated into other views. This promotes code reusability and consistency across your SQL codebase.

   ```sql
   -- Create a view based on the ProductSales view
   CREATE VIEW TopSellingProducts AS
   SELECT *
   FROM ProductSales
   WHERE total_sales > 10000;

   -- Reuse the TopSellingProducts view in various reports and queries
   SELECT * FROM TopSellingProducts;
   ```

- **Performance Optimization:** In some cases, views can improve performance by precomputing complex calculations or aggregations, allowing you to query the view instead of repeating those operations in multiple places.

When using views, remember that they are virtual representations of data, and the underlying data may change. Ensure that your views are up to date and accurately reflect the data you intend to query. Additionally, use views judiciously and avoid creating overly complex or deeply nested views, as they can make your database schema harder to maintain and understand.
HacktoberFest'23 Maintainer
Tags: hack23maintainer, hacktoberfest23
Published: 2023-10-29 14:53:32

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a maintainer. Is this your first Hacktoberfest, or have you maintained in others? Feel free to embed your GitHub account by using {% embed LINK %} -->
I'm Piyush Kumar Das, a Web Developer, Programmer, and Tech Writer. This was my debut as a Hacktoberfest maintainer, where I guided contributors and reviewed their open-source contributions. It's been a rewarding experience collaborating with the community. Check out my [GitHub](https://github.com/piyushkdas0611).



### Project
<!-- Tell us about the repository that you hosted. What processes did you set up to review and merge pull requests? Feel free to embed your GitHub repo by using {% embed LINK %} -->
I maintained the "[Profile Card Generator](https://github.com/piyushkdas0611/Profile-Card-Generator)" repository, a user-friendly tool for crafting stylish profile cards, ideal for portfolios and websites. Built with HTML, CSS, and JavaScript, it empowers users to generate customized cards with ease. This project adds a creative touch to personal branding and enhances online presence.

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->
This month, my major accomplishment was my inaugural participation as a maintainer during Hacktoberfest. It was an insightful experience where I learned new skills, collaborated with contributors, and had fun while doing so. One notable challenge was dealing with merge conflicts, which initially seemed daunting. However, with the help of Chat GPT and online resources, I successfully resolved them, enhancing my GitHub proficiency. Overall, it was a rewarding and educational journey.

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your project goals changed since publicly maintaining it? -->
Before Hacktoberfest 2023, I had a solid foundation in web development and a basic understanding of version control systems. Throughout the event, my knowledge of version control systems significantly improved, allowing for more efficient project management. While my project goals remained the same, the experience encouraged me to enhance it with additional features and improvements. It reinforced my commitment to maintaining and evolving the "Profile Card Generator" project while furthering my expertise in open source collaboration.
Is the Tech Boom Over?
Tags: discuss, jobs, programming, beginners
Published: 2023-10-29 14:52:36

I spoke with a recent Computer Science graduate from a well-regarded United States university. She sent out over 200 applications and got only 7 interviews.

She is very good and knows what she is doing. She works at the same company I work at, and her coworkers have only been impressed.

Ten years ago these people would have had job offers before graduating.

Is the excitement and opportunity surrounding Computer Software development over?
Clearing the Path to Clutter-Free Living
Published: 2023-10-29 14:20:23

Entrümpelung Stuttgart, a term that translates to "decluttering" or "clearing out" in the city of Stuttgart, is a valuable and sought-after service for both residents and businesses alike. This process involves the systematic removal of unwanted items, old furniture, debris, and various items that may be cluttering homes, offices, or commercial spaces in Stuttgart.

The need for **[Entrümpelung Stuttgart](https://ruempelschwab.de/)** has significantly grown in recent years due to the desire for more organized, spacious, and aesthetically pleasing living and working environments. Whether it's a residential space that needs a thorough cleanup or a commercial establishment aiming for an improved and more efficient layout, Entrümpelung services in Stuttgart can help achieve these goals.

Professionals in this field are equipped with the expertise and tools to efficiently remove, recycle, or dispose of items in an environmentally responsible manner. They can transform chaotic, cluttered spaces into clean, organized areas, making life more comfortable and work more productive.

Entrümpelung Stuttgart services are not only about decluttering but also about enhancing the overall quality of life and functionality of a space. Whether it's a home, an office, a retail space, or any other property, entrusting the task to experienced professionals can lead to significant improvements in the ambiance and utility of the space.
Clearing the Path to Clutter-Free Living
Published: 2023-10-29 14:20:07

Entrümpelung Stuttgart, a term that translates to "decluttering" or "clearing out" in the city of Stuttgart, is a valuable and sought-after service for both residents and businesses alike. This process involves the systematic removal of unwanted items, old furniture, debris, and various items that may be cluttering homes, offices, or commercial spaces in Stuttgart.

The need for **[Entrümpelung Stuttgart](https://ruempelschwab.de/)** has significantly grown in recent years due to the desire for more organized, spacious, and aesthetically pleasing living and working environments. Whether it's a residential space that needs a thorough cleanup or a commercial establishment aiming for an improved and more efficient layout, Entrümpelung services in Stuttgart can help achieve these goals.

Professionals in this field are equipped with the expertise and tools to efficiently remove, recycle, or dispose of items in an environmentally responsible manner. They can transform chaotic, cluttered spaces into clean, organized areas, making life more comfortable and work more productive.

Entrümpelung Stuttgart services are not only about decluttering but also about enhancing the overall quality of life and functionality of a space. Whether it's a home, an office, a retail space, or any other property, entrusting the task to experienced professionals can lead to significant improvements in the ambiance and utility of the space.
Do You Ever Get Sentimental Over Your Old Websites? 💗
Tags: website, html
Published: 2023-10-29 14:17:46

I recently bought my own domain and web hosting. I also looked through my old files the other day for inspiration on how I should design my new website. I found some screenshots of one of the old webpages which I had made on Blogger. Blogger offered free hosting and free webpages which did not require me to code the webpage from scratch, I only needed to insert some code to add images, links, dividers, bullets and write some text here and there. My site was so terrribly cute, too cute not to share! 🤗<br><br>

![An avatar resembling me and my cat](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/94m5perl3ncf62zklaqz.png)

![A picture resembling "my" house in pixels](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/em3440wq3a6sjq3qk4ab.png)

Human Age (human-age.com) was a free browser game where you started in the prehistoric age and then progressed up to 6 more ages (if you wanted to) with the next age more advanced than the prior. Below I show my love for the 1st age which was my favourite due to its more simplistic gameplay compared to the more complex gameplay of the more advanced ages. I could relax and keep a lovely flickering campfire in my camp which I loved to look at for hours on end <b><3</b><br><br>

![My poems page 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bl9sfr150tj1qyqotnd0.png)

![My poems page 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90vt21a7iuup6sad6eq8.png)<br>
My poems actually got published in the newspaper in the game!

I hope, in fact I am positive, that I will be able to make an even better website than I did when I was 16 years old. This time I am making my website from scratch 😳 Wish me luck! 😅

Disclaimer: The images used on my old website where from glitter-graphics.com.
Can you use select_related and prefetch_related with Abstract Base Classes in Django?
Tags: django, python
Published: 2023-10-29 14:14:30

Yes!! Here you have an example 👇

You can use `QuerySet.prefetch_related` or `QuerySet.select_related` with Abstract Base Classes in Django.

Let's say we have these models:

```python

class Country(models.Model):
    name = models.CharField(max_length=200)

    def __str__(self):
        return self.name

class AbstractPerson(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)

    class Meta:
        abstract = True

class AbstractAddress(models.Model):
    street = models.CharField(max_length=100)
    city = models.CharField(max_length=50)
    state = models.CharField(max_length=2)
    zip_code = models.CharField(max_length=10)
    country = models.ForeignKey(Country, on_delete=models.CASCADE)

    class Meta:
        abstract = True

class AbstractPhoneNumber(models.Model):
    phone_number = models.CharField(max_length=15)

    class Meta:
        abstract = True

class Contact(AbstractPerson, AbstractAddress, AbstractPhoneNumber):
    email = models.EmailField()

    def __str__(self):
        return f"{self.first_name} {self.last_name} - {self.country}"
```


If you make this query you wouldn't have a N+1 issue:

```python
> Contact.objects.select_related("country").get(id=1).country
```

You have one query only. The generated SQL is:


```sql
SELECT app_contact.id,
       app_contact.first_name,
       app_contact.last_name,
       app_contact.street,
       app_contact.city,
       app_contact.state,
       app_contact.zip_code,
       app_contact.country_id,
       app_contact.phone_number,
       app_contact.email,
       app_country.id,
       app_country.name
  FROM app_contact
INNER JOIN app_country
    ON (app_contact.country_id = app_country.id)
 WHERE app_contact.id = '1'
```
Simplifying Database Interactions with Django's ORM
Published: 2023-10-29 13:56:03

As a Django enthusiast, I've always been fascinated by the power and simplicity of the Django ORM (Object-Relational Mapper). In my recent project, I encountered a significant challenge that highlighted the elegance of the Django ORM in simplifying complex database interactions.

The project involved building a robust content management system for a growing e-commerce platform. One of the crucial requirements was to implement a dynamic product recommendation feature based on customer browsing history. This necessitated efficient data retrieval and manipulation from multiple database tables.

Django's ORM came to the rescue with its intuitive querying capabilities. Leveraging the ORM's expressive syntax, I swiftly constructed a complex query that aggregated customer data, their purchase history, and browsing patterns. By utilizing Django's `filter`, `annotate`, and `aggregate` functions, I could extract the relevant data points and compute personalized product recommendations for each user.

A particular snippet that I am proud of is the concise yet powerful query I used to retrieve top-selling products within a specific category. Here's a simplified version of the code:

```python
from django.db.models import Count

def get_top_products_in_category(category_name, limit=5):
    top_products = Product.objects.filter(category__name=category_name) \
        .annotate(num_purchases=Count('purchases')) \
        .order_by('-num_purchases')[:limit]
    return top_products

```


This snippet efficiently fetches the top products in a given category by counting the number of purchases for each product and ordering the results based on the purchase count. The seamless integration of filters, annotations, and ordering exemplifies the elegance of the Django ORM in simplifying complex database operations.

Through this experience, I solidified my appreciation for Djangos robust ORM and its ability to streamline intricate database interactions. Its clear and expressive syntax not only facilitated the implementation of intricate features but also enhanced the overall maintainability and scalability of the project.

In conclusion, Djangos ORM remains a fundamental pillar in my development toolkit, consistently empowering me to build efficient and scalable web applications while keeping the focus on delivering exceptional user experiences.
Hacktoberfest 2023 - My Contribution Journey
Tags: hacktoberfest23, hack23contributor, hacktoberfest, opensource
Published: 2023-10-29 13:50:36

## What is Hacktoberfest?
Each year, the tech world comes alive with Hacktoberfest, an exciting event that inspires developers to dive into open-source projects throughout the entire month of October. This year, I've enthusiastically embraced the challenge, eager to discover new skills and insights along the way.

## My Hacktoberfest Experience:
I participated in Hacktoberfest by making contributions to various open-source projects on GitHub.
I made **six pull requests** that got **merged** which was more than the _minimal requirement(4 PRs)_ to meet the Hacktoberfest requirements.

## Accomplishments and Notable Moments:
The satisfaction of seeing my contributions merged into projects was a major highlight.
I improved my skills in version control, collaborating with others, and working with different programming languages.

## My Learnings:
1. I acquired an understanding of the vital role clear and effective communication plays in the context of open-source projects.
2. Collaborative efforts and teamwork emerged as crucial elements when engaged in code-related activities with peers.
3. Through my contributions, I developed a growing sense of confidence in my ability to make a tangible impact on real-world projects.

## Conclusion:
My journey through Hacktoberfest proved to be an invaluable learning experience, and I wholeheartedly recommend fellow developers to partake in this event.
Open source embodies the spirit of giving back to the community, and Hacktoberfest serves as an ideal platform to actively contribute and be a part of this collaborative tech-fest.
Difference between reverse() and reverse_lazy() in Django
Tags: django, python
Published: 2023-10-29 13:33:09

Both `reverse` and `reverse_lazy` functions have the same objective: to generate a URL based on the inputs (like a named url).

## The difference is in when they are evaluated:

- `reverse` is used to generate a URL at the time the function or method is called.

Let's put an example:

*A function*:

```python
    #views.py

    from django.urls import reverse

    def my_view(request):
        url = reverse('url-name', args=[1])
        # do something with the URL
```

The `reverse` function is evaluated at the moment the `my_view` function is called: it generates a URL for the named url `url-name`, passing the integer 1 as an argument.

*A method*:

```python
    #models.py 
    
    from django.db import models

    class Post(models.Model):
        #rest of the class

        def get_absolute_url(self):
            return reverse("blog:post_detail", kwargs={"pk": self.pk})
```


Again, the `reverse` function is evaluated at the moment the `get_absolute_url` method is called.

What is important in both this cases is that at the moment the `reverse` function is called, **it already has the information of the `URLConf`**, so it can easily find the url pattern.


- `reverse_lazy` is also used to generate a URL, but it defers the moment of evaluation until it is actually needed. That's way it is a lazily evaluated version of `reverse`.

You may be wondering why...

There are moments in your code when you need to use a URL reversal, but you don't exactly know if the `URLConf` has already been loaded.

If you use `reverse` when the `URLConf` hasn't already been loaded, you would get an error.

This error occurs because reverse needs to know the URL patterns defined in the project's `URLConf` in order to generate the correct URL. If the `URLConf` has not been loaded, `reverse` will not be able to find the necessary information to generate the URL and will raise an exception.


Example:

*A class based view*:

```python
    from django.views.generic.edit import DeleteView
    from django.urls import reverse_lazy

    class PostDeleteView(DeleteView):
       model = Post
       template_name = "post_delete.html"
       success_url = reverse_lazy('home')
```

When you defined the `success_url` (*a class attribute*) you used `reverse_lazy` instead of `reverse`.

**This is because class attributes are evaluated at the time when the class definition is executed**.

This means that the values assigned to class attributes are determined when the class is defined, and not when instances of the class are created.

When you import the class, the Python interpreter executes the class definition from top to bottom and that includes the *class atrtributes* like `success_url`, but there are chances that the `URLConf` hadn't been loaded.

To not have an error, instead of using `reverse` we use `reverse_lazy`, which delays the actual call to the `URLConf` to the moment is needed and not when the class attribute is evaluated.

NOTE: originally posted in StackOverflow https://stackoverflow.com/a/75653186/6710903