teleren/devto huggingface dataset:
Crushing Job Interviews(DSA) - Two Number Sum
Tags: beginners, algorithms, webdev, javascript
Published: 2022-06-23 07:29:24

### The Question

##### Difficulty: **Easy**


Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum. If any two numbers in the input array sum up to the target sum, the function should return them in an array, in any order. If no two numbers sum up to the target sum, the function should return an empty array.

Note that the target sum has to be obtained by summing two different integers in the array; you can't add a single integer to itself in order to obtain the target sum.

You can assume that there will be at most one pair of numbers summing up to the target sum.

**Sample Input**
```javascript
array = [3, 5, -4, 8, 11, 1, -1, 6]
targetSum = 10
```

**Sample Output**
```javascript
[-1, 11] // the numbers could be in reverse order
```
##### Optimal Space & Time Complexity:
O(n) time | O(n) space - where n is the length of the input array

### The Thinking

If you paid attention to the boring maths professor's class, you might be able to come up with this solutions very easily.

So lets say
```javascript
// 10 is the target sum
10 = x + y
// so
y = 10 - x
```
> P.S: Hashmap is just a object in javascript or dictionary in python.

So now what we do is, we create a hashmap and iterate through the array that's given to us. Then we:

* check if the hash has y ie ` 10 - x  `
* if the value is there, then we return the array, since we have both x and y
* if not then we add that num to the hashmap


### The Solution
```javascript
function twoNumberSum(array, targetSum) {
    const nums = {} // this is the hashmap

  for (let num of array){
    if (nums[targetSum - num] ) return [targetSum-num, num]
    nums[num] = true
  }

  return []
}
```

Got any doubt's ? Got a better solutions ? Drop a comment below and let's start a discussion.

Follow me on instagram for more awesome content on coding: https://www.instagram.com/dhruvindev
Quick branded light and dark modes with Fluent UI React v9
Tags: fluentui, javascript, webdev, tutorial
Published: 2022-06-23 07:28:17

When building Teams Apps, Office Add-ins, or any kind of Microsoft 365 integration there's always a balance of retaining your apps brand and aligning with the hosting apps UX. 

However, if you are building an experience and your app maybe only has a brand color, then I'd recommend aligning with the hosting application UX so that your end customers have a consistent experience using your add-in, extension, or app.

