teleren/devto huggingface dataset:
ImportExcel and Conditional Formatting
Tags: powershell, importexcel
Published: 2022-07-06 07:05:17

Don't you love [ImportExcel](https://github.com/dfinke/ImportExcel)?

One example I couldn't find was a comparison of two cells with **each other**. With some directions from [Doug Finke](https://github.com/dfinke), I made it work. 

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

Adding conditional formatting for rows and cells if two columns have the same values requires the following rules in Excel:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okh932mdzyvys5j7rdkv.png)

They may be created using `Add-ConditionalFormatting` command:
```powershell
Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "C2:D10" -ConditionValue '=$C2=$D2' -RuleType Expression -BackgroundColor ([System.Drawing.Color]::Thistle) -Bold
Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "A2:D10" -ConditionValue '=$C2=$D2' -RuleType Expression -BackgroundColor ([System.Drawing.Color]::LavenderBlush)

``` 
 
And in case you already have some conditional formatting rules, and you would like to reuse them in your PS script, there's an easy way to "export them":
```powershell
Import-Module ImportExcel

$xlSourcefile = "YOUR FILE NAME"
$excel = Open-ExcelPackage -Path $xlSourcefile

$excel.Workbook.Worksheets | ForEach-Object {
    $_.ConditionalFormatting | ForEach-Object {
        Write-Host "Add-ConditionalFormatting -Worksheet `$excel[""$worksheetName""]  -Range '$($_.Address)'  -ConditionValue '$($_.Formula)' -RuleType $($_.Type) "
    }
}
```

The above script prints the `Add-ConditionalFormatting` commands which you can use in your script. It doesn't export the formatting, so make sure to add them =)
神奇的麵包板搜尋之旅
Tags: breadboard, gadgets
Published: 2022-07-06 07:02:43

因為臉書社團上有人問[哪裡有賣這種麵包板](https://www.facebook.com/groups/arduinotaipei/posts/5798500460177357/?comment_id=5798606630166740&reply_comment_id=5798841560143247&notif_id=1657085644169902&notif_t=group_comment_mention)：

![](https://i.imgur.com/Pvbpb9J.jpg)

圖片來自於這一個[日本的 Youtube 影片](https://www.youtube.com/watch?v=tgxVE5kpwFw), 右邊這個麵包板和一般市面上買到的不一樣, 內部的縱行是 6 孔, 不是 5 孔, 如果要使用像是 [Doit ESP32 Devkit](https://olddocs.zerynth.com/r2.6.2/official/board.zerynth.doit_esp32/docs/index.html) 這種比較胖的板子, 使用圖片中看到的麵包板就可以在控制板兩側留出空位接線, 不需要跨接兩個一般 5 孔的麵包板。

問題來了, 找遍台灣市面上銷售的麵包板, 都找不到這一種, 最後我在[英國的購物網站](https://www.rapidonline.com/k-h-ad-102-advanced-solderless-breadboard-456-tie-points-34-0676)上找到有銷售：

![](https://i.imgur.com/CFxKBUG.png)

這個編號 K & H AD-102 的麵包板就是了, 咦？怎麼哪裡怪怪的？來源國家是台灣啦, 經過搜尋, 原來這個 K ＆ R 是台灣的公司, 叫做[掌宇國際](https://www.kandh-edu.com.tw/web/about.php), AD-102 是他們旗下麵包板 [AD 系列](https://www.kandh-edu.com.tw/web/product-detail.php?pro_no=178)的其中一款, 可以從[規格書](https://www.kandh-edu.com.tw/web/DownLoadFile1.php?File=pro_pdf178.pdf&FileName=AD.pdf)中看到這系列就是縱行 6 孔：

![](https://i.imgur.com/7YnEGXW.png)

賓果, 就是它了！
An Awesome Distributed Transaction Middleware, Support Any Language!
Tags: distributedsystems, microservices, cloudnative, database
Published: 2022-07-06 07:01:05

The DBPack is an DB mesh resolution that implements in AT transaction mode, which is a distributed transaction model that has no invasion into the business logic and has high performance.

Github repo: https://github.com/CECTC/dbpack

You can learn more AT transaction in [this site](https://seata.io/en-us/docs/dev/mode/at-mode.html).

The DBPack is a little bit different from Seata AT transaction, it can be deployed as a sidecar in k8s, so that any programming language can use this sidecar to handle distributed transaction. It also support sharding DB and tables and more features are coming soon.

Here is a picture to describe the DBPack work flow, hope it can help you understand it better.


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

Here is the workflow description:

1. Slient sends HTTP request to DBPack proxy of Aggregation Service. (Note: request address and port should configuraed be DBPack proxy instead of actual Aggregation Service API address).

2. DBPack generates unique XID (global transaction id), and stores it in ETCD.

3. If global transaction begins successfully (will end transaction in case failed), the Aggregation Service can get XID through HTTP header (X-Dbpack-Xid). Then the Aggregation Service can send API request to Service1 and pass XID to it.

4. After Service1 receives the XID, it send business SQL to DBPack, the proxy will register branch transaction for Service1 (generate branchID, store in ETCD...)

5. After the Service1 been registered, the DBPack will generate undo_log for the business SQL, then the undo_log will commit along with local transaction of Service1.

6. Service2 will do the same step4, 5 as Service1.

7. The Aggregation Service can get the API result from Service1 and Service2, and decides if to global commit or rollback. In case both API success, it response HTTP 200 to DBPack. In case failed, it response other status code except 200. The DBPack will update global transaction to "commiting" or "rollbacking" in ETCD accordingly.

8. Through ETCD watch mechanism, Service1 and Service2 will know if to commit or rollback their branch transaction. (In case commit, they delete the undo_log; In case rollback, they execute the undo_log.)

9. After all branch been commited or rollbacked, the branch status will get updated in ETCD. The DBPack proxy of Aggregation Service will know that the global transaction is finished, then it will delete XID and BranchID info from ETCD.

dbpack support any languages, there is some samples:

Golang: https://github.com/CECTC/dbpack-samples/blob/main/go/README.md

JAVA: https://github.com/CECTC/dbpack-samples/tree/main/java

dotnet: https://github.com/CECTC/dbpack-samples/tree/main/dotnet

PHP: https://github.com/CECTC/dbpack-samples/tree/main/php

Python: https://github.com/CECTC/dbpack-samples/tree/main/python
JavaScript clone and rewrite property from existing object
Tags: javascript, webdev, beginners
Published: 2022-07-06 07:00:00

In JavaScript, we work a lot with Objects, and you'll have to modify some of the object data from time to time.

Let's take the following object as our example.

```js
const user = {
  username: 'Chris',
  online: false,
};
```

This user object is used to keep track of all the users and their status.

But what should we do when we want to set the online status to true, but the original one to remain false?

There are multiple good answers to this question, but I'll show you the easiest way to do this in this article.

## Using the spread operator to overwrite an object property

We'll use the [spread operator](https://daily-dev-tips.com/posts/10-ways-to-use-the-spread-operator-in-javascript/), which you can recognize by the three dots.

Let's say we want the status to be true. We can use the following call.

```js
console.log({ ...user, online: true });

