teleren/devto huggingface dataset:
Translate text with google translate in your PHP/Laravel app with 4 lines of codes.
Tags: php, laravel, beginners
Published: 2021-01-07 13:35:43

---
title: Translate text with google translate in your PHP/Laravel app with 4 lines of codes.
published: true
description: 
tags: php, laravel, beginner
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/wewsf8f90zjztyddb2ki.jpg
---

Hi,

Here a quick way to easily translate text in your php Laravel application. NO NEED TO HAVE A GOOGLE API KEY!

First you need to install Google Translate PHP package.

You can do it by running in your project folder
```
$ composer require stichoza/google-translate-php 
```

After installation you can use it anywhere in your code like this.

```
use Stichoza\GoogleTranslate\GoogleTranslate;

$tr = new GoogleTranslate(); 
$tr->setSource('en'); // Translate from English
$tr->setTarget('fr'); // Translate to French

echo $tr->translate('Hello World!'); // Bonjour le monde!
``` 

That's it. Cannot be easier than that!

If you want to use more options like language auto-detect, etc. You can read the doc: https://github.com/Stichoza/google-translate-php


CONCLUSION

If you like this kind of small tips, you can follow me, I have more to come.

See you later...
100daysofcode - init
Tags: 100daysofcode, javascript, webdev, programming
Published: 2021-01-07 13:32:16

I took the #100daysofcode challenge before also but gave up after 20 days, because of the strict rules I set for myself and also not posting to any platform, so now I started it again hoping to code at least 1 hr a day for the next 100 days (it will be okay to miss a day or two if something else come up in life).
 
So from today, I start the #100daysofcode challenge and will be regular in updating you guys also.
By aiming to learn React by initially taking the course on udemy - https://www.udemy.com/course/modern-react-bootcamp/
Privacy cookies
Tags: watercooler, webdev, opensource, privacy
Published: 2021-01-07 13:22:44

The common internet user might have the impression that cookies are a completely useless invention. Discussions on this topic usually refer to a privacy catastrophe that allows advertisers to track users across the Internet. Not to mention those annoying consent banners everywhere trying to trick you into saying "yes".

Of course, there are problems with how cookies are often deployed these days. Therefore, their usage definitely needs to be regulated. Yet, in the whole debate, it is often forgotten that *the use of cookies does not equal an invasion of users' privacy.* Properly applied, they can even be crucial for improving privacy on the web.

Thinking about data protection for the user from scratch means that the technical details of implementation play a secondary role. If you want to collect non-essential data from users in a privacy-friendly way, you have to ask for consent. All the other solutions out there, no matter how sophisticated, that help avoid the "cookie banner" for collecting non-essential data are not privacy friendly, they are just regulation friendly.

With this out of the way, we can think about how *cookies can actually be used to improve privacy on the web.* The most important thing here is to distinguish between essential and non-essential functions. For example, if you need to store a session identifier in a cookie for the user, this is essential and can be done without consent. A non-essential function, on the other hand, is collecting analytics data for a website. From the user's perspective, this feature is definitely not required to use your service and therefore requires consent.

