teleren/devto huggingface dataset:
Beep Boop 2: Use Machine Learning Models to Prep Your Data
Tags: beginners, codenewbie, programming, tutorial
Published: 2021-08-13 22:21:59

--- 
title: Beep Boop 2: Use Machine Learning Models to Prep Your Data
description: In part 2 of this series, we use data from real and animated basketball players from the film Space Jam: A New Legacy, to create a machine learning model to clean up some data and see who should start in the next game. 
tags: beginners, codenewbie, programming, tutorial
series: "Beep Boop"
published: true
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7oo3cvjq2y4f8rdu5hp9.png
---

Thanks to everyone who joined us live for the 2nd episode of [Beep Boop with the Microsoft Reactor](aka.ms/BeepBooptube)- we had a lovely time getting right back into our [Microsoft Learn module](aka.ms/beepbooplinks2) and creating a machine learning model to clean up our data! 👩‍💻👩🏽‍💻



If you missed the fun live, don't worry- you can watch the replay [here on YouTube](aka.ms/beepboop2), and in the embedded video below!



{% youtube 9KTcGYJ1Npg %}



**On this episode we cover:**



- [7:36](https://youtu.be/9KTcGYJ1Npg?t=446) [Ornella](https://twitter.com/ornelladotcom) and [Chloe](https://twitter.com/ChloeCondon) recap what we do on Beep Boop and the ~vibes~ we want to cultivate on the show! 🤖💕


- [11:24](https://youtu.be/9KTcGYJ1Npg?t=684) Previously on Beep Boop... we catch folks up on what we did last time, and revisit how to [set up your local environment for data science coding](https://aka.ms/beepboop2links2) and [download VS Code](aka.ms/beepboopvscode) so we can pick up where we left off! ☁️🏀

- [16:56](https://youtu.be/9KTcGYJ1Npg?t=1016) Frank pops in to tell us what he thinks about AI and ML 🐶🦴


- [18:21](https://youtu.be/9KTcGYJ1Npg?t=1101) We [discover data that represents more than one population](https://aka.ms/beepboop2links3) and talk about why that might be useful for other scenarios 🕵️‍♀️👥

- [34:49](https://youtu.be/9KTcGYJ1Npg?t=2084) We [manipulate the data](https://aka.ms/beepboop2links4) so we can easily distinguish between Tune Squad players 🐰🐥 and real NBA players ⛹️‍♂️

- [39:38](https://youtu.be/9KTcGYJ1Npg?t=2378) Magically [impute (add in) data to our DataFrame](https://aka.ms/beepboop2links5), and get closer to a PERfect set of data 🤓

- [47:27](https://youtu.be/9KTcGYJ1Npg?t=2847) [Using Machine Learning techniques](https://aka.ms/beepboop2links6) like linear regression and cross-validation to finally complete our dataset - no more NaNs! 😎

*Did you have fun? Check out [Beep Boop 3: Create a Web App with Data and ML](aka.ms/beepboop3) where we take our data on an adventure - see ya then, friends!*
How to return the list of Timezone available in Python?
Tags: python, 100daysofcode, codenewbie
Published: 2021-08-13 21:49:56

Will this one is easy you just have to use the DateTime package which is available in Python. You have to import the Timezones function from the Datetime Package in Python by using the import statement and after then you have to call the Function just like Below.
```python
from DateTime import Timezones

timezones = set(Timezones())
print(timezones)

for zone in timezones:
    print(zone)
```
Read out the complete article of how to use the [DateTime Python Package](https://www.alixaprodev.com/2021/08/how-to-use-datetime-package-in-python.html).
Improve your callbacks by making their return meaningful
Tags: react, javascript, tutorial, webdev
Published: 2021-08-13 21:44:21

When dealing with the more interractive elements of React like inputs or buttons, you will often come across the need of passing around callbacks like this:

```jsx
const MyInput = (props) => {
  return(
    <input
    type="text"
    value={props.value}
    onChange={props.onChange}
    />
  );
}
```

And focusing on the `onChange` part of the snippet, it will call the callback with the values and that's about it, ignoring if it returns anything.

But with a need for making it easier to make stuff happen when pressing enter, I came up with the following snippet:

```jsx
const MyInput = (props) => {
  return(
    <input
    type="text"
    value={props.value}
    onChange={props.onChange}
    onKeyDown={(e) => {
      if (e.key === 'Enter') {
        props.onEnter()
      }
    }}
    />
  );
}
```

usually with the idea that I should make it blur sometimes when I press enter. And then I had the idea that `props.onEnter()` should return if it will stay focused or not, leading to the following idea:

```jsx
const MyInput = (props) => {
  const inputRef = useRef(null);
  return(
    <input
    type="text"
    ref={inputRef}
    value={props.value}
    onChange={props.onChange}
    onKeyDown={(e) => {
      if (e.key === 'Enter') {
        const keepFocus = props.onEnter();
        keepFocus || inputRef.current.blur();
      }
    }}
    />
  );
}
```

This way, whenever I need to use my custom `MyInput` component, I can write an elegant `onEnter` callback like this:

```jsx
<MyInput
value={value}
onChange={setValue}
onEnter={() => {
  if (value === '') {
    return false;
  } else {
    process(value);
    setValue('');
    return true;
  }
}}
/>
```

so that if the user presses enter when there is something in the input field, it will process it and clear it, keeping focus on it. But if it is empty, it will simply blur the input field.

A similar pattern can be found in React's [`useEffect` hook][1], it's basic idea is that you just pass in a callback for what it should execute after each render, but if you need it to clean up, you make the callback return a cleanup function.

So the next time you make a component take a callback, consider if you can give your code more functionality by working with what it returns.

[1]: https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
Serverless Architect Filip Pyrek in podcast on current challenges in Serverless space
Tags: aws, podcast, serverless, awscommunity
Published: 2021-08-13 21:44:20

> On this episode of the Talking Serverless Podcast Ryan Jones is joined by Filip Pyrek, an AWS Community builder and Serverless Architect. Described as “one of the youngest people to know the most about serverless in Europe” Filip began working for Purple Technology at only 18. Purple Technology specializes in developing software for FinTech companies; an emerging industry that leverages technology to make financial services more accessible. Their journey with Serverless started in the fall of 2017 with only 4 developers and since then have grown to 25+ with all their newly built software being Serverless.

{% youtube 8mq1zY8hIoQ %}

Episode available also on:

- [TalkingServerless.io](https://www.talkingserverless.io/episodes/ep-41%3A-filip-pyrek-serverless-architect-at-purple-technology)
- [Apple Podcasts](https://podcasts.apple.com/us/podcast/41-filip-pryrek-serverless-architect-at-purple-technology/id1479593355?i=1000531840495)
- [Spotify](https://open.spotify.com/episode/5hryzU1PrHiiKLOmgKyiqn?si=OcAOXc6vTUqenYhqHk3HEw&dl_branch=1)
- [RadioPublic](https://radiopublic.com/talking-serverless-85DL2x/s1!6a7f1)
Experience in an intership
Tags: computerscience, sideprojects, javascript, typescript
Published: 2021-08-13 21:17:34

Finally, after a couple of months working with React.js and Typescript I'm able to describe as an computer science student what I learned as a front-end developer.

## Preparation, curriculum and interview

I was working with a small project with a professor in my university, and learned the basics of React.js with a small pre-made assets. Also I got quite some experience with Git, the visual interface of [Github](https://github.com/) and using [Git Bash](https://git-scm.com/download/win) as main sources of practise it was pretty useful.

The curriculum was created with my main skills (Javacript, React.js and others), prior experiences (including participation and organization in university events) and Github page. The curriculum was created with [Overleaf](https://pt.overleaf.com/), a LaTeX editor.

Finally the interview, since it was a small business, mostly was a short talk about interests, motivation as a candidate and previous projects and got the intership.

## What I learned?



- Found good and bad practises of coding (thanks to [Clean Code: A Handbook of Agile Software Craftsmanship](https://www.amazon.com.br/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882))
- Think and participate as a team (also thanks to [Accelerate](https://www.amazon.com.br/Accelerate-Software-Performing-Technology-Organizations/dp/1942788339))
- Undestand the value of automated end-to-end tests ([Cypress](https://docs.cypress.io/))
- Improve networking by participating and talking to friends and colleages
- Found more communities to learn more about the code you're working with (Twitter, Reddit, Stack Overflow, Dev.to, Medium)
- Use more task managers such as Trello and Jira
- Have fun learning unexpected methods to solve issues with Code Challenges ([CodeWars](https://www.codewars.com/)  and using external tools as [Replit](https://replit.com/)



But also, working with home-office there's time-management because of university and household tasks. But now, what to improve? Probaly, a lot.  But I believe the main goal is to participate and make the community richer and talk about what you learnded and how to improve with others.

Maybe your experience with your first intership was very much diffent from mine? How it was? Tell more in the comments.
Set timezone in your docker image
Tags: docker
Published: 2021-08-13 21:41:50

## TL;DR

```bash
RUN apt update && apt install tzdata -y
ENV TZ="America/New_York"
```

## Debian 

When your image is based on Debian, or your image's root is based on Debian, you can use `ENV TZ` in `Dockerfile`:

```dockerfile
FROM debian:10

ENV TZ="America/New_York"
```

## Ubuntu
When your image/root-image is based on Ubuntu, use:

```bash
RUN apt-get update && \
    apt-get install -yq tzdata && \
    ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata
```

If you don't know what your base image is, you could try putting both:
```bash
RUN apt-get update && \
    apt-get install -yq tzdata && \
    ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata

ENV TZ="America/New_York"
```

Also quote from and credits to @peter279k [in the comment below](https://dev.to/peter279k/comment/1h7dp):
> If using the ENV to set TZ to set the timezone, it should have the tzdata package installed on Linux distribution Docker base image.
> After investigating some common Linux distributions, the `Debian` and `CentOS` have the `tzdata` installed on their Base Docker images.
> And Ubuntu doesn't have the tzdata package on the Docker base image.

So another solution is:
```bash
RUN apt update && apt install tzdata -y
ENV TZ="America/New_York"
```
Dutiap! - Do you think I am pretty?
Published: 2021-08-13 21:37:05

In Dutiap you can objectively rate your photos and meet new people based on your preferences!
Is it hard to choose the best photo from your huge gallery?
Just upload a few shots to Dutiap and get an objective rating from 1 to 10 for each of your photos and your profile in general.
Rate photos of other users!
The number of rated profiles is equal to the number of ratings for your photos. The more you rate, the more objectively your profile will be rated.
Also, our algorithm remembers your preferences and every day recommends 10 users just for you. If you have a match, you can start chatting immediately!
Our app has no ads and it's absolutely free!
Dutiap!
Do you think I am pretty?
August 09 - August 16 Weekly Status
Published: 2021-08-13 20:00:20

This week I finished analysis of the new metric based on color histograms. It can be read [here](https://dev.to/aleksandrgushchin/august-02-august-03-weekly-status-565a).

I experimented with combining this new metric with the current one. Here are the F scores on BBC Planet Earth dataset for different versions:
 * Current rav1e version: 
  * 0.7024
 * Improved threshold (version of my latest pr): 
  * 0.8081
 * Version with color histogram based metric: 
  * 0.8502
 * Union of the latest two versions (frame is considered to be a scene change if one of the above-mentioned metrics said so): 
  * 0.8923
 * Version with color histogram metric with block-based approach, when each frame is divided into blocks (more details on the bottom): 
  * 0.9217

When I say the intersection of algorithms, I mean an algorithm that marks the frame as scene change only if both algorithms have marked it. 
Here is the picture that explains why I chose union rather than an intersection. It should also be taken into account that the recall of the algorithms is higher than accuracy:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tehmqzl1u3lnfnpt7cih.png)
Numbers represent the amount of frames considered as scene changes in two versions of the algorithm and ground truth. 
Each number represents one color area.
It can be seen that ground truth contains around 90% of the intersection of these versions. 

I improved histogram-based metric by dividing frames into blocks. The results for it can be seen below along with the regular histogram-based approach. The improved version is marked in the legend as _"with blocks"_
Results on BBC dataset:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7bc3kldc06bc7f4garh.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esey2w2bo3y1brmlf5ip.png)
Results on open-source videos:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9en1owgh6oyono62926.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vz2s2usqwwnm8l5kb354.png)

**But** the calculation speed became **0.75x** of the current version on the BBC dataset (resolution 360x288) and **0.56x** on open-source videos (resolution 1280x720). 

I check if it worth it to combine this metric with the current one. The average increase in the F score is about 0.01-0.02, which, considering the even greater decrease in the speed rate, is unreasonable.

Also, I implemented block-based histogram approach considering the motion vectors. The results will be published here soon.
.NET: Call Func delegates from Dictionary objects
Published: 2021-08-13 19:46:39

How about store Func delegates in a Dictionary object and invoke them when you really need them?

This approach can help us to avoid having nested conditional in our code and keep its cyclomatic complexity lower.

> **“Cyclomatic complexity** is a software metric used to determine the complexity of a program”. [Click here](https://en.wikipedia.org/wiki/Cyclomatic_complexity) to know more about that.

For example, suppose we want to create a method that returns a result from a math operation between two numbers. Its result will depend on the operation type that the user will provide to us: addition, subtraction, multiplication, and division.

A simple way to solve that is by creating a method that accepts three parameters: a number that will apply some operation and the operation type. Like this:

{% gist https://gist.github.com/luis-alexandre/b586abdd06f13e376028a3261158af6a %}

As you can see, we need to add four conditions to this method. From that, we have the cyclomatic complexity metric below:

![nested conditions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjobyb50qd75p0o5thuf.png)

Now check the same method with a Dictionary type that stores Func delegates:

{% gist https://gist.github.com/luis-alexandre/b586abdd06f13e376028a3261158af6a %}

In this case, we don’t need a lot of “if” statements in our code and it’s getting easier to read. Also as you can see in the picture below our cyclomatic complexity is lower than in the first approach:

![without nested conditions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vymza7ju6jzfakrunxr.png)

Of course, this sample is so simple. Now, try to think how easier can be our life in complex scenarios where we need to support code with higher cyclomatic complexity.

**[How about buying me a coffee? :D](https://www.buymeacoffee.com/techwithluis)**

![buy me a coffe?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocojbj7yf8l59aibats8.png)
Electron Adventures: Episode 20: IPC Benchmark
Tags: electron, javascript
Published: 2021-08-13 18:19:20

How fast is IPC communication between Electron frontend and backend? Let's do a quick benchmark.

### Backend

The backend will simply have one channel `increment`, that return number passed plus one:

```javascript
let { app, BrowserWindow, ipcMain } = require("electron")

ipcMain.handle("increment", (event, x) => (x+1))

function createWindow() {
  let win = new BrowserWindow({
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false,
    }
  })
  win.loadFile("index.html")
}

app.on("ready", createWindow)

app.on("window-all-closed", () => {
  app.quit()
})
```

### Benchmark

The `index.html` is just a placeholder for the results, so let's skip that. Here's the benchmark `app.js`:

```javascript
let { ipcRenderer } = require("electron")

let localIncrement = (x) => (x+1)

let benchmarkLocal = async () => {
  let startTime = new Date()
  let x = 0;
  while (x < 100_000_000) {
    x = localIncrement(x)
  }
  let endTime = new Date()
  return endTime - startTime
}

let benchmarkIPC = async () => {
  let startTime = new Date()
  let x = 0;
  while (x < 10_000) {
    x = await ipcRenderer.invoke("increment", x)
  }
  let endTime = new Date()
  return endTime - startTime
}

let runBenchmark = async () => {
  let results = document.querySelector("#results")
  results.textContent = `
    10k IPC calls took: ${await benchmarkIPC()}ms
    100M local calls took: ${await benchmarkLocal()}ms
  `
}

runBenchmark()
```

### Results

And here are benchmark results:

![Episode 20 Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trb1q35qu8vpthilfxom.png)

As you can see, calling another process is much slower than calling local functions. For trivial function, it took 1.7ns to do a local call, and 80000ns to do an IPC call. So you definitely should consider which code goes into which process, and if you can achieve the same result with fewer round trips.

On the other hand, IPC was still very fast! If your UI has 60 frames per second, you have 16ms per frame, so 0.08ms latency per IPC call is plenty fast.

By comparison HTTP calls over the internet are something like 100ms, and even localhost http server would likely be >1ms.

This isn't meant as any "serious" benchmark, but it should give you some ballpark figures what kind of latencies to expect from different modes.

As usual, [all the code for the episode is here](https://github.com/taw/electron-adventures/tree/master/episode-20-ipc-benchmark).
Quick Touch Events
Tags: touchevents, javascript, mobile, desktop
Published: 2021-08-13 19:31:14

{% codepen https://codepen.io/ZevanRosser/pen/JjNzVKO 
 default-tab=js,result %}

Draw with your mouse by clicking, holding down and dragging…

I often use some variation of this depending on the project… This snippet normalizes touch events in a simple way, prevents scrolling and gives an example of how to handle multi-touch.

You’ll probably want a to use a meta tag like this – for the full effect.

```html
<meta name="viewport" content="width=device-width, initial-scale=1.0">
```

_See more stuff like this over @ [Snippet Zone](https://snippet.zone/)_
how to identify the traces of the tor browser during the investigation?
Tags: cybersecurity, computerscience, linux
Published: 2021-08-13 19:16:38

Tor browser is one of the topics that excite every cybersecurity enthusiast. Tor was made for only one purpose, i.e., to make the user anonymous on the internet. It is used to access the Dark web, the deepest entity of the known Internet. Let's understand the working of Tor before investigating it. Tor browsers is based on Mozilla Firefox and work on relays. These are routers or nodes through which the traffic passes. These relays are divided into three levels:

1. Entry Relay: When establishing a Tor network, the user connects to the entry node, from which the user's IP address can be seen.

2. Middle Relay: Here, the data is transferred in an encrypted mode.

3. Exit Relay:  data is sent to the destination servers through this node. Thus, the exit node is seen as the origin of the traffic, hiding the original identity of the user.

The working and routing technique is known as onion routing. Tor browser provides access to .onion websites available on the dark web. Tor’s hidden service protocol allows users to host websites anonymously with. Users on the Tor network can only access BIT domains and these websites.

Although the Tor browser provides anonymity to its users, artifacts pertaining to the activities performed on it reside on the system RAM as long as the system is not powered off. Investigators can acquire a RAM dump of the live suspect machine to identify and analyze the artifacts pertaining to malicious use of the Tor browser. To investigate cybercrimes perpetrated using the Tor browser, forensic investigators should collect RAM dumps from the suspect machine and study them to determine the malicious activities performed using the Tor browser, including websites visited, emails accessed, and programs downloaded. 

When the Tor browser is installed on a Windows machine, it uses port 9150/9151 for establishing connections via Tor nodes. Forensic investigators can obtain the path from where the TOR browser is executed in the following Registry key: HKEY_USERS\<SID>\SOFTWARE\Mozilla\Firefox\Launcher. The investigator analyzes the ‘State’ file located in the path where the Tor browser was executed on a suspect machine. 

When the Tor browser is uninstalled from a machine, or if it is installed in a location other than the desktop (in Windows), it is difficult for investigators to know whether it was used or the location where it is installed, examining the prefetch files helps the investigators in obtaining this information. The prefetch files are located in the directory, C:\WINDOWS\Prefetch on a Windows machine. Using tools such as WinPrefetchView, investigators can obtain metadata related to the browser, which includes:

1. Browser created timestamps
2. Browser last run timestamps
3. Number of times the browser was executed
4. Tor browser execution directory
5. Filename

Linkedin: https://linkedin.com/company/cyber-junk
Discord: https://discord.gg/ZmCmkw2enz