teleren/devto huggingface dataset:
Flutter Open WhatsApp & send Text Message to Specific WhatsApp
Tags: flutter, dart, flutterapp
Published: 2021-07-11 13:59:13

In Flutter Open Whatsapp and send text message is very easy. You can do it without using Flutter Share Plugin. If You want to launch Whatsapp application from Flutter code with predefine text message then you should follow this tutorial <a href="https://www.dripcoding.com/flutter-open-whatsapp-and-send-text/">How Flutter Open WhatsApp And Send Text Message</a>. You can dynamically change the WhatsApp number as well. Just get the working WhatsApp number from server api call and use it on flutter code given below as dynamic variable.
This Flutter Code is working on Both Android & iPhone. So I will suggest you to run this code on Real Mobile phone not on emulator. WhatsApp Must installed on your mobile phone. Otherwise you will get an error “whatsapp is not installed”.
Create a button
I am going to Create a simple text button in Stateful widget and on Button Click whatsapp app will be open. If you have confusion about stateless and stateful widget, so Please read my article. To make text as clickable widget, wrap Text widget with a GestureDetection Widget. Once use will click on button, we will call a function name as “openwhatsapp()“. You can choose other name as well. Below is the code for build method. You can follow this tutorial How Flutter Open WhatsApp And Send Text Message for complete code.
<code>
@override
Widget build(BuildContext context) {
  return Scaffold(
    body: SafeArea(
      child: GestureDetector(
        onTap: (){
          openwhatsapp();
        },
        child: Container(
          padding: EdgeInsets.all(40),
          child: Text(" contact US"),
        ),
      ),

    ),
  );
}
</code>
Create Function
Now we need to write code in openwhatsapp function. We need to write separate code for android and iphone. The only difference is on URL string only , rest of the code is same. Below is the code for open whatsapp and send text predefine text message.
<code>
openwhatsapp() async{
  var whatsapp ="+919144040888";
  var whatsappURl_android = "whatsapp://send?phone="+whatsapp+"&text=hello";
  var whatappURL_ios ="https://wa.me/$whatsapp?text=${Uri.parse("hello")}";
  if(Platform.isIOS){
    // for iOS phone only
    if( await canLaunch(whatappURL_ios)){
       await launch(whatappURL_ios, forceSafariVC: false);
    }else{
      ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: new Text("whatsapp no installed")));

    }

  }else{
    // android , web
    if( await canLaunch(whatsappURl_android)){
      await launch(whatsappURl_android);
    }else{
      ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: new Text("whatsapp no installed")));

    }


  }

}
</code>
Now run the code on real mobile phone. How Flutter Open WhatsApp And Send Text Message.
If you have any questions please feel free to contact me at <a href="https://www.dripcoding.com/flutter-open-whatsapp-and-send-text/">www.dripcoding.com</a>
Colour Quantization Using K-Means Clustering and OpenCV
Tags: python, machinelearning, opensource, datascience
Published: 2021-07-11 13:57:29

Topic: Colour Quantization Using K-Means Clustering and OpenCV

https://www.analyticsvidhya.com/blog/2021/07/colour-quantization-using-k-means-clustering-and-opencv/

Have you ever wondered how we can implement a machine learning algorithm on the pixel intensity value with a common K-means clustering algorithm?

In this method, we would generate a compressed variant of our picture with more scattered colours. The image will be processed in a lower intensity resolution, whereas the fraction of pixels will prevail. This procedure is very interesting, so I expect that you will like it.

This article can appear as a particularly impressive and unexpected one, so here is the link to the article, please have a read and hope you like it.

#algorithms #technology #machinelearning #datascience #artificialintelligence #python #kmeans #clustering #opencv #imageprocessing #computervision
Go vesioning v2
Published: 2021-07-11 11:17:45