This can be easily achieved by using the brand theming capabilities with [Fluent UI React v9](https://react.fluentui.dev).

The library comes with light mode and dark modes built in with the ability to supply your own brand variants.

## 1. Create a `BrandVariants` object
The `BrandVariant` interface is just a color palette of 16 stops. There are tools available to create color palettes (which we are looking to make that easier in the future.) but for this example I've created a simple one here:
```
const myBrand = {
"10":"#000000",
"20":"#011800",
"30":"#002700",
"40":"#00360c",
"50":"#004612",
"60":"#005618",
"70":"#00671f",
"80":"#007826",
"90":"#218935",
"100":"#3e9949",
"110":"#59a85e",
"120":"#73b776",
"130":"#8ec68f",
"140":"#aad5a9",
"150":"#c6e4c5",
"160":"#e2f2e2"
};
```
## 2. Create a light and dark theme
Once you have your custom `BrandVariants` object, then you simply create a light theme and a dark theme calling `createLightTheme` and `createDarkTheme` respectively.
```
const light = createLightTheme(myBrand);
const dark = createDarkTheme(myBrand);
```

## 3. Pass your `Theme` to the `FluentProvider`
Now that you have a light and dark theme, you can pass that into the `FluentProvider` for your application and all the components within that scope will pick up colors from the custom `BrandVariants.`

```
<FluentProvider theme={light}>
  <Button appearance="primary">Button</Button>
  <Switch defaultChecked label="Switch" />
  <TabList defaultSelectedValue="tab1">
    <Tab value="tab1">Tab 1</Tab>
    <Tab value="tab2">Tab 2</Tab>
    <Tab value="tab3">Tab 2</Tab>
  </TabList>
  <Slider defaultValue={50} />
</FluentProvider>
```
The best part here is that Fluent UI React v9 will apply the `BrandVariants` values across the components in the rest, hover, and pressed states so that you don't need override each component individually. 

So there you have it. A quick way to create light and dark mode support with a splash of brand color for your Microsoft 365 apps, add-ins, and extensions.

As always, you can find the full CodesandBox here:
{% embed https://codesandbox.io/embed/custom-theme-y90xfs?fontsize=14&hidenavigation=1&theme=dark %}

For more on Fluent UI React v9:
- GitHub: https://github.com/microsoft/fluentui
- Docs:  https://react.fluentui.dev
- Twitter: https://twitter.com/fluentui

Enjoy!
Turn on TS flag evolutionarily
Tags: typescript, fronted, bash
Published: 2022-06-23 07:24:41

# Introduction

After migration a JavaScript project to TypeScript it is good to turn on some `compilerOptions` flags. Some of them are easy, like [strictBindCallApply](https://www.typescriptlang.org/tsconfig/#strictBindCallApply) but for example [strictNullChecks](https://www.typescriptlang.org/tsconfig#strictNullChecks) can throw many errors: `Found 649 errors in 184 files.` Migrating all of them in one pull request can create many bugs or merge conflicts. On the other hand without this migration the amount of strictNullChecks errors can increase.

Unfortunately there's no way to turn a compilerOptions flag on only part of the project. However we can track the amount of these errors.

# Implementation

```json
"scripts": {
  "typeCheck": "tsc",
  "typeCheck:checkNulls": "tsc --strictNullChecks true"
}
```

Now we can check how many errors we have. Of course this script will always fails so we can not add it to the CI process. To add it we have to add some pipes:

```bash
yarn typeCheck:checkNulls | grep error | wc -l
``` 
Grep will filter files without `error` and `wc -l` will reduce lines with errors to just a number. Then simple `>` operation will check if the amount of errors wasn't increased. In bash it looks like this:

```bash
if [ $(yarn typeCheck:checkNulls | grep error | wc -l) -gt 649 ]; then exit 1; fi
```

# Summary

This solution isn't perfect. For example you can fix old one then create a new error and CI will not catch it. Also IDE will not inform about any strictNullChecks error because in the `tsconfig.json` flag is set as false. I this case simplicity is the main advantage: one line in `package.json` and one in CI config. But compared to alternatives: migrating all by once or separate modules from the project it doesn't look so bad.
What is YOLOv3 model?
Tags: machinelearning, model
Published: 2022-06-23 07:21:14

**YOLO: Real-Time Object Detection**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xeivcg09y9hi7pg7ega4.png)


Check out [this video](https://youtu.be/MPU2HistivI) to know how fast it detects objects.

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



**How It Works**

Prior detection systems repurpose classifiers or localizers to perform detection. They apply the model to an image at multiple locations and scales. High scoring regions of the image are considered detections.

We use a totally different approach. We apply a single neural network to the full image. This network divides the image into regions and predicts bounding boxes and probabilities for each region. These bounding boxes are weighted by the predicted probabilities.



Our model has several advantages over classifier-based systems. It looks at the whole image at test time so its predictions are informed by global context in the image. It also makes predictions with a single network evaluation unlike systems like R-CNN which require thousands for a single image. This makes it extremely fast, more than 1000x faster than R-CNN and 100x faster than Fast R-CNN. See our paper for more details on the full system.

Check out this website to know [more](https://pjreddie.com/darknet/yolo/)
How to "go get" from private repository
Tags: go, github
Published: 2022-06-23 07:18:46

Installing a go package is breeze with the introduction of `go mod`. However, when it comes to getting (installing) packages from private repository then it's not that straight forward.

In this post, I'll discuss how to `go get` from a private repository. I'll show how to get packages from Github.com, but method is almost same for other repository hosting services.

**OPERATING SYSTEM**: Mac or Linux

### STEP 1: Create SSH Key

In this step I'll generate SSH key, in my case I've multiple Github Accounts. One for is personal and another one for my organization I'm currently working with.

Please make sure that you give it a unique file name when asked.

```
ssh-keygen
```

Enter a name and select the default location `~/.ssh`
```
Enter file in which to save the key (/Users/<username>/.ssh/id_rsa):
```

### STEP 2: SSH Config file

This step is optional. I'm creating a config file to use multiple SSH keys for multiple GitHub/Bitbucket/Gitlab accounts.

**CREATE**(if not exist) a file `config` in `~/.ssh` and enter Host configuration for particular SSH keys and Github account.

Here is a sample:

```
# Bitbucket Account
Host acme
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/acme
    IdentitiesOnly yes
    
# Bitbucket Account
Host simpson
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/simpson
    IdentitiesOnly yes
    
# GitHub Account
Host donald
    HostName github.com
    User git
    IdentityFile ~/.ssh/donald
    IdentitiesOnly yes
```

### STEP 3: Create a Global Git Config

On you terminal enter following command and execute

```
git config --global url.git@acme:<GITHUB_USER_NAME>.insteadOf https://github.com/<GITHUB_USER_NAME>
```

Here, acme is the Host configuration from `~/.ssh/config` file.

Replace, <GITHUB_USER_NAME> with your Github username.

If done correctly, the file at location `~/.gitconfig` will be modified. The above configuration will added to the EOF.

### STEP 4: Now `go get` :blush:

```
go get github.com/<GITHUB_USER_NAME>/private-repo
```
Liftmaster 811LM teardown/programming instructions
Tags: b0071eyrgg, 811lm
Published: 2022-06-23 07:13:18

# About

LiftMaster 811LM Encrypted DIP with Security+ 2.0 Technology Remote Control

ASIN: B0071EYRGG
FCC ID: HBW7471
IC: 2666A-7471


# Teardown

## Front

![Front of PCB](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rlyr9s0rcv1ysb9kovud.jpg)

## Back


![Back of PCB](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycjg7363ju5uiluea3ld.jpg)


# Programming Instructions

* Push blue button (`SW4`) to put into programming mode
* Verify that yellow LED (`SW5`) lights up
* Push black button (`SW2`) <x> amount of times to toggle through frequencies

| # of presses | Device Security Type |
| -----------  | -------------------- |
|     1        |  Security+ 2.0®      |
|     2        | 315 MHz DIP          |
|     3        | 390 MHz DIP          |


* Verify that gate receivers responds (either via LED or by actual gate opening)
* Push blue button again to exit programming mode
* Verify yellow LED turns off
Better way to try...except...pass in Python
Tags: python, exceptions, programming
Published: 2022-06-23 04:31:00

The typical '_try, exception, ignore_' pattern I see people using in python is this:

```python
try:
  # do something that might raise
except (MyError1, MyError2, etc) as err:
  pass
```

If you've ever found yourself doing something like that, I'm **not** here to tell you to _stop_, instead I'll show you a better way.

### Introducing [`contextlib.suppress`] (https://docs.python.org/3/library/contextlib.html#contextlib.suppress) builtin

Using `suppress`, we can transform the above syntax to this:
**_requires python 3.4+_**
```py
from contextlib import suppress
with suppress(MyError1, MyError2, etc):
  # do something that might raise
```

And there we have it, from 4 lines to a nicely condensed 2 lines.

#### Advantages
What do you gain from this? Shorter, concise code which makes clear the intentions of the user to ignore the exceptions.

#### Disadvantages
The exception will never be visible outside of the context, therefore if you are being a good log keeper and in the habit of using `logger.exception("I tried to do something")`, the exception will not be shown by the logger.


### Conclusion
If you are already using this pattern, then I'm assuming you know what you're doing. The disadvantage mentioned might be a blocker for some. Consult your nearest python guru if you experience any adverse effects.
Digital Literacy
Published: 2022-06-23 07:08:41

Digital literacy is the ability to navigate our digital world using reading, writing, technical skills, and critical thinking. It's using technology—like a smartphone, PC, e-reader, and more—to find, evaluate, and communicate information.

What are some examples of digital literacy?
Examples of Digital Literacy skills:
Using your phone to check emails.
Using an online search engine to find the answer to a question.
Using online search to complete a research project.
Creating an online profile on a social media platform.

Competencies for digital literacy can be classified according to three main principles: Use, Understand and Create. You can find additional information in this field below:

Digital Literacy Resources to Bookmark:
DigitalLiteracy.gov open_in_new. ...
Classroom Aid open_in_new. ...
The Futurelab open_in_new. ...
Creative Commons open_in_new. ...
Plagiarism Checker open_in_new. ...
EasyBib open_in_new. ...
Microsoft's Digital Literacy Curriculum open_in_new. ...
Twitter: #DigitalLiteracy open_in_new.
Why Estimates Are Waste
Tags: discuss, programming, productivity, management
Published: 2022-06-23 06:58:27

Software development is unpredictable but people waste hours every week trying to guess how long tasks will take.


![No Estimates](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5f47d6gg56fexci0462x.png)

Estimation can provide confidence in future changes, but this doesn’t apply to software development because:

*   If you can predict work then you should automate it instead of repeating it.
*   If you can’t predict work then attempting to do so is a waste of time.

## Automation Instead of Accurate Estimation

**Repetition increases predictability.** It isn’t possible to accurately estimate how long a task will take if you have never done it. In other words, the more you repeat a task the more predictable it becomes.


![Predictability ≈ Repetitions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uglko2e9wduw2l9mmn9y.png)

**Repeated work should be automated.** In software development the ability to re-use libraries, frameworks, and APIs means that repeatable work can be automated. The more you repeat it the more effort would be saved with code re-use and automation.


![Value of Automation ≈ Repetitions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ymirbvaboetzhia2u5zk.png)

**Accurate Estimates Correlate with Wasted Effort.** As repetitions increase the value of automating and the predictability both go up. Therefore …


![V ≈ R ≈ P](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvut6o8rmjs3f0qu8fn6.png)

## Inaccurate Estimation is Harmful

If the purpose of estimation is to plan around the future then inaccurate estimates can only lead to problems. This is compounded by the cost of estimating work in time and effort.

{% embed https://twitter.com/No_Estimates/status/1466892889439494147 %}

Instead of spending time and effort on estimating work that can’t be predicted or should be automated we should find alternatives. One of the most agile approaches is to work without estimates.

## Working Without Estimates

Working without estimates is critical to good software development and goes hand in hand with continuous delivery. The simplest process to work without estimates is:

1.  Identify the most valuable task.
2.  Work on that task.
3.  Repeat.

It is important to consider the time spent on estimating work and the value it provides. This minimal process may be too strict for you but next time you are estimating your work consider the value it provides.

If you would like to discuss this further please contact me on **Twitter** [@BenTorvo](https://twitter.com/BenTorvo) or **Email** [ben@torvo.com.au](http://torvo.com.au/)
Trùm Đất Nền
Published: 2022-06-23 06:57:32

Trumdatnen là website bất động sản chuyên chia sẻ thông tin, kinh nghiệm, pháp lý bất động sản về loại hình đất nền dự án, đất nền thổ cư.
Địa chỉ: 134 Thảo Điền - Quận 2 - Hồ Chí Minh
SĐT: 972817893
Email: trumdatnen101@gmail.com
Website: https://trumdatnen.com
#trumdatnen #muabannhadat #datnengiare #nhapholienke #batdongsan #phanlobannen
https://www.youtube.com/channel/UCzVj8XBRj8tp0Wo9WwziIeQ
https://www.pinterest.com/tienotee/_saved/
https://twitter.com/TienNgu67681423
https://www.linkedin.com/in/trumdatnen/
https://trumdatnen.wordpress.com/
https://www.facebook.com/Tr%C3%B9m-%C4%90%E1%BA%A5t-N%E1%BB%81n-101-108024031950438/?ref=pages_you_manage
https://trumdatnen.tumblr.com/
🗠 Waiting time in OPT-NC agencies... on Rapidapi.com
Tags: tutorial, api, docker, opensource
Published: 2022-06-23 06:32:38

## ❔ Context

Currently [OPT-NC](https://office.opt.nc/) is [publishing a website](https://www.opt.nc/service/l-opt-pres-de-chez-moi-trouver-une-agence) that makes it possible to find agencies and queue waiting time so our customers can optimize their time according to current load: 

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

## 📰 Publish on RapidAPI Marketplace

To enable innovation and [open-innovation](https://www.amazon.fr/Open-innovation-D%C3%A9veloppez-culture-collaborative/dp/2100705199), we have released this content as a public API on [RapidAPI marketplace](https://rapidapi.com/opt-nc-opt-nc-default/api/temps-attente-en-agence/details) so people can create new solutions on our services.

👉 This short post will guide you through our API, how to find it, how to interact with it thanks to an interactive and [dedicated tutorial on Killercoda](https://killercoda.com/opt-labs/course/opt-temps-attente-agences/basique).

## 🍿 Démo

{% youtube SpzF0sHSkes %}

## 🧪 Innovation

This API made it possible to create, learn & innovate a wide range of things & technologies. Stay tuned for more 🤗

## 🔖 Resources

- API on [RapidAPI marketplace](https://rapidapi.com/opt-nc-opt-nc-default/api/temps-attente-en-agence/)
- `optnc/opt-temps-attente-agences-api` Docker image [on DockerHub](https://hub.docker.com/r/optnc/opt-temps-attente-agences-api)
- [Killercoda tutorial](https://killercoda.com/opt-labs/course/opt-temps-attente-agences/basique)
UI Builder: Add a page-level success alert message
Tags: servicenow, ui, uibuilder
Published: 2022-06-23 06:27:32

If you want to add a success or any other notification, you can fire an event in a client script. The OOTB event you can fire is the 'NOW_UXF_PAGE#ADD_NOTIFICATIONS'.

To see what other configuration you can make to the alert message, you can use the component playground:
[Component Playground](https://developer.servicenow.com/dev.do#!/reference/now-experience/sandiego/now-components/now-alert/playground)

```javascript
    api.emit('NOW_UXF_PAGE#ADD_NOTIFICATIONS', {
        items: [{
            status: 'positive',
            icon: 'thumbs-up-outline',
            header: 'Success: ',
            content: 'Record was created',
            action: {
                type: 'dismiss'
            }
        }]
    });
```
Vendor lock-in sucks
Tags: watercooler
Published: 2022-06-23 06:18:08

I don't often do rants, but this problem grinds my gears. We all know Twitter can be a fantastic place to receive and share knowledge.

Recently Twitter acquired Revue. A Dutch startup focused on making newsletters easy for Twitter users.

And don't get me wrong, it's a pretty cool system.
...
That is, if you don't already have a newsletter.

And that last part is where I got a bit annoyed.
It happens a bit too often when new startups arrive, and they do one thing pretty good.
You might want to give them one finger, but they all want your whole arm.

## What's so wrong about that?

I've worked hard to set up my mailing list with some form of automation, custom layouts, and subscribe flows from different places.

I don't want to throw that away and move over to Revue, where I have to start with this stuff.

(And some things like custom layouts are not even possible at the moment)

## Don't use it then

This might be the Dutch person inside me, but why complain? Just don't use Revue, then.

And yes, that's what I'm doing now. However, I miss out on a unique way of getting newsletter subscribers.

If you are opt-in for Revue, you get a lot of cool new features on your Twitter profile that can enhance your existing newsletter.

![Newsletter subscribe widget on Twitter](https://cdn.hashnode.com/res/hashnode/image/upload/v1655098001996/QdcTd1hoY.png)

For example, the newsletter subscribe widget you see in the image above.
This super cool element could help get new subscribers more easily.

## So, what then?

First, I would have loved it if I could sync this widget with any other newsletter service.

That doesn't sound too complicated, yet it seems to be.

A second-best could be us simply building this ourselves, and that's exactly what I'll be doing.

Follow along if you want to join me on this journey of syncing Revue with [Sendy](https://daily-dev-tips.com/posts/moving-from-mailchimp-to-sendy/), my newsletter system.

I'm looking forward to hearing how you all feel about this vendor lock-in.

### 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)