teleren/devto huggingface dataset:
Google Geocoding API error: request denied
Published: 2023-07-23 16:59:01

I ran into this issue while trying to use the Geocode gem on my rails 7 app. 

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

If you ran into this error, these are the steps that I used to debug. 
Google Bard was a great tool that helped with solving this bug.

Why? Google Geocoding API error: request denied.

The Google Geocoding API error "request denied" can occur for a few reasons:

- You have not activated the Geocoding API in the Google Cloud Console.
- You have not specified the key parameter in your request.
- The key parameter does not match the API key in your Google Cloud Console.
- Your API key has not been correctly set up in the Google Cloud Console.
- You have exceeded your monthly quota for free requests.
- You are using a restricted IP address or country.

To troubleshoot this error, you can check the following:

- Make sure that the Geocoding API is activated in your Google Cloud Console.
- Check that you have specified the key parameter in your request.
- Verify that the key parameter matches the API key in your Google Cloud Console.
- Check your monthly quota for free requests.
- Check that you are not using a restricted IP address or country.


**Solution**

Installing the Geocode gem to rails

1. Install the Geocoder gem: 
`bundle add geocoder`

2. Create a config/initializers/geocoder.rb file and add the following code:
`Ruby
Geocoder.configure do |config|
  config.api_key = ENV['GEOCODER_API_KEY']
  config.lookup_adapter = :google
end`

3. Replace ENV['GEOCODER_API_KEY'] with your Google Geocoding API key. 
You can get your API key from the Google Cloud Console: https://console.cloud.google.com/apis/credentials.

4. In your Rails application, you can now use the Geocoder class to geocode addresses. 

For example, the following code will geocode the address "1600 Pennsylvania Avenue NW, Washington, DC 20500":

`Ruby
address = "1600 Pennsylvania Avenue NW, Washington, DC 20500"
coordinates = Geocoder.search(address).first.coordinates`

The coordinates variable will now contain the latitude and longitude of the address.

Here are some additional resources that you may find helpful:

Geocoder gem documentation: https://github.com/alexreisner/geocoder
Google Geocoding API documentation: https://developers.google.com/maps/documentation/geocoding/

**Results**

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0x89lq5d1aw5t0b90pn.png)
Why choose 3Enigne zkEVM? Unleashing the Potential of Web3 Games
Published: 2023-07-23 16:41:16


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

Have you tried learning a language through a mobile app? How successful were you? Have you heard that language learning apps are [only a supplement to classes?](http://google.com) Or… that language apps aren’t helpful for speaking skills? In 2020, Michigan State University conducted a study using Babbel, a popular subscription-based language learning app and e-learning platform, to answer the question, “How effective are language learning apps?” (1).

1. java
2. py
3. js
4. code

-  javaaaa
-  pddddy
-  jssadas
-  code


```
          <div>
            <p className="text-2xl font-semibold text-white">
              Recommended Posts
            </p>
          </div>
```
Laravel API Error Exception Handling Methodologies.
Tags: php, laravel, exceptions
Published: 2023-07-23 16:23:59

Laravel is one of the most used backend frameworks in building modern APIs for applications. When building APIs or writing codes (either simple or complex algorithms), no developer can escape from encountering errors. In this short article, I'll be sharing a simple tips on how to handle these errors. 

**These are some of the reasons why you need to learn error handling:**

1. To avoid unnecessary termination of your program.
2. To avoid security threat on your application.
3. Proper communication to the end user or the API tester of your application. etc

**Here are common errors you will likely encounter when building your APIs:**

1. MethodNotAllowedHttpException
2. NotFoundHttpException
3. BadMethodCallException

_**In Laravel, all exceptions are properly handled in the:
\app\Exceptions\Handler.php.**_

After Locating the path, you will find the render method, inside the method, all exceptions should be written there.

**1.MethodNotAllowedHttpException** usually occurs when you're trying to POST to a GET route or you're trying to GET from a POST route or similar

**Popular error:**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1m3249oiz03xwadn33wv.PNG
)