// { username: 'Chris', online: true }
```

It's a super clean syntax and easy to see which value we are overwriting.

The only thing you must remember while using this method is that the order matters.

If we, for instance, put the property we want to overwrite. First, it won't work.
This is because the latter assignments always win.

```js
console.log({ online: true, ...user });

// { online: false, username: 'Chris' }
```

And that's the easiest way to overwrite an object value using JavaScript's spread operator.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Use TypeScript interface extends and type composition semantically
Tags: typescript, discuss
Published: 2022-07-06 06:55:49

Consider below example, you have an API which accepts three parameters: `current`, `pageSize` and `channelCode`.

```ts
interface Pagination {
  current: number;
  pageSize: number;
} 
interface GetUsersByPageRequestDTO {
  channelCode?: string;
}
```

Now you have two choice to pack these parameters.

**Option 1:**

```ts
interface GetUsersByPageRequestDTO extends Pagination {
  channelCode?: string;
}
```

**Option 2:**

```ts
type GetUsersByPageRequestDTO = {
  channelCode?: string;
} & Pagination;
```

Which one will you choose? Inheritance or composition?

For me, I will choose option 2, use intersection type(type composition). Because using inheritance requires semantic correctness. Which means the two need to have **is-a** relationship. E.g. Bear is an animal. So bear interface can extend animal interface.

Apparently, `GetUsersByPageRequestDTO` is **NOT** a `Pagination`. 

So we know the difference between `interface` and `type`, but we also have to pay attention to the semantic correctness, not only to get the final correct shape, right?
let's connect for an open source project
Tags: programming, devops
Published: 2022-07-06 06:53:28

❤️Catch me on : [GitHub](https://github.com/deepakydv9315) || [Codepen](https://codepen.io/deepakydv9315) || [Instagram](https://www.instagram.com/syco_coders/)

Hello coding soul hope you are doing great, recently i am **planning to work on an open source project on github**, where we developers from all over world can **came together and can collaborate**. 

**follow for updates:**
[GitHub Profile](https://github.com/deepakydv9315)
WordPress Word Counter
Tags: wordcounter, textcounter, numberofwords
Published: 2022-07-06 06:38:24

[WordPress Word Counter](https://wprefers.com/wordpress-word-counter/) tells you exactly how many words are in your article. This tool is used to check the number of words and characters in a particular article. Since a number of words are important for an article and you can create a perfect article with an accurate number of words these tools help you to analyze the number of words.


How to use WordPress Word Count?
To check word count, place your cursor into the WordPress word counter area and start typing. You can also copy and paste text from another program over into the online editor above. Then click submit button.

Knowing a text’s word count can be useful. For example, suppose a writer is required to write a certain number of words for an article, essay, report, tale, book, or paper. Word Counter will assist in ensuring that its word count meets a specified demand or remains inside a specific restriction.

Word Counter also works perfectly with Grammarly. This enables you to determine which terms you use how frequently and in what percentages. This will prevent you from overusing specific terms or word combinations and will allow you to check for the optimal keyword distribution in your work.
Back on the grind - New Years Resolution - Dev Log 35
Tags: webdev, beginners, programming, startup
Published: 2022-07-06 06:13:50

I am officially back on the coding grind and trying to get this metaphoric bread. I am super excited about the next web application I am currently starting on. I do not want to spoil it early on but it is in the education space.

Over the last few weeks I have thought up many good ideas to pursue, but I ended up going with another web application, it's my strong suit. I am allured to trying to create a mobile app or game using unity. That is only because the technologies are still foreign to me, which makes them more exciting. Unfortunately, I do not have time to learn a bunch of new skills and technologies. The clock is ticking and I believe that the smart play is to use the skills I have. Going off that thought, I am going to use the exact same stack as my previous project (the job board); except I might trade Redis for Mongo. Mongo and Redis are both great options for fully managed cloud databases, but while I loved using Redis, Mongo is a little more mature as a technology.

Today was the first day I was getting back into the grind of coding, which felt good. I was looking at the blank canvass and have made a terrible first draft UI for my homepage. I am hoping after refining it a few times that I will have one of those modern SASS homepage looks. The ones that have sections based on complimentary background colors, if ya know, ya know.

That is the update. I am back at the grind. I will spill the beans on the idea later once I get further into development. I am one of those people who romanticize my own ideas, so for now I think it's just about the best idea ever. Once I get to marketing and actually attempting to get users, my many failed attempts will deflate my ego real quick; but for now, this idea slaps.
10 TIPS TO GET A JOB AT BIG TECH COMPANIES
Tags: career
Published: 2022-07-06 06:10:46


LINK - https://kovasys.com/10-tips-to-get-a-job-at-big-tech-companies-like-google-facebook-amazon/

Thats it for this post.
THANK YOU FOR READING THIS POST AND IF YOU FIND ANY MISTAKE OR WANTS TO GIVE ANY SUGGESTION , PLEASE MENTION IT IN THE COMMENT SECTION.
^^You can help me by some donation at the link below Thank you👇👇 ^^
☕ --> https://www.buymeacoffee.com/waaduheck <--

Also check these posts as well
https://dev.to/shubhamtiwari909/higher-order-function-in-javascript-1i5h

https://dev.to/shubhamtiwari909/styled-componenets-react-js-15kk

https://dev.to/shubhamtiwari909/introduction-to-tailwind-best-css-framework-1gdj
Add Github Star Icon to your project in just 1 HTML tag
Tags: webdev, html, javascript, productivity
Published: 2022-07-06 06:05:36

Do you know you can add Github Icons like Star, Fork & others to your project in just 1 line of code?
If not, then keep reading...

You might have seen the Github star icon on many websites or projects that shows the total number of people who marked the repo as a star & clicking it redirects you to the repo where you can also mark it as a star.


![come inside](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/od66dohao9ibur3sygsc.gif)

Let's jump into the code

```
<iframe 
src="https://ghbtns.com/github-btn.html?user=twbs&repo=bootstrap&type=star&count=true&size=large" frameborder="0"
scrolling="0"
width="170"
height="30"
title="GitHub">
</iframe>
```
**Live Examples**

{% codepen https://codepen.io/gulshanaggarwal/pen/dymYgNX  %}

You may be thinking...

**How can I customize it for my own repo?** 🤔
**Src** attribute let you customize it, by changing query parameter key values you can make it useable for your own repo. Let's take a look at these **5 important** keys of the URL-

- **user -** replace it with your Github Username
- **repo -** your repo name
- **type -**icon type(keep the value same)
- **count -** shows the number of star count(optional)
- **size -** for large icons(optional)

You are almost done! 
**But what if I want to resize the icon ?**🤔
Ok, then there are also some other attributes such as **width** and **height** that are gonna help you in resizing. Don't add pixels units with width & height attribute, just add the value & then it will automatically do it for you.

🏁 Here we discussed one of the commonly used star icon, there is more than that, read more about other icons [here](https://ghbtns.com/).
If you know a better way then let me know in the comments.

Thank you for reading

![goodbye](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6wlcy9el2rohf3ut5vjs.png)
When Unity won't let you in
Tags: gamedev, unity3d
Published: 2022-07-06 05:48:55

Sometimes Unity refuses to open, and that's okay... not?

**Before** reimporting your project (sometimes this doesn't even fix the problem) or reverting your VCS changes, or applying any suggested fixes: check `Editor.log` under: 

`C:\Users\USER_NAME\AppData\Local\Unity\Editor` 

This will help confirming the issue.

Then, here's a few things you can do:

- Try just opening another project, and maybe re-setting the layout?
- Delete your `Packages/manifest.json` (backup the manifest so you won't lose track of your custom packages, if any!)
- Delete the `/Temp` directory next to `/Assets`
- Delete the editor layout (see below); sometimes Unity crashes on opening custom asset windows (or just any window trying to load broken data)
- Read a [long thread](https://forum.unity.com/threads/can-not-launch-unity-due-to-failed-to-load-window-layout.694450/)!

About the editor layout - this is typically saved in several locations:

- `Library\CurrentLayout.dwlt`

But also `LastLayout.dwlt`, which moves around a bit but seen in these places (search within `Editor-5.x!`)

Windows 
- `%APPDATA%\Unity\Editor-5.x\Layouts\`
- `%APPDATA%\Unity\Editor-5.x\Preferences\Layouts\default\`

MacOS
- `~/Library/Preferences/Unity/Editor-5.x/Layouts/LastLayout.dwlt`

Note: literally pasting `%APPDATA%\Some\Thing` in explorer does work and faster than figuring where that is!
How to Plot an audio file using Matplotlib
Tags: python, audioanalysis, beginners, nlp
Published: 2022-07-06 05:24:50

## Introduction
Plotting and visualizing an audio file is one of the most important processes in audio analysis. Audio analysis is the process of transforming, exploring, and interpreting audio signals recorded by digital devices so as to extract insights from the audio data.

In this article, we are going to plot a waveform of an audio file with matplotlib.

## Prerequisites
- Python installed
- Numpy installed
- Matplotlib installed
- Background in data analysis

## Importing module and libraries
As a first step, let's import the modules and libraries that we will need.
```
import wave
import matplotlib.pyplot as plt 
import numpy as np
```
We will use wave module and numpy to preprocess the audio. We will use matplotlib for plotting the audio.

## Loading the Audio file
The audio file that we will use is a wave file.
Let's load the wave file that we want to plot

```
obj = wave.open('audio_file.wav', 'rb')
```

## Getting Audio parameters
Let's print out the audio parameters such as number of channels, sample width, etc.
We will use `.getparams()` method of the wave module

```
print('Parameters:', obj.getparams())
```
**Output:** _Parameters: _wave_params(nchannels=1, sampwidth=2, framerate=22050, nframes=81585, comptype='NONE', compname='not compressed')_

Now let's get the parameters that we will need for plotting the audio.

- Sample frequency, this is the number of samples per second

```
sample_freq = obj.getframerate()
```

- Number of samples, this is the total number of samples or frames in the audio file

```
n_samples = obj.getnframes()
```

- Signal wave, this is the wave amplitude which is the sound intensity.

```
signal_wave = obj.readframes(-1)
```

- Audio length, this is the duration of the audio.

```
duration = n_samples/sample_freq
```

## Creating numpy objects
Let's create a numpy object from the signal_wave. This will be plotted on the y-axis.

```
signal_array = np.frombuffer(signal_wave, dtype=np.int16)
```
Let's create a numpy object from duration. This will be plotted on the x-axis

```
time = np.linspace(0, duration, num=n_samples)
```
## Creating an audio plot

```
plt.figure(figsize=(15, 5))
plt.plot(time, signal_array)
plt.title('Audio Plot')
plt.ylabel(' signal wave')
plt.xlabel('time (s)')
plt.xlim(0, time) #limiting the x axis to the audio time
plt.show()
```
**Output:**

![Output of the plot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqieuv0iw5017dve5ixg.PNG)
## Conclusion
In this article, we've learnt how to plot a waveform of an audio file. Apart from plotting the waveform, another plot we can get from an audio file is frequency spectrum. For the frequency spectrum, we plot sample frequency against time. To learn how to plot a frequency spectrum, checkout this [link.](https://learnpython.com/blog/plot-waveform-in-python/)

## Credits
[Audio Processing Basics(Assembly AI)](https://www.youtube.com/watch?v=n2FKsPt83_A&list=PLcWfeUsAys2nb0i79L_LqYVfwOWEYA4eD&index=2)
[Audio Analysis(altexsoft)](https://www.altexsoft.com/blog/audio-analysis/)
299. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-06 05:19:49

```
class Solution {
 public:
  string getHint(string secret, string guess) {
    int A = 0;
    int B = 0;
    vector<int> count1(10);
    vector<int> count2(10);

    for (int i = 0; i < secret.length(); ++i)
      if (secret[i] == guess[i])
        ++A;
      else {
        ++count1[secret[i] - '0'];
        ++count2[guess[i] - '0'];
      }

    for (int i = 0; i < 10; ++i)
      B += min(count1[i], count2[i]);

    return to_string(A) + "A" + to_string(B) + "B";
  }
};