ต่อจากคราวที่แล้วที่เราลองทำ lib ใน Go แบบที่ยังไม่ได้กำหนด version กันจริงจัง คราวนี้เราลองเอาของเดิมมาเล่นต่อ ด้วยการ upgrade มันเป็น version 2 ตามแบบที่ Go ทำกัน ก่อนอื่นก็เอา lib เรามายำก่อน

go.mod

```go
module github.com/pallat/versioning/v2

go 1.16
```

versioning.go

```go
package versioning

var Number = 2.0
```

เพื่อบอกว่า lib ตัวนี้ v2 เราเลยต้องแก้ module ให้เติม `/v2` ต่อท้ายไป แล้วก็ถือโอกาสเปลี่ยน type ของ Number ให้เป็น float64 ด้วยเลย เพราะมันจะเกิด incompatible ด้วย

จากนั้นก็ commit แล้วก็ push ขึ้นไปบน github แต่ ยังไม่พอ เราต้องติด tag ให้มันด้วยตามนี้

> git tag v2
> git push --tags

จากนั้นเรามาที่โปรแกรมที่เรียกใช้ lib ตัวนี้เป็นแบบนี้

```go
package main

import (
	"fmt"

	"github.com/pallat/versioning/v2"
)

func main() {
	fmt.Printf("%f\n", versioning.Number)
}
```

จากนั้นใช้คำสั่ง

> go mod tidy

แล้วลองรันดูใหม่ เพียงแค่นี้เราก็ได้ใช้ lib v2 เรียบร้อย

สรุปการทำ lib จะต้องทำอะไรบ้าง

1. ชื่อ module ให้ลงท้ายเลข major version เช่น `/v2`
2. ติด tag ตาม vesion แบบ SamVer โดยต้องมี `v` นำหน้า
ที่สำคัญ อย่าลืม push ขึ้นไปด้วยทั้ง code และทั้ง tag
The New Writing Playbook
Tags: blogging
Published: 2021-07-18 12:46:42

---
title: The New Writing Playbook
published: true
date: 2021-07-11 12:58:00 UTC
tags: blogging
canonical_url: https://dils.blog/the-new-writing-playbook/
cover_image: https://images.unsplash.com/photo-1471107340929-a87cd0f5b5f3?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDExfHx3cml0aW5nfGVufDB8fHx8MTYyNjA5NDM1Mg&ixlib=rb-1.2.1&q=80&w=2000
---
Okay so I know blogging is quite outdated so might as well figure out some guidelines going forward.

