teleren/devto huggingface dataset:
(Series) Efficient Workflow in Go with Temporal.io - Updated
Tags: go, webdev, tutorial, devops
Published: 2023-07-15 12:06:27

In today’s fast-paced world, building scalable, efficient, and maintainable software is essential for businesses of any size. One challenge of creating modern software systems is managing the workflows and activities that make up the system. Workflow management can become complicated, especially when working on complicated distributed systems.

By the end of this tutorial series, you will have the skills and knowledge required to build, maintain and monitor fast, reliable, and efficient workflows and activities in Golang applications with Temporal.io.

[Continue Reading](https://younisjad.medium.com/series-efficient-workflow-in-go-with-temporal-io-ab3248b1c5f9)
IoT Part 1: Create an IoT Hub On Azure Portal
Published: 2023-07-15 11:51:34

To create an IoT Hub on Azure, you can follow these steps:

1.	Log in to the Azure portal at portal.azure.com.
2.	Click on the **“+ Create a resource”** button.
![Azure portal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26grmb24cimo7dzgj7n0.png)
3.	In the search bar, type **“IoT Hub”** and select **“IoT Hub”** from the list of results.
4.	Click on the **“Create”** button to start the creation process.
![Createiot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ut1gt0xf91zqaerzs3qv.png)
5.	Fill in the required information, such as the subscription, resource group, and region.
![details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lw1ahrpxedpv8jzt931s.png)
6.	Provide a unique name for your IoT Hub.
![uniqueid](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46i2h0062ita47h1lf7o.png)
7.	Choose the pricing and scale tier that suits your needs.
![Tier](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4nvsctu2q5k3wgskuok8.png)
8.	Configure the remaining settings, such as messaging, security, and advanced options, as per your requirements.
9.	Click “Review + create” to review your configuration.
10.	Once you’ve reviewed everything, click “Create” to create the IoT Hub.
![created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3ol3nh44uj4wavxf0t7.png)

Please note that creating an IoT Hub on Azure requires an active Azure subscription. Make sure you have the necessary permissions to create resources in your Azure environment. Additionally, the steps provided here may vary slightly depending on the Azure portal version you are using.
Elon Musk launches his new company, xAI
Published: 2023-07-15 11:44:02



Elon Musk on Friday said the purpose of his new artificial intelligence company, xAI, will be to "understand the universe."

In an often meandering 90-minute long Twitter Spaces audio chat, the billionaire discussed his vision for xAI for the first time while veering into topics such as the Earth's evolution and the fragility of civilization.

In seeking to deepen the understanding of the universe, Musk joked that xAI's mission statement would be "what the hell is really going on?"

Musk announced the formation of xAI on Wednesday after accusing companies like OpenAI and Google of developing the technology without considering risks to humans.

OpenAI and Google did not respond to request for comment.

He said xAI would seek to build a "good AGI," as an alternative to Microsoft, Google and OpenAI. AGI stands for artificial general intelligence and refers to AI that can solve problems like a human.

During the Spaces session, which had a delayed start as Twitter needed to "tweak the algorithm" to promote the chat to more users, Musk said xAI would work closely with his other companies, Twitter and Tesla.

The company will use public tweets to train its AI models and may also work with Tesla on AI software.

Such a relationship would have "mutual benefit" and could accelerate Tesla's work in self-driving capabilities, Musk said.

He also accused all AI companies of training their models using Twitter data in what he characterized as an illegal manner.

Musk, who has advocated for regulations in AI, said he has pushed for meetings with White House officials and has emphasized the importance of regulating AI in his recent meetings with top government officials in China.

I am currently building a newsletter to share informative articles and news, covering ai, startups 🚀, tech 📱, and programming 💻! my progress in becoming Software Developer with little experience, and how you can learn from my experience.
Please subscribe via this [link](https://lalitkumawattech.substack.com/)

Also published here.
OpenSource impact on Economy. The truth beyond GDA.
Tags: opensource, economics, softwareengineering
Published: 2023-07-15 11:19:43

Modern businesses depend on IT.

Be it bank payments, communication services, or actors like tax offices and police.

In order for a business to work, the whole ecosystem of information systems around the business must be working. The interesting part - the ecosystem heavily relies on open-source software. We all felt Log4j impact some time ago, but other open-source projects are the same important, we just haven't heard of them.

So 27% of UK Tech GVA may be, but if all open source disappeared tomorrow, our economy would have stopped to near absolute 0. Luckily that's a scenario for an Amazon movie, not for real life (fingers crossed).

The article is inspired by Amanda Brock (CEO of @OpenUK) post: https://www.linkedin.com/posts/amandabrocktech_opensource-opensourcesoftware-uktech-activity-7085908116105502720-Ed8m?utm_source=share&utm_medium=member_desktop
LeetCode Go #1. Two sum
Tags: go, leetcode
Published: 2023-07-15 10:16:52

## Problem Description
You can find the problem on [Leetcode](https://leetcode.com/problems/two-sum/).

Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.

### Example 1:
```
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Explanation: The sum of 2 and 7 is 9. Therefore, the indices of the two numbers are 0 and 1.
```

### Example 2:
```
Input: nums = [3,2,4], target = 6
Output: [1,2]
```

### Example 3:
```
Input: nums = [3,3], target = 6
Output: [0,1]
```

## Understand Problem
We are given an array of integers and a target value. Our task is to find two numbers in the array that add up to the target value. We need to return the indices of these two numbers.

## Implementation
Let's implement the solution in Go.

```go
package main

func twoSum(nums []int, target int) []int {
	complements := make(map[int]int)

	for i, num := range nums {
		complement := target - num
		if index, found := complements[complement]; found {
			return []int{index, i}
		}
		complements[num] = i
	}

	return nil
}
```

## Testing
To test the solution, we can use the `testing` package in Go. We'll write multiple test cases to ensure our implementation works as expected.

```go
package main

import (
	"reflect"
	"testing"
)

func TestTwoSum(t *testing.T) {
	tests := []struct {
		nums   []int
		target int
		want   []int
	}{
		{[]int{2, 7, 11, 15}, 9, []int{0, 1}},
		{[]int{3, 2, 4}, 6, []int{1, 2}},
		{[]int{3, 3}, 6, []int{0, 1}},
	}

	for _, test := range tests {
		got := twoSum(test.nums, test.target)
		if !reflect.DeepEqual(got, test.want) {
			t.Errorf("Input: nums=%v, target=%d\nGot: %v\nWant: %v", test.nums, test.target, got, test.want)
		}
	}
}
```

## Conclusion
Congratulations! You have successfully solved the Two Sum problem on Leetcode. By solving this problem, you have learned how to find two numbers in an array that add up to a specific target value. This problem is a classic example of using a map (or dictionary) to store complements and perform efficient lookups.

Now that you are familiar with solving this problem, you can move on to the next challenges on Leetcode and continue improving your problem-solving skills. Good luck!
Chapter 3 of Crafting Interpreters
Tags: 100daystooffload, book, chapter3, craftinginterpreters
Published: 2023-07-15 10:28:33

Finished chapter 3 today of the [Crafting Interpreters](https://a.co/d/bjMamei) book, which is also the last chapter of part one of the book.

This chapter goes through the properties of the language Lox that will be implemented in this book.

It will use dynamic typing to make the book concise since a static type system includes a lot of things to learn. The language has a lot of similarities with JavaScript (at least from a helicopter view), however it will not use prototypes, instead it will use classes. The author has a small section about _classes_ vs _prototypes_ which I found interesting.

The chapter pointed to an interesting paper that will be on my reading list:
> Peter J. Landin coined the term “closure”. Yes, he invented damn near half the terms in programming languages. Most of them came out of one incredible paper, “[The Next 700 Programming Languages](https://homepages.inf.ed.ac.uk/wadler/papers/papers-we-love/landin-next-700.pdf)”.

and this post, [Waterbed Theory](http://wiki.c2.com/?WaterbedTheory), by [Larry Wall](https://en.wikipedia.org/wiki/Larry_Wall).

Next up is part two and chapter 4 about scanners.

My previous post about the book is [here](https://dev.to/stefanalfbo/crafting-interpreters-1kbk).
#LearnedToday: LottieFiles
Tags: learnedtoday, animations, webdev, graphic
Published: 2023-07-15 10:20:39

⛱️ It’s weekend! Let’s talk about something lighter: **animations**

👁️‍🗨️ I bumped into [LottieFiles](https://lottiefiles.com), a website which collects free, ready-to-use and **customizable animations** for your projects.

🚶✏️ Here is one of my favourite: the [walking pencil](https://lottiefiles.com/animations/walking-pencil-LW2C6wzcmc) by Bashir Ahmed.
LeetCode Go #2. Add Two Numbers
Tags: go, leetcode
Published: 2023-07-15 10:17:42

## Problem Description
You can find the problem on [Leetcode](https://leetcode.com/problems/add-two-numbers/).

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

### Example 1:
```
Input: l1 = [2,4,3], l2 = [5,6,4]
Output: [7,0,8]
Explanation: 342 + 465 = 807.
```

### Example 2:
```
Input: l1 = [0], l2 = [0]
Output: [0]
```

### Example 3:
```
Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
Output: [8,9,9,9,0,0,0,1]
```

## Understand Problem
We are given two linked lists representing non-negative integers. The digits are stored in reverse order, meaning the units digit is at the head of the list. We need to add the two numbers and return the result as a new linked list.

## Implementation
Let's implement the solution in Go.

```go
package main

type ListNode struct {
	Val  int
	Next *ListNode
}

func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
	dummyHead := &ListNode{}
	curr := dummyHead
	carry := 0

	for l1 != nil || l2 != nil {
		sum := carry

		if l1 != nil {
			sum += l1.Val
			l1 = l1.Next
		}

		if l2 != nil {
			sum += l2.Val
			l2 = l2.Next
		}

		curr.Next = &ListNode{Val: sum % 10}
		curr = curr.Next
		carry = sum / 10
	}

	if carry > 0 {
		curr.Next = &ListNode{Val: carry}
	}

	return dummyHead.Next
}
```

## Testing
Let's write some tests to verify that our implementation is correct.

```go
package main

import (
	"reflect"
	"testing"
)

func buildLinkedList(nums []int) *ListNode {
	dummyHead := &ListNode{}
	curr := dummyHead

	for _, num := range nums {
		curr.Next = &ListNode{Val: num}
		curr = curr.Next
	}

	return dummyHead.Next
}

func getListValues(head *ListNode) []int {
	values := make([]int, 0)

	for head != nil {
		values = append(values, head.Val)
		head = head.Next
	}

	return values
}

func TestAddTwoNumbers(t *testing.T) {
	tests := []struct {
		l1   []int
		l2   []int
		want []int
	}{
		{[]int{2, 4, 3}, []int{5, 6, 4}, []int{7, 0, 8}},
		{[]int{0}, []int{0}, []int{0}},
		{[]int{9, 9, 9, 9, 9, 9, 9}, []int{9, 9, 9, 9}, []int{8, 9, 9, 9, 0, 0, 0, 1}},
	}

	for _, test := range tests {
		l1 := buildLinkedList(test.l1)
		l2 := buildLinkedList(test.l2)
		got := getListValues(addTwoNumbers(l1, l2))

		if !reflect.DeepEqual(got, test.want) {
			t.Errorf("Input: l1=%v, l2=%v\nGot: %v\nWant: %v", test.l1, test.l2, got, test.want)
		}
	}
}
```

## Conclusion
Well done! You have successfully solved the Add Two Numbers problem on Leetcode. This problem introduced you to arithmetic operations on linked lists. By reversing the order of digits, you were able to perform addition on the linked lists and return the result as a new linked list.

Now that you have gained confidence in solving this problem, it's time to tackle more challenges on Leetcode. Keep practicing and enhancing your problem-solving skills. Good luck with your future endeavors!
How to upload base 64 image in Nodejs Application
Published: 2023-07-15 10:13:33

While development in Node.js, Mostly developers uses multer package to upload the image or other type of files to server. But some time we may get the image in base64 image format.

 

So in this article, We will see how a base64 image can be uploaded to the Node.js server. Here we will user Buffer to upload files.


### What is Buffer?

Node provides Buffer class which provides instances to store raw data similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. **Buffer** class is a global class that can be accessed in an application without importing the **buffer** module.

 

Create Node.js app and install dependencies with below command:

``````npm init --yes

npm i express body-parser fs mime``````


After installing above dependencies, Create a file inside project folder named server.js and put below code inside it:

``````/*
* @Author: Pankaj Kumar.
* @Date: 17 June 2019
* @Source : https://jsonworld.com/
* @Topic : base-64-image-upload
*/
 
const express = require('express');
const app = express();
const port = 3000;
const bodyParser = require('body-parser');
const fs = require('fs');
const mime = require('mime');
 
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
 
// parse application/json
app.use(bodyParser.json());
 
 
const uploadImage = async (req, res, next) => {
// to declare some path to store your converted image
var matches = req.body.base64image.match(/^data:([A-Za-z-+/]+);base64,(.+)$/),
response = {};
 
if (matches.length !== 3) {
return new Error('Invalid input string');
}
 
response.type = matches[1];
response.data = new Buffer(matches[2], 'base64');
let decodedImg = response;
let imageBuffer = decodedImg.data;
let type = decodedImg.type;
let extension = mime.extension(type);
let fileName = "image." + extension;
try {
fs.writeFileSync("./images/" + fileName, imageBuffer, 'utf8');
return res.send({"status":"success"});
} catch (e) {
next(e);
}
}
 
app.post('/upload/image', uploadImage)
 
app.listen(port, () => console.log(`Server is listening on port ${port}`))``````


### Run the app

Run the app with the below command:

``````node server.js``````

Now check everything done over postman tool with input and url like below:


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


### Conclusion

So in this article, I explained how to upload base64 file in the Node.js Application. If you are new to Node.js then click here to find many demos to start the app for enterprise-level application

Let me know your thoughts over the email demo.jsonworld@gmail.com. I would love to hear them and If you like this article, share with your friends.

This article is originally posted over [jsonworld](jsonworld.com)
🧠 Image Classification Tutorial: Train and Detect Objects with TensorFlow and Pixellib ⚙️
Published: 2023-07-15 10:08:42

🎥 Discover the world of image classification using TensorFlow, Pixellib, and Python in our latest video tutorial! 🌟 
Learn how to train and detect custom images, enhancing your computer vision skills. 📸🔍

In this informative tutorial, we'll explore the process of annotating objects within images, creating accurate labels with dot markings and JSON files. We'll also introduce the ResNet101 model, a powerful pre-trained deep learning architecture, to train our custom images and labels.

If you are interested in learning modern Computer Vision course with deep dive with TensorFlow , Keras and Pytorch , you can find it here  : http://bit.ly/3HeDy1V
Perfect course for every computer vision enthusiastic

A recommended book , https://amzn.to/44GnlLW - "Make Your Own Neural Network - An In-depth Visual Introduction For Beginners "
Code for this video: https://github.com/feitgemel/Object-Detection/tree/main/Pixellib

The link for the video : https://youtu.be/i9MEXrLtFOQ

Enjoy
Eran


#Python #Cnn #TensorFlow #deeplearning #neuralnetworks #pixellib
Reading, Displaying and Saving Images using OpenCv
Tags: webdev, python, ai, machinelearning
Published: 2023-07-15 09:39:39

- 
OpenCv is an advance library used for image detection and manipulation .It was instrumental in the  development  the first self driving car.

In this tutorial we would explore some of the building block of image manipulation using the python OpenCv library.


Images are just numpy array with which has a given row and columns .Each row/columns contains a number ranging from o-255 for single channel and RGB for three channels .

A one channel image is called grayscale because it two colour are just black and white ranging for 0 to 255.

A three channel image is also called coloured image because it uses the RGB for colours meaning RED,GREEN,BLUE 

- Read image 

`
import cv2
import numpy as np
import matplotlib.pyplot as plt

retval = cv2.imread('files/img_bw_18x18.png',cv2.IMREAD_GRAYSCALE)
print(retval)`


`OpenCv image`

![OpenCv image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/24cp40jd67kwkl63k85w.png)

`original Image`

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

- To save image 


`
cv2.imwrite('new_mage.png',retval)
`

Thanks for reading
API Gateways for Microservices: A Must-Have for Modern Applications
Tags: api, apigateway
Published: 2023-07-15 08:51:02

Microservices are a popular architectural style for building complex applications. They offer a number of benefits, such as scalability, flexibility, and maintainability. However, microservices also introduce a number of challenges, such as complexity, security, and performance.

An API gateway is a software application that acts as a single point of entry for microservices. It routes client requests to the appropriate services, and provides a number of other features such as load balancing, authentication, and authorization.

![API Gateway](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eh3usowjic81p2cqphm.png)

## Why Do You Need an API Gateway for Microservices?
There are a number of reasons why you need an API gateway for microservices. Here are a few of the most important:

### Improved performance and scalability
An API gateway can help to improve performance and scalability by routing client requests to the appropriate microservices. This allows the load to be distributed across multiple microservices, which can help to prevent any single microservice from becoming overloaded.

### Enhanced security
An API gateway can help to enhance security by providing features such as authentication and authorization. This helps to protect microservices from unauthorized access.

### Simplified management
An API gateway can simplify management by providing a single point of control for microservices. This makes it easier to monitor, troubleshoot, and update microservices.

## Use Cases for an API Gateway
There are a number of use cases for an API gateway. Here are 6 of the most common:

### Request routing
An API gateway can route client requests to the appropriate microservices. This can help to improve performance and scalability, as it allows the load to be distributed across multiple microservices.

### Load balancing
 An API gateway can load balance client requests across multiple microservices. This can help to ensure that no single microservice is overloaded.

### Authentication
An API gateway can authenticate client requests. This helps to protect microservices from unauthorized access.

### Authorization
An API gateway can authorize client requests. This helps to ensure that clients only have access to the resources that they are authorized to access.

### Rate limiting
An API gateway can rate limit client requests. This helps to prevent microservices from being overwhelmed by too many requests.

### Caching
An API gateway can cache responses from microservices. This can help to improve performance by reducing the number of requests that need to be made to microservices.

## Conclusion
An API gateway is a critical component of a microservice-based system. It provides a number of features that make it easier to manage, secure, and scale microservices. If you are considering using a microservice architecture, then you should also consider using an API gateway.
Fitts's Law in the Age of Modern Touchscreen Phones
Tags: ux, mobile, uxfortherestofus
Published: 2023-07-15 08:43:37

[#ux_for_the_rest_of_us ] [#day_2]

## Fitts's Law,

> A principle from human-computer interaction that predicts the time it takes for a user to point at a target area.

Simply put, Fitts's Law says that

> The larger and closer a target, the quicker it is to click on.

This principle, first introduced in the 1950s, is more relevant than ever today. With smartphones playing a central role in our lives, optimizing our apps for touch has become critical. Let's understand how Fitts's Law applies to modern touchscreen phones.



- **The target should be large enough for fingers to accurately tap:** To start with, our screens are our 'pointing device' and our fingers are the cursors. The touch targets — the buttons, links, and other interactive elements on a screen — should be large enough for fingers to accurately tap. Remember, the ["Fat finger"](https://en.wikipedia.org/wiki/Fat-finger_error) problem is real. Apple's iOS Human Interface Guidelines recommend a minimum target size of 44 pixels wide and 44 pixels tall ( [source](https://developer.apple.com/design/human-interface-guidelines/buttons#Best-practices) ).



![Image source: https://dribbble.com/shots/18173915-Login-Get-Started-Animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xi4f75treueqdx2n4pg0.png)



- **Frequently used elements within easy reach of the thumb:** the positioning of these touch targets is vital. Designing apps with Fitts's Law in mind means placing frequently used elements within easy reach of the thumb. This is often why you'll see key navigation elements at the bottom of mobile apps.


![Image source: https://dribbble.com/shots/19457217-Touch-ID-authorization](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bazyf5dlogw2t3y57yvt.png)


- **Be wary of edges and corners:** Fitts's law indicates that screen edges and corners are essentially 'infinitely large' targets because the pointer cannot go beyond these boundaries, making them very fast to hit. However, on touchscreen devices, corners especially can be hard to reach, turning a theoretically 'infinite' target into a tricky one.

**Final Word:** As we create mobile interfaces, let's keep our touch targets big, and within easy reach, and think about the usability of screen edges. Doing so will make our apps more user-friendly.
Cheers to better, more ergonomic designs in our pockets! 🥂📲
Need to develop a calendar App similar to Calendly
Published: 2023-07-15 08:35:08

Hello,

We have a requirement to develop a calendar similar to Calendly App. We should be able to create events, provide availability while creating events, let the users schedule the events and block the calendar accordingly. We want to create zoom meetings for all the events scheduled. We have multiple organizations and we should be able to fetch the meeting details along with the zoom details and organization details and store it in our MYSQL DB. Is there any PHP code available for this? We use PHP, Javascript and HTML for coding. Please help.