**Solution:**

```php
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
public function render($request, Throwable $exception){
        if ($exception instanceof MethodNotAllowedHttpException)
        {
            return response()->json( [
                'success' => 0,
                'message' => 'This Method is not allowed for the 
                   requested route',
                'status' => '405',
            ], 405 );
        }
}
```




**2.NotFoundHttpException**  in Laravel always means that it was not able to find a router for a particular URL

**Popular error:**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3bzytdjkl5d6o50rk1x5.PNG)

**Solution:**

```php
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
public function render($request, Throwable $exception)
     if ($exception instanceof NotFoundHttpException) {
            return response()->json( [
                'success' => 0,
                'message' => 'This Route is not found',
                'status' => '404',
            ], 404 );
        }
}
```
**3.BadMethodCallException** is thrown if a callback refers to an undefined method or if some arguments are missing.
**Solution:**

```php
public function render($request, Throwable $exception){
      if ($exception instanceof \BadMethodCallException) {
            return response()->json( [
                'success' => 0,
                'message' => 'Bad Method Called',
                'status' => '404',
            ], 404 );
        }
}
```
_**NOTE: There should not be multiple render methods. Just one! You put all your exceptions inside one render method**_

I hope this short article has been helpful to you? Kindly add more exceptions if you know of any other ones.
Javascript polyfill implement Array.prototype.findLast()
Tags: javascript, programming, beginners, interview
Published: 2023-07-23 16:18:32


Good morning! Here's your coding interview problem for today.

## This problem was asked by Apple.

**Please implement your own Array.prototype.findLast()**

```
Example
Array.prototype.findEndIdx = function (val) {

}

let arr = [1, 2, 2, 4];
console.log(arr.findEndIdx(2)); // 2
```
**Note: Do not use native Array.prototype.findLast() in your code**

**Solution**

```
if (!Array.prototype.findLastIndex) {
  Array.prototype.findLastIndex = function (value) {
    for (let i = this.length - 1; i >= 0; i--) {
      if (this[i] === value) {
        return i;
      }
    }

    return -1;
  };
}

```

**Explanation**

- Loop backwards from end of array to start
- Check if current element matches value
- If so, return current index
- If loop completes, value not found so return -1
Motivational Quotes for Software Developers
Tags: beginners, motivation, career, mentalhealth
Published: 2023-07-23 16:16:56

Software development can be a challenging and rewarding career. It requires a combination of creativity, problem-solving skills, and technical knowledge, but even the most talented developers can get stuck or discouraged from time to time. That's why it's important to have some motivational quotes to fall back on.

Here are a few quotes that can inspire us as software developers:

1. "The best way to predict the future is to invent it." - Alan Kay
2. "The only way to do great work is to love what you do." - Steve Jobs
3. "The computer was born to solve problems that did not exist before." - Bill Gates
4. "Good code is its own best documentation." - Steve McConnell
5. "Innovation distinguishes between a leader and a follower." - Steve Jobs
6. "The most damaging phrase in the language is 'we've always done it this way!'" - Grace Hopper
7. "Code is like humor. When you have to explain it, it’s bad." - Cory House
8. "If you think math is hard, try web design." - Trish Parr
9. "The only true wisdom is in knowing you know nothing." - Socrates
10. "Quality is not an act, it is a habit." - Aristotle

These quotes can provide a much-needed boost of motivation when things get tough.
Remove the duplicates in-place such that each unique element appears only once
Tags: javascript, programming, beginners, interview
Published: 2023-07-23 16:13:41


Good morning! Here's your coding interview problem for today.

## This problem was asked by Tencent.

**Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums.**

**Example**

```
function removeDuplicates(nums){
    
}

console.log(removeDuplicates([1, 2, 3, 1, 3])) 
// [1, 2, 3]
```


**Solution**