Taking this further, for all cookie applications, whether essential or non-essential, it must be ensured that the implementation is secure and respects the privacy of the user as much as possible. In doing so, some technical details have to be considered. For this we have written [an extensive collection of ideas that you can review on our blog.](https://www.offen.dev/blog/privacy-cookies/?utm_source=forum)
Developed HTML based website within 7 Days!
Published: 2021-01-07 13:16:23

Hi there I have accepted an challenge from my collegue to build the entire website with only HTML, CSS and Bootstrap with JavaScript on the lower amount.

I was just surprised to create this website: 
http://www.thechildrenshospitalmumbai.com/

Can any one find bugs on the above mentioned website, as it would be too good for me to improve myself in the HTML era.

Thanks
Daily Developer Jokes - Thursday, Jan 7, 2021
Tags: jokes, dailydeveloperjokes
Published: 2021-01-07 13:00:05

---
title: "Daily Developer Jokes - Thursday, Jan 7, 2021"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Thursday%2C%20Jan%207%2C%202021"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e125925337e5.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ Why did the constant break up with the variable?

___A:___ Because they changed.
 -->
The @Scheduled annotation may be deceiving you..!

Tags: springboot
Published: 2021-01-07 12:52:47

Is your `@Scheduled` method with `fixedRate` is not firing exactly at the time interval configured? Here I try to explain this behaviour and how you can fix it.

It all has to do with the default `ThreadPoolTaskScheduler` that is provided by Spring Boot’s auto-configuration. This Executor’s thread pool size is 1 by default. Every method that uses `@Scheduled` annotation will have to use this single thread.

Spring has deliberately done this so that there won’t be two runs of the same method happening in parallel. To achieve parallelism, we need to do three things.

1) Enable Async Support by annotating the Spring Boot main class with `@EnableAsync`.
2) Mark The `@Scheduled` method with `@Async`.
3) Increase the default number of threads available using `spring.task.scheduling.pool.size` property.