```





Link to the problem:  
https://leetcode.com/problems/bulls-and-cows/


#leetcode 
#challenge
#challenges
1. Leetcode Solution in Python
Tags: python
Published: 2022-07-06 05:09:11

```
class Solution:
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        length = len(nums)
        for i in range(length):
            for j in range(i + 1, length):
                if nums[i] + nums[j] == target:
                    return [i, j]
```
Working with JSON in C#
Tags: json, coupon, beginners
Published: 2022-07-06 05:03:35

JavaScript Object Notation (JSON) is a way of representing data structures in a “human-readable” form that can be used to exchange information between two different applications. Most commonly this is between client-side JavaScript running in a web browser, and a server-side script running on the web server. Although derived from JavaScript, JSON is a flexible format that can be used with many programming languages.

C# developers have a variety of structures, data formats, and mechanisms they can use to exchange information. The most common use of JSON for them is when communicating with a web service that only accepts and returns data in JSON format. It may be helpful to get an introduction to web APIs before continuing, which will provide background information as to why JSON is used and the benefits of working with web services. A fair amount of experience working with C# is assumed here, so it would be beneficial for [beginners to learn programming in C#](https://www.udemy.com/course/programming-for-complete-beginners-in-csharp) prior to attempting these techniques.

## A Brief Overview of JSON
JSON represents objects in a structured text format, with data stored as key-value (or attribute-value) pairs, an example of which is shown below:
`<script type="text/javascript">
var udemy = {
"name": "Media Relations",
"email": "press@udemy.com",
"notes": "Member of the media? We'd love to hear from you."
};
</script>`
This script block was written for inclusion on a web page, and declares an object representing an entry in a simple address book or contacts list. From JavaScript, you access the information using a dot syntax like udemy.name or udemy.email. The code between the equals sign and the semicolon is what is referred to as JSON.

Because of the flexibility that JavaScript offers, it’s possible to declare a list of objects using one assignment statement:
`<script type="text/javascript">
var contacts = [
{
"name": "Media Relations",
"email": "press@udemy.com",
"notes": "Member of the media? We'd love to hear from you."
},
{
"name": "Business Development",
"email": "bizdev@udemy.com",
"notes": "For general business development inquiries."
}
];
</script>`
Notice how square brackets are used to mark the array of objects, and each object is surrounded by curly brackets and separated by a comma.


> **[Udemy Coupon Codes](https://www.todaydeals.org/store/udemy)**
> Get up to 100% discount for best Udemy courses with specially selected Udemy coupon codes that guarantee great savings.
509. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-06 05:00:42

```
class Solution {
 public:
  int fib(int N) {
    if (N < 2)
      return N;

    vector<int> dp{0, 0, 1};

    for (int i = 2; i <= N; ++i) {
      dp[0] = dp[1];
      dp[1] = dp[2];
      dp[2] = dp[0] + dp[1];
    }

    return dp.back();
  }
};

```