1. **No comments**  There were good comments back in the day but these days its too much of a hassle to maintain. A contact form or twitter should be enough. (Does not apply to dev.to, I'm happy to engage with comments here 🙂)
2. **SEO'ish**  If you use a CMS these days you get this for free. Don't stress too much about it and write like you just don't care, your people will find you.
3. **Minimal tracking**  No Google Analytics, something more privacy preserving just to see the areas of interest.
4. **No ads**  never really liked them myself so why push it on my readers. No ads but I might have another plan.

It would be nice to make some money with words ... 🤔

So my evil plan is to make money, so I can buy more plastics and mess up the world (not).

The money would help pay the hosting bill and move to a better platform so I don't have to tweak so many things and just write.

## References

- [Blogging Without Comments: Should You or Shouldn’t You?](https://neilpatel.com/blog/blogging-without-comments/)
- [🌱 My blog is a digital garden, not a blog](https://joelhooks.com/digital-garden)
- [A Blog Without Comments Is Not a Blog](https://blog.codinghorror.com/a-blog-without-comments-is-not-a-blog/)
- [Stop Publishing Web Pages](http://dashes.com/2012/08/14/stop_publishing_web_pages/)
- [Ad blocking - Wikipedia](https://en.wikipedia.org/wiki/Ad_blocking)
- [Privacy focused analytics](https://github.com/0xnr/awesome-analytics#privacy-focused-analytics)
- [Plastiturtle - Gehan Blok & Dino Corera](https://www.youtube.com/watch?v=nsrkm_cNuDI)
如何把舊 Mac 上的 LINE 對話紀錄備份、轉移到新 Mac
Tags: line, mac, chat, transfer
Published: 2021-07-11 12:57:32

---
title: 如何把舊 Mac 上的 LINE 對話紀錄備份、轉移到新 Mac
published: true
description: How to backup / restore LINE chat history from your old Mac to a new one.
tags: LINE,Mac,chat,transfer
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jr3lassxix8axonjiu93.jpg
---

如果新 Mac 沒有使用 MacOS「系統轉移」傳送舊電腦的資料到新的 Mac，你會發現安裝 LINE 之後，對話紀錄僅可以回溯到某個時間，更早的對話紀錄並無法顯示，也無法搜尋，這是因為更早的對話紀錄並不會存放在 LINE 的 server 上，這時需要手動轉移舊 Mac 上的紀錄到新 Mac。

這次我嘗試從 MacOS High Sierra 上備份／轉移 LINE 對話紀錄到 MacOS Big Sur ，到發文時測試沒問題。

以下我用到基本的 Terminal 操作，但只要知道路徑，直接備份／轉移資料也可行，ssh 的部分我會先略過，之後再另外寫一篇（寫了一下後發現根本懶得講）。

MacOS 上 LINE 對話紀錄與一些偏好設定的資料在
```
~/Library/Containers/jp.naver.line.mac/Data/Library
```
但因為其中有許多 link，需要備份／轉移的資料僅有 
```
~/Library/Containers/jp.naver.line.mac/Data/Library/Containers
```
簡單說你只要從舊 Mac 複製此資料夾，在新電腦上替換掉這資料夾，就完成了，但預設 `~/Library` 並不會顯示在 Finder，請在任一 Finder 按下 `cmd＋shift＋g`，然後貼上 `~/Library/Containers/jp.naver.line.mac/Data/Library`，就可以開始以下操作。

以下是我的操作流程，但某些步驟我不清楚是否是必要：

- 備份前先登錄舊 Mac 的 LINE，讓最新的對話紀錄下載到本機
- 替換掉新 Mac 的資料前，請不要刪除原有的 `Containers` 資料夾，請先改名就好，例如：`Containers_bk`
- 把舊 Mac 的資料夾複製出來，如果 LINE 對話紀錄很多（裡面應該也有包含下載到本機的照片、影片），會花一點時間，以我的例子，整包壓縮成 `xz` 後還有 3.2GB
- 替換資料的過程，登出並關閉兩台 Mac 的 LINE
- 替換資料後，登入新 Mac 的 LINE，請先檢查某個有很久歷史的聊天，是否可以顯示幾個月前，甚至幾年前的對話紀錄，不需要慢慢滾動滑鼠或軌跡板，方法是：在聊天內，按下鍵盤的 `fn＋方向鍵左` 不放，這是 PageUp，可以快速往上回溯對話紀錄
- 如果轉移／還原失敗，也請照上面流程做一次，只是這次將前面被改名的資料夾改回來，注意原本的 `Containers` 是複數
- 如果新的電腦沒什麼對話紀錄，且原有的資料夾也沒有保留，放心，開啟 LINE 後，近期幾天的對話紀錄還是會被保留在 LINE 的 server 上，LINE 會自動幫你建立 `Containers`，也會下載近期的對話紀錄

既然知道路徑了，備份當然就沒問題了，祝你成功。
My Dev Journey: Week 10
Tags: javascript, beginners, bootcamp, codenewbie
Published: 2021-07-11 12:45:34

This week was the second week in the front end block of the course, and this week we spent a lot of time going further in depth with React.

If you've enjoyed any of my blog series, then maybe consider following me on [GitHub](https://github.com/fearneyork) 😁

## What I've learnt this week

### Data fetching

For the start of this week we used the Fetch API to make requests to endpoints to get the data back that we were going to be using in our apps. The fetch API was a good start but I prefered it when we started to use Axios, as I think it reads a lot clearer that fetch.

I spent most of this first day getting base functionality added in to my app that retrieves NASA Astronomy Pictures of the Day, for specified dates in input fields.

### Styling with React

Building on top of the base functionality I added a couple of extra features in like beign able to search by a date range, and then got going on styling. I wanted it to be a fairly minimal site, but to use similar tones to the NASA logo, so that it all ties in, and was pretty happy with adjusting to styling with React.

One of the key principles from this lecture was on Mobile first design, and using media queries to display certain components styled in different ways because of screen sizes.

Another thing we learnt but I didn't have chance to apply was the use of CSS modules, something that I'd like to apply on a side project or by refactoring the code from this two-day sprint.

### React Routing

Routing in React was a blessing after having spent the last week with really long App files. The routing makes sense, especially after creating our own backends, it made processes much more alike.

### Context

Another issue I had with React at the start of the week was I felt like I was passing props through all over the place, which is where using Context allows me to have certain states to be seen globally across all components. This came in handy when wanting to tidy a lot of my prop chains up.

## Resources I've found useful this week

### CSS Tricks

[CSS Tricks](https://css-tricks.com) has been a great cheat-sheet style site, that has helped especially with [flex-box](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) bits.

### React Router

[React Router](https://reactrouter.com/web/guides/quick-start) has also been great for seeing examples of setting up React Apps with Routing.

### Figma

What's Figma? [Figma](https://www.figma.com/) is a pretty good way to quickly and collaboratively mock up the wireframes for an app and definitely helped us to start planning out what actually needed to be done first, rather than start aimlessly coding.
For Chinese DL Learners: Your First DL Environment
Tags: python
Published: 2021-07-11 12:38:36

# Why this article
安装Pytorch等环境堪称中国深度学习初学者的噩梦，本文将简单阐述安装工具辅助DL环境的安装。如果手头没有合适算力的设备推荐使用云服务器，这里个人尝试过Colab，Kaggle，矩池云，其中矩池云是付费服务器，但是综合体验值得推荐且价格低廉。因为是Linux服务器如果使用Pytorch记得更改num_workers的数值匹配服务器CPU核心数，否则会非常漫长。使用矩池云的时候个人感觉存在CPU配置过低带不动GPU的情况，推荐2080Ti级别的服务器起步。
This article is written for those DP learners located in China. Because of some well-known reasons (Firewall), access to some of the foriegn websites is not available. And, unfortunately, the libraries that are required to be installed using pip can be really hard (just nightmares!!!). Even the mirroring of '清华', '豆瓣' are not satisfactory.
In this article, I will try to state the steps of setting up training environments on Windows 10. If you would like to explore, the environment on Linux can be set up in a similar way.
# Steps to set up
## Install **Clash for Windows**
You can obtain this tool by simply searching on the Internet. It is recommended that you install from the official Github link (I am not putting the link here). To enable your access to the foreign websites, you may have to find (or buy) a route (If you find this difficult, refer to the advertisement in Clash for Windows). Paste the URL of your route in the profiles, and then click Download. Test your Prxoy list in **Proxies**.
## Set up Clash
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzuknsw4566al25zbu8a.png)
To proxy your device, first click System Proxy to 'ON' state. Then click the 'Launch Helper' which is included in 'UWP Loopback'.
Click 'Exempt All' and then 'Save Changes'.
## Install Python
In this step you have several choices to choose. Either you can install directly using Anaconda or [Python](https://www.python.org/downloads/windows/).
Personally I prefer the official Python version and you are suppose to install a Python with version lower than **3.8** for compatibility. Remember to choose 'Add Python to Path' when you are installing it.
## Install libraries
After the steps above are finished, you may install the needed libraries for Python. For example, **pip install numpy** will install numpy for your computer. And about whether to use [Pytorch](https://pytorch.org/) or Tensorflow, it is totally dependent on yourself.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mbuqfxmideioeei36v1g.png)
AWS re:skill Program 2021!!🤩🤩Earn Rewards
Tags: aws, machinelearning, firstpost, github
Published: 2021-07-11 12:30:46

#What is AWS?
Amazon Web Services (AWS) is a secure cloud services platform, offering **compute power**, database storage, **content delivery**and other functionality to help businesses scale.

**AWS Provides:**
1)Improve Skills 
2)Earn Rewards
3)Build Network



#AWS re:Skill  Program 2021
re:Skill in Partnership with **AWS Community** to help Developers learn and Meet the vast Community on **AWS Platform**.

![Reskill](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yekl3obypg51f9ac8gg5.jpeg)

#Major Highlights

1)Be recognized as an expert at the **National level**.
2)Earn **AWS Goodies**.
3)Free **Digital Badges** For all Candidates.
4)**Cash Prizes** Worth Rs. 5000 **Amazon Voucher**.

#Who Should Participate?

Participation is open to **all tech** enthusiasts. Go through the **learning videos** and take up the **challenge**, and get an opportunity to **win badges** and **points**.

#Learnings:- 

-> Got Experience in AWS.
-> Learned to work with the group.
-> Had a great Networking with Amazing Peoples! 

#How to Get Enrolled? 

Just **Login** to Re:skill Platform and You are Ready to Participate.
After **Completion of Quiz** and Gaining 1000 Points you are Eligible to **Redeem** your **T-Shirt**.
Then you will Receive **Email**:-

![Mail](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bqvdmt6binmtb85ny23.jpeg)

#T-Shirt I Received🤩🤩:-

![T-Shirt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bngxp0w58udjlu3heya.jpeg)

Get Connected with Me 🙂
[LinkedIN](www.linkedin.com/in/chinmay-kulkarni-a1a166205)
[Twitter](https://twitter.com/Chinmay94658154)
[GitHub](https://github.com/chinmaykulkarni19)
useLocal: the useState hook for a properly-synced state
Tags: react, hooks, usestate, typescript
Published: 2021-07-11 12:28:56

---
title: useLocal: the useState hook for a properly-synced state
published: true
description: 
tags: react, hooks, useState, typescript
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0cljv4w4iqw9rqy8qf4m.png
---

As you might know, the React hook `useState` takes one argument, which will initialize its internal state to that given value. When React 16 with Hooks got released, I found it a little bit confusing, but it perfectly makes sense.

No matter what, there are still situations, where you need to update the state based on the incoming props. Usually that is done using a `useEffect` hook, where you listen on the incoming prop to change, and then update your local state. 

This is a great way of handling it, because you, as the owner of the component can perfectly control, if the parent prop change is actually what you want. It could even break your component if the parent decides to update a prop during a critical state of your component. 

But there are also situations, where not much can happen. There are simple scenarios where you basically want to hold a local version and not propagate it up the tree until a certain condition happen. During that time, you still want to allow the parent controlling component to update the local value, if that is what it wants. 

Here is an example how to allow the parent controlling component set (and update, if necessary) the from and to values. It can happen that for example for whatever reason, there is another component, that can set a date range, for that, we would want that from and to can be updated. 

```ts
const RangeDatepicker = ({ value: { from, to }, onChange }) => {
   const [from, setFrom] = useLocal(from)
   const [to, setTo] = useLocal(to)
   const update = () => {
    if (from && to) {
      onChange({ from, to });
    }
   }
   
   useEffect(update, [from, to])
   
   return <MyCalendarRangePicker from={from} to={to} onChangeFrom={setFrom} onChangeTo={setTo} />
}
```

the easiest implementation of such a hook (in Typscript) looks like this

{% gist https://gist.github.com/theluk/13b7a17455b599699b7d34775cbf8273 file=useLocal.ts %}

One further improvement would be, to pass in some conditional function that checks, if it is allowed to update the local state. 

{% gist https://gist.github.com/theluk/13b7a17455b599699b7d34775cbf8273 file=useLocalConditional.ts %}

You can visit the gist here

https://gist.github.com/theluk/13b7a17455b599699b7d34775cbf8273
The Four Stages Of Full Software Testing
Tags: programming, webdev, javascript, tutorial
Published: 2021-07-11 12:21:27

👉Testing software is crucial to assure that it does what we expect it to do, and to catch problems as early as possible to speed up the development process.

👉The process of testing can be divided into 4 stages, starting from writing code and ending with deploying to production.

---

## 1️⃣ Commit Stage
This includes tests that fail fast
- A total run time of 5 minutes or less is preferred.

### What kind of tests?🤔
- Unit tests
	- Testing isolated units of behavior.
- Controller tests
	- For example, Given that we send a POST request to this endpoint, it should fail because the parameters are invalid.
- Database tests
	- For example, Given those records in the DB, this method should get them.
- Coding standards tests
	- This test fails because at file X you have 5 empty lines.

---

## 2️⃣ Acceptance Stage

### What kind of tests?🧐
- Acceptance tests
	- For example, When user X logs in and orders a new book, we should create a new order request and send an email.

- Performance tests.
- Configuration tests.
- Any other tests that we want to run prior to release.

---

## 3️⃣ Release Stage
This stage comes after building the software and attaching all its components together.

### What kind of tests?👀
- Smoke test
	- Test the system's most important features.
		- Sign-in, book purchase, etc...
	- Canary release testing🐤
		- Releasing the new version of the system to places of low impact.
		- For example, Netflix uses Canary releasing by releasing new updates to geographic locations in the world where it's 1 AM so if any failure happens, only few people experience it.🤫
- Exception tracking.

---

## 4️⃣ Product Stage
This stage is executed after the system is deployed to production and is under use.

### What kind of tests?❔
- Can it scale up/down?
- Is it using a lot of memory/disk/CPU?
- What is the request response time?
- Do performance metrics match predications?
- Security.
- For example Netflix has teams to test those aspects and try to break the system.
	- Chaos monkeys, Latency monkeys, Security monkeys🐒

---
### This material in this post is mainly derived from Dave Farley amazing [video](https://www.youtube.com/watch?v=z-3aSVfoyBY&t=761s) on testing.
📦 How is C++ Compiled?
Tags: cpp, c, tutorial, computerscience
Published: 2021-07-11 12:16:25

I've been using C++ for quite a while now. This got me into thinking, how does C++ work under the hood? So I came up with this short video in which I explain the whole C++ compilation process.

{% youtube rUtprDA0bgc %}

----
And that is it, folks. Let me know your takeaways from the video. If you have any other video or article ideas, comment on them too. Oh, BTW, do you want to learn Bash? Here's my crash-course post on Shell Scripting:

{% link https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk %}

----
🌟 I made some [Cheat-Sheets](https://github.com/godcrampy/cheat-sheets)
🚀 Stalk me on [Youtube](https://www.youtube.com/c/SahilBondre) | [Github](github.com/godcrampy) | [Twitter](twitter.com/godcrampy) | [Website](sahil.surge.sh)
😄 Have a wonderful day!
Visual Studio Code Tutorial for Beginners in 30 Minutes | Video
Tags: webdev, codenewbie, vscode
Published: 2021-07-11 12:05:13

Hey Devs, I have prepared for you a complete guide on visual studios code. In the following tutorial we will take a look at the various features of VS Code and how you can set up your development environment while working with VS Code.

##Video Tutorial
{% youtube euktKH2iHsY %}
Daily Developer Jokes - Sunday, Jul 11, 2021
Tags: jokes, dailydeveloperjokes
Published: 2021-07-11 12:00:18

---
title: "Daily Developer Jokes - Sunday, Jul 11, 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=Sunday%2C%20Jul%2011%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.
 -->