You can find detailed explanation about this behaviour at the post about how **[The @Scheduled annotation may be deceiving you..!](https://springhow.com/things-you-dont-know-about-scheduling-in-spring-boot/)**
Distributed Caching with Hazelcast
Published: 2021-01-07 12:46:50

Hazelcast is an in-memory data grid that helps share highly volatile data between multiple application instances. This approach gives the advantages of avoiding network round trips.

Here is a post about hazelcast with spring boot and how to monitor them with Hazelcast Management centre.

[Spring Boot Hazelcast Cache](https://springhow.com/spring-boot-hazelcast-cache/)
Add github based comments on your gridsome blog
Tags: vue, javascript, codenewbie, webdev
Published: 2021-01-07 12:43:35

## Overview

This is a guide on how you can add GitHub based comments on your Gridsome powered blog like shown in the picture below.

![Gitalk Demo](//images.ctfassets.net/7xvuet8e2li4/4zAyUeUg8yjPh3wqN8aqjP/99fc74f8e27bd2911660b00e12dc3bab/Unnamed.jpg)

We will use a component named `Gitalk` in this article. All the comments are stored in a github issue. So, you don't need a seperate database for storing the comments.

## Let's Start

### Create a GitHub OAuth application

- Go to your [Github App Settings](https://github.com/settings/apps).
- Go to OAuth Apps.
- Create new OAuth application.
- Fill in all the required details. In the `Authorization callback URL` fill in the `URL` where your site will be deployed.
- Copy the <u>Client ID</u> and <u>Client Secret</u> from your OAuth App.

<br>

### Configure your Gridsome app

First of all, install the gitalk gridsome plugin.

```bash
yarn add gridsome-plugin-gitalk
```
<br>

Now, in your `gridsome.config.js` add the following block to your plugins.

```javascript
module.exports = {
  ...,
  plugins: [
    ...,
    {
      use: "gridsome-plugin-gitalk",
      options: {
        clientID: "kuy78h87gg87g8g89", // The client id you copied earlier.
        clientSecret: "r248hf924hfhh8fh8a2", // The client secret you copied earlier.
        repo: "nishantwrp-website", // The name of the github repo where the comments should be stored.
        owner: "nishantwrp", // The username of the owner of the github repository.
        admin: ["nishantwrp"], // The usernames of the admins of the repository.
      }
    }
}
```

<br>

Now, you're all set. You can just use the gitalk component in your `Vue` files like below.

```html
<Gitalk />
```

## That's all

If you did everything correctly, the comments and github authentication should work correctly when you deploy it. For further advanced configurations please refer to the [plugin docs](https://github.com/nishantwrp/gridsome-plugin-gitalk). Thanks!

<hr>

Hi, I'm Nishant Mittal. Thanks for reading this post. Feel free to comment or reach out on [Twitter](https://twitter.com/nishantwrp) in case of any queries. You can also find me on [Github](https://github.com/nishantwrp), [Linkedin](https://www.linkedin.com/in/nishantwrp/).
Svelte. What is your opinion about the lightweight JS framework?
Tags: svelte, opinion, discuss, javascript
Published: 2021-01-07 12:36:42

Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do the bulk of their work in the browser, Svelte shifts that work into a compile step that happens when you build your app.

Instead of using techniques like virtual DOM diffing, Svelte writes code that surgically updates the DOM when the state of your app changes.

As we all know the popularity of Svelte is at the moment way lower than other JS frameworks/libraries like React.js or Vue.js, but that is no reason for Svelte to lose the game.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jl4iv3xm0s4s2nka8nqo.png)

So what's your opinion about Svelte? Will Svelte continue with growing and will it become more popular than popular frameworks/libraries like React or Vue? Or will it at the end become a forgotten project?
HP printer keeps going offline
Published: 2021-01-07 12:20:38

HP printers are highly sensitive to network connectivity glitches and trigger an offline error if the expectations are not met. If your HP printer keeps going offline, then most probably the network connectivity problems are the real culprit. That’s not all, In fact, sometimes using an outdated printer driver also leads to an offline problem. Well, in that case, we would suggest you take help from experts and avoid messing up with your printer to kill an offline issue. We have a team of printer techies who will deal with the problem with ease as they are highly experienced and carries enough knowledge about an offline issue. Some other reasons that direct your printer to go offline is poor networks, loose connections, a printer is set up to print offline, or accumulation of too much data in the print queues. All these issues can be eliminated easily by using some effective measures and using some automated tools. Drop us a call to learn the skills to fix an offline error. We are available 24/7 to help you overcome any challenge. https://sites.google.com/view/why-is-my-hp-printer-offline/
Mixpanel in React Native with Context API
Tags: reactnative, mixpanel, analytics, react
Published: 2021-01-07 12:18:51

I recently came across [Mixpanel](https://mixpanel.com/), as a nice analytics service to quickly implement in your projects regardless the stack you use.

However, their RN example is using classes and I felt like their app example was also a bit confusing and not quite DRY, so I implemented using the more modern [ContextAPI](https://reactjs.org/docs/context.html) and Functional Components. And I felt like this was worth sharing with the community and even the mixpanel team so they can add it to their docs.

### 1. Lets create the Consumer and Provider

```jsx
import React from 'react';
import {Mixpanel} from 'mixpanel-react-native';

export const MixpanelContext = React.createContext();

export const MixpanelProvider = ({children}) => {
  const [mixpanel, setMixpanel] = React.useState(null);

  React.useEffect(() => {
    const initMixpanel = async () => {
      const initializedMixpanel = await Mixpanel.init('your token');
      initializedMixpanel.serverURL = 'https://api-eu.mixpanel.com'; // if needed
      setMixpanel(initializedMixpanel);
    };

    initMixpanel();
  }, []);

  return <MixpanelContext.Provider value={mixpanel}>{children}</MixpanelContext.Provider>;
};
```

### 2. Wrap your App Component
So that you can access the context globally.

```jsx
import React from 'react';
import {MixpanelProvider} from 'path.../AnalyticsService';

const App = () => {
  return (
          <MixpanelProvider>
            {children}
          </MixpanelProvider>
  );
};

export default App;
```
### 3. Consume your context in any Component
```jsx
import React from 'react';
import {Text, TouchableOpacity, View} from 'react-native';
import {MixpanelContext} from 'path.../AnalyticsService';

//simple example to get the point, customize it however you want
 
export const SomeComponent = () => {
  const mixpanel = React.useContext(MixpanelContext);
  return (
    <View>
          <TouchableOpacity onPress={() => mixpanel.track('Testing mixpanel')}>
            <Text>Test mixpanel</Text>
          </TouchableOpacity>
        )}
    </View>
  );
};
```
Hope it was helpful. I didn't went deep into the nits&grits as i felt like react docs are well explained and you can find many brilliant and free videos on the topic as well.   
Nevertheless, let me know if you have any doubts.
You can also contact me at https://www.linkedin.com/in/alejandrogutierrezb/
Convert Decimal to Binary for IOT Product With Vue.js
Tags: javascript, vue, decimal, numbers
Published: 2021-01-07 12:17:38

I just made a recent Internet of things product for a company using Raspberry pi. It is a safe locker that opens with a correct decimal number. My client wanted to convert decimal to binary number and then save that to the database. When the user sends a query to change the password, the server should convert binary to decimal and show that to the user for updating.

I have used Bcrypt earlier but this was a new experience for me. However, I managed to find a code to convert decimal to binary online but I have to make many changes in the code to make it work correctly for the bigger numbers.

For this app, I used Vue.js in the front-end and Node.js for the back-end and IOT connection. Most of the code is Vanilla.js. Vue.js and Node.js are for just a few operations.

For the decimal to binary and again binary to decimal conversion, I have used Vue.js and axios to send data to the back-end. Here is the code:

Decimal to binary code:

```javascript
var xx = document.getElementById("input").value;
var xy = parseInt(xx);
  var xz = xy.toString(2);
    document.getElementById("demo").innerHTML = xz;
```
I found the above code online, this code returns the correct answer only for 16 characters long input. In case, you insert an input that is longer than 16 characters then you get the wrong answer.

To solve this problem, I used Bignumber.js. This is a great Javascript library to perform the arithmetic operations more precisely. To get the correct answers for more than 16 characters, you need to use Bignumber.js. Here is the code:

Vue.js Code with Bignumber.js:

```javascript
dectobin() {
      var x = new BigNumber(this.text_value, 10)
    var dectobin = x.toString(2);
    this.ans = dectobin;
            },
```
In the above code, dectobin() function is called at the click event on the button. Apart from that, this.text_value is used to get the value from the user input. toString is an in-built javascript function to get the binary value of a number.

Vue.js code for binary to decimal:

```javascript
bintodec() {
      var cc = new BigNumber(this.text_value, 2);
       this.ans = cc;
     },
```

Just like the above operation, bintodec() function is also called at the click event from the user. Again, text_value is the value updated by the user.

So, above is the simple code for decimal to binary conversion. I spend almost one day to understand the concept of bignumber and binary numbers. If you are also dealing with such numbers then I hope this code helps you! [Demo](https://binarytotext.net/decimal-to-binary/)
Scala and Perl in 2021
Tags: scala, perl, 2021, discuss
Published: 2021-01-07 12:09:32

Hi dev.to community!!

What is the situation of Scala and Perl in 2021? I mean, i don't know anything about both languages but i want to learn, is the both still used in large scale? Or do you think is better to keep coding in PHP, Node and Python?
What are you using Realtime databases for?
Tags: realtime, database, firebase, acebase
Published: 2021-01-07 11:44:43

Are you using realtime databases such as Firebase, AceBase, RethinkDB,  etc? If so, please let me know in the comments:

1. Which realtime database(s) do you use?
2. For what kind of functionality do you use the realtime aspect?
3. Are you missing features in those db's, such as indexes / query options?

I would greatly appreciate your response, thanks in advance!
A silly way to reverse an array
Tags: programming, maths, jokes, showdev
Published: 2021-01-07 11:34:22

---
title: A silly way to reverse an array
published: true
description: Using polar coordinates to reverse an array
tags: programming, maths, jokes, showdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/r95g0rgksly787pv4hvs.png
---

I was looking at a post in the challenge tag today, and it got me looking into polar coordinates, and I saw that you can rotate an array by 180 degrees by putting a pole in the middle and spinning the array around it, so here it is:

{% codepen https://codepen.io/schmellen/pen/qBaKYjw %}

The only issue I have is that small arrays seem to get a load of gaps at the beginning that I needed to filter out. Not sure why that is.
What was your first day at your first dev job like? 
Tags: webdev, discuss, beginners, livestream
Published: 2021-01-07 11:26:57

---
title: What was your first day at your first dev job like? 
published: true
description: What was your first day as a junior developer like? 
tags: webdev, discuss, beginner, livestream
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2u6znm38c7aj5r1vr1ws.jpg
---

## **What was your first day as a working junior developer like?**

For example: 

Was it as expected? 

Were you nervous? 

What was your job title? 

What were your first tasks? 

The topic of my YouTube livestream tomorrow (Friday Jan 8 at 4 pm  CST) is "First Day on the Job as a Junior Dev." I'll be sharing stories of others, in addition to what my own first day was like. I LOVE hearing stories like these so don't be bashful! 

(Comments made here may appear on the livestream).  

Be sure to [subscribe to my channel] (https://www.youtube.com/realtoughcandy?sub_confirmation=1) so you don't miss it.
Understanding the fancy words in software industry.
Tags: software, javascript
Published: 2021-01-07 11:22:04

---
title: Understanding the fancy words in software industry.
published: true
description: Understanding the fancy words in software industry.
tags: software, js
cover_image: https://images.pexels.com/photos/3861959/pexels-photo-3861959.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940
---

Two days ago I was searching to understand some "fancy words" in the software industry, but it took me some time to find it and actually understand it.

so I created [stupid fancy words GitHub repo](https://github.com/wassimbj/sfw) to explain the words I daily find in simple and understandable way. and planning to add examples.

I'm sharing this so you guys help me out in adding more and more words and also to people who find some "magic" words while they are learning something new. cause understanding them will help you so much in mastering that topic (language or whatever cool thing you are learning).

Thanks for reading. 😄
TIL: Testing an Amazon Cloudwatch alarm
Tags: aws
Published: 2021-01-07 11:12:01

Today I was setting up an application load balancer that sits in front of a test application I have put together. Setting this up was super easy, and very quickly I had my domain pointing to the alias and serving requests.

As part of the setup, I wanted to monitor the application load balancer to let me know when requests were failing to the downstream application (anything other than an HTTP 200) and so I set this up super easily in Amazon Cloudwatch. I now had monitoring and a nice dashboard that gave me the health of the application from the application load balancer perspective.

However, what I really needed was to be informed when there was issues. Within the Amazon CloudWatch dashboard I was able to very easily setup an alarm, and then trigger an SNS notification that would send me an email every time the threshold of failed requests was met/exceeded.

With this setup, I needed to now figure out how I was going to test this, after all, no one really cares about the monitoring/alarms until they actually need to be used. I found [this](https://devopslife.io/testing-cloudwatch-alarm-using-aws-cli/) post from the devopslife blog which pointed me in the right direction.

Using this command,

```
$ aws cloudwatch set-alarm-state --alarm-name "{your alarm name}" --state-reason "Testing the Amazon Cloudwatch alarm" --state-value ALARM
```

>The above assumes you have the aws cli installed somewhere and are using credentials/account with the right level of access.

I was able to validate that the Alarm had been setup and I would receive the notification. When I looked at the Cloudwatch dashboard I could see that this metric was now in Alarm status, and after about a minute I received my notification. The alarm reset itself after a few minutes so you do not need to do anything extra.
ServiceNow: Wait for Condition Flow Designer
Tags: servicenow
Published: 2021-01-07 11:08:18

The 'Wait for Condition' action in the ServiceNow FlowDesigner is run once and returns an EncodedQuery. Every time the record is updated, the record gets evaluated with the EncodedQuery and if it matches, the flow will continue.

That in mind, it is possible to write your own EncodedQuery in the inline script editor of the condition builder.

For example you can check if an 'on hold due date' was changed like:

```javascript

return 'u_on_hold_due_date!=' + fd_data_trigger.current.u_on_hold_due_date.getValue();

```