```
function removeDuplicates(nums) {
  const set = new Set();

  for (let i = 0; i < nums.length; i++) {
    set.add(nums[i]);
  }

  let k = 0;
  for (const num of set) {
    nums[k++] = num;
  }
  nums.length = k;
  return k;
}
```

**Explanation**


- Use a Set to collect only unique elements from the unsorted array.
- Loop over the original array and add each element to the Set.
- Set will only contain unique elements, discarding duplicates.
- Loop over Set to rebuild array with only uniques in original order.
- set size of array to k
- Return k which is the new length after removing duplicates.
ASP.net mvc de kodundaki değişiklik tarayıcıda da uygulansın istiyorsan
Published: 2023-07-23 16:03:00

Araçlar>seçenekler>projeler ve çözümler >ASP.net core>otomatik derleme ve yenileme seçeneği > Tarayıcı isteği üzerine otomatik derle
Not!! IIS DE ÇALIŞTIR
Azure Key Vault for local development
Tags: azure, devops, powershell
Published: 2023-07-23 16:01:05

---
title: Azure Key Vault for local development
published: true
description: A powershell script for managing secrets localy
tags: azure,devops,powershell
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oz3qvp1kkt13j9sg9hz3.png
# Use a ratio of 100:42 for best results.
# published_at: 2023-07-23 15:28 +0000
---

One of the most huge mistakes that a developer can do It's storing secrets (i.e. database connection string) directly into the source code repository and also forgetting one could be very dangerous.

Ideally, all secrets should be stored and accessible by a secret manager ([Azure Key Vault](https://azure.microsoft.com/en-us/products/key-vault)) and stored on repository only reference to right secret. On the other hand, the developer needs to use the secret's values on their configuration files (i.e. appSettings.json), so a fast way for retrieve them from Key Vault should be nice.

To accomplish this operation I have developed a powershell script called Set-ValuesFromKeyVault, which I have included an example of using it below.


### Example

We want replace the key vault references into the following json file:
```json
{
  "parent-property1": "@Microsoft.KeyVault(SecretUri=https://<<your-keyvault-resource>>.vault.azure.net/secrets/<<your-secret1>>)",
  "Values":
  {    
    "nested-property2": "@Microsoft.KeyVault(SecretUri=https://<<your-keyvault-resource>>.vault.azure.net/secrets/<<your-secret2>>)",
    "nested-property3": "@Microsoft.KeyVault(SecretUri=https://<<your-keyvault-resource>>.vault.azure.net/secrets/<<your-secret3>>)",
    "non-keyvault-binding-property": "<<any-value>>"
  }
}
```

To do that, first establish a connection to an Azure account and than execute the powershell script as reported below: 

```powershell
# connect to azure
Connect-AzAccount

# execute the replace on data.json file
./Set-ValuesFromKeyVault.ps1 -FileName data.json
```
The result will be a new json file called out.json within the secrets replaced as this:
```json
{
  "parent-property1": "<<your-secret1-value>>",
  "Values":
  {    
    "nested-property2": "<<your-secret2-value>>",
    "nested-property3": "<<your-secret3-value>>",
    "non-keyvault-binding-property": "<<any-value>>"
  }
}
```
The script is available on my [repository](https://github.com/antdimot/devops/tree/main/azure#azure-keyvault-powershell-script).
Seamless Java and PostgreSQL Integration: Unveiling the Magic of JDBC Driver
Published: 2023-07-23 15:58:53

 

## Introduction:
Hey Java enthusiasts! PostgreSQL has earned its reputation as a reliable and scalable database, and if you're in the Java world, the JDBC driver is your secret weapon to connect with PostgreSQL effortlessly. In this blog, we'll embark on a journey through the wonders of the JDBC driver and how it brings the power of PostgreSQL right into your Java applications.

## Connecting with Grace:
Buckle up, because the JDBC driver makes connecting to PostgreSQL a breeze. With its user-friendly API, setting up connections to your databases, whether they're local or remote, is a walk in the park. No more grappling with complicated configurations; the JDBC driver takes care of it all, allowing you to focus on building your app with ease.

## Talking SQL, No Fuss:
Need to have a chat with your database? The JDBC driver has you covered! You'll find a plethora of tools to execute SQL queries, tweak them, and fetch data with simplicity. From basic SELECT statements to complex data manipulations, the JDBC driver is your trusty companion on this journey.

## Keeping Transactions in Check:
Oops, need to roll back a transaction? Not a problem! The JDBC driver handles transaction management like a pro. Taking care of your database transactions is a breeze, ensuring data integrity and consistency with ease.

## Graceful Error Handling:
We all encounter those unexpected bumps on the road, don't we? But fret not! The JDBC driver is here to save the day with its robust error handling. Those little oops moments won't disrupt your app – the JDBC driver has your back.

## Speed Up with Asynchronous Programming:
Want to accelerate your app? Asynchronous programming is the answer, and the JDBC driver knows how to do that! Executing multiple queries concurrently is a breeze, making your app super responsive and efficient.

## Your Customization Haven:
The JDBC driver is all about making you happy. It lets you customize and fine-tune your PostgreSQL interactions. Advanced features like SSL/TLS encryption, server notifications, and prepared statements are just some of the treats it brings to the table. Plus, it supports connection pooling, so you can optimize your resources like a pro!

## Conclusion:
Java enthusiasts, meet your database companion, the JDBC driver! It's the gateway to PostgreSQL wonderland. From smooth connections and effortless queries to cool transaction management and error handling, the JDBC driver simplifies your journey into PostgreSQL adventures.
(New) Coding Tutorial: Efficient Workflows in Go with Temporal: Signals & Selectors
Tags: go, webdev, tutorial, opensource
Published: 2023-07-23 15:51:20

With the use of Signals, workflows can receive updates, notifications, or requests from external systems or actors. These Signals can trigger wait conditions within the workflow, allowing it to patiently pause until a defined Signal is received.

Tutorial: [https://younisjad.medium.com/series-efficient-workflows-in-go-with-temporal-signals-selectors-ddd4bbc285d4](https://younisjad.medium.com/series-efficient-workflows-in-go-with-temporal-signals-selectors-ddd4bbc285d4)

Source Code: [https://github.com/unijad/temporal-select-signal-tutorial-code](https://github.com/unijad/temporal-select-signal-tutorial-code)
Powering Python and PostgreSQL: Meet psycopg2!
Published: 2023-07-23 15:50:43

## Introduction:
Hey there, Pythonistas! PostgreSQL has become a rock-solid database choice for many developers, and if you're in the Python world, psycopg2 is the real hero that makes PostgreSQL integration a breeze. In this blog, let's take a friendly stroll through the wonders of psycopg2 and how it brings the magic of PostgreSQL right into your Python apps.

## Smooth Connections, No Hassle:
Getting cozy with PostgreSQL is a piece of cake thanks to psycopg2. With its friendly API, setting up connections to your databases, be it local or remote, is a breeze. No more struggling with complicated setups; psycopg2 handles it all smoothly, so you can dive straight into building your app without headaches.

## SQL Queries Made Simple:
Need to chat with your database? Say no more! With psycopg2, firing SQL queries and getting results is as easy as chatting with a friend. You'll find a wide range of tools to execute queries, tweak them, and fetch data with ease. From simple SELECTs to fancy data manipulations, psycopg2 has your back.

## Stay Cool with Transactions:
Oops, need to rollback a transaction? No worries! psycopg2 has got your back with its cool transaction management. Handling those database transactions is a piece of cake, and you can rest assured your data stays safe and sound.

## Handling Oops Moments Gracefully:
We all have those moments, don't we? But in the database world, psycopg2's got you covered with its top-notch error handling. Those unexpected bumps on the road won't mess up your app – psycopg2 makes sure of that.

## Get on the Fast Lane with Asynchronous Programming:
Speed up your app with asynchronous programming – psycopg2 knows how to do that! Running multiple queries at once is a breeze, making your app super responsive and efficient.

## Customize to Your Heart's Content:
Psycopg2 is all about making you happy. It lets you customize and fine-tune your PostgreSQL interactions. Advanced features like SSL/TLS encryption, server notifications, and prepared statements are just a few of the goodies it brings to the table. Plus, it offers connection pooling, so your resources stay in check!

## Conclusion:
So, Python aficionados, meet your database buddy, psycopg2! It's the ticket to PostgreSQL wonderland. From smooth connections and effortless queries to cool transaction management and error handling, psycopg2 makes your life easier as you dive into PostgreSQL adventures.
My first year of programming
Tags: firstpost, programming, codenewbie
Published: 2023-07-23 15:48:25

Already, it's been already a year and a half I had my first coding experience and... what a journey !

Even it's only a small step, it's feeling like being already miles away from my starting point and this is what I've done during this time.

## First Week:

Everything's been interesting so far, from learning to use loops, to conditions, my first bug encounter, first commits, he really seems I'm in love with my first coding week, I'm doing JS, HTML, CSS, I type code and I see stuff in my browser it's awesome.

## First Month:

My first team project is done, a really simple website, with just plain HTML, CSS and JS, nothing fancy but still, how pleased I am to have achieve something like that in just a month with my teammates, at that time I feared using too many branches, I named them randomly using who's been working on the branch and stuff, it was a real mess.

## First quarter:

I've been doing React all day, everyday, learning how components works, how to handle states, what are API, how to work with them, I did my first web app, a simple game super hero game using a third party API, not bad.

## First semester:

I've done my first fullstack application using React, Express and mySQL, learned a new language for my first internship PHP, learning a new language has been both easier than I first thought and allowed me to learn new way to code, new way to think about my program, here come's the OOP and my first clean code readings.

## First year:

I've graduate from my bootcamp, finished my first internship with really good feedbacks from my manager, find out that maybe our fundamentals while bootcamp graduate where a bit "light" and so I've studied OOP, data structures, algorithms,  I've been doing a lot of exercises to practice and fill the gap in my computer science knowledge.

## Today:

And here I am, I work now as a graduate software engineer for a startup, I learned a lot about clean code, software craftmanship, software architecture, I still try to improve as most as possible my fundamentals whereas it's algorithms, core software engineer, or subjects like Domain Driven Design or clean architecture, I now understand that what make a developer is not the language he use, but he's fundamental, he's thinking, that's why I now want to work as much as possible on my core programming skill, that will be of use for my whole career.

## What in the future:

I really think, that investing in the rights set of skills today could make a huge difference on your career, learning skills that apply for every programming language are really my main focus today, I also think that skills like devops, system design would be very well worth the investment.

## Final words:

If like me, you always wanted to work as a programmer, but just kind of lost your tracks, don't lose hope, it's just absolutely impressing to step back and see what we can achieve in just a single year, with a good mix of passion and hardwork, and don't forget, we are not in a sprint, we are here for the long run :D
A CSS font styling protip for mixed English & Asian language sites
Tags: css, cjk, fonts
Published: 2023-07-23 15:46:48

Imagine you have a website that uses both English and Asian languages like Chinese, Japanese, or Korean. You want the English text to appear in a Western-style font and the Asian text in an appropriate Asian font.

To achieve this, you don't need to complicate things by separating the Asian text and writing special CSS rules for it. Instead, you can handle it simply by adding the Asian font as a fallback in your CSS file like this:

```css
.content { font-family: <Western font>, <CJK font>; }
```

When someone opens your website in their browser, it will first try to display all the text using the primary Western font. However, since Western fonts can't show non-Latin characters, the browser will automatically switch to the fallback Asian font, but only for the Asian text.

Pretty neat!