teleren/devto huggingface dataset:
TCP and UDP did you ever use them directly?
Tags: discuss, javascript, programming, architecture
Published: 2021-01-18 09:09:16

---
title: TCP and UDP did you ever use them directly?
published: true
description: usually we use protocols that sit on top, such as http, grpc, various SDK. What do you do?
tags: 
  - discussion
  - javascript
  - programming
  - architecture
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/8ddrklktm6uo5obs2yzt.jpeg
---
Did you ever had a project where you used lower level protocols directly?

Usually we use `http(s)`, a lib like `grpc` or service `SDK`s such as for databases.

But did you ever build an app that use `tcp` or `udp` directly or define your own protocol on top of them?
ReadabilityJS - adding Reader View Mode to websites
Tags: a11y, javascript, firefox, readermode
Published: 2021-01-18 09:03:59


One of the features I absolutely love in Firefox is `Firefox Reader View`. This removes all the clutter and present the content in text format for better readability and relief for eyes(It also removes the ad banners 😉 ).

Not all the browsers (Chrome needs special flag to enable this 😐 ) have a readability mode thus, providing an option for reader mode within your website would be a huge help to your users and would make your webpage more accessible.  

The good news is you do not have to implement this on your own, Mozilla has a standalone version of the readability library used for Firefox Reader View - [**Readability.js**](https://github.com/mozilla/readability).  
The usage is pretty simple and straight forward:
1. We need to include the readability.js in our code in either of 2 ways:
    1. Download the file via https://github.com/mozilla/readability/releases
    2. Install npm package - https://www.npmjs.com/package/@mozilla/readability
2. Create a new `Readabilty` object from DOM document node
    ```JS
      const article = new Readability(document).parse();
    ```
    This article object will have following properties
    - `title`: article title
    - `content`: HTML string of processed article content
    - `textContent`: text content of the article (all HTML removed)
    - `length`: length of an article, in characters
    - `excerpt`: article description, or short excerpt from the content
    - `byline`: author metadata
    - `dir`: content direction (LTR or RTL)

    _Note_ Readability morphs the actual object so better to pass a clone node.
    ```JS
    const documentClone = document.cloneNode(true);
    const article = new Readability(documentClone).parse();
    ```
3. Substitute this `article.textContent` in the desired div and done 😎

See this in action here - https://itsopensource.com/demos/readability

**<center>HTML View</center>**

  ![HTML view](https://dev-to-uploads.s3.amazonaws.com/i/0dfbuo7cra43f1iaobd5.png)

**<center>Text View</center>**

  ![text view](https://dev-to-uploads.s3.amazonaws.com/i/5twfljccl5texasy6cbq.png)


Reference: https://github.com/mozilla/readability
Handle Large CSV files in PHP
Published: 2021-01-03 18:37:39

A big mistake when dealing with large files in PHP is attempting to open the file and load the entire file straight into memory or loop through all the lines and build up a buffer to loop through after. Example:

### Bad Example
```php
$rows= [];
$handle = fopen($filename, "r");
if ($handle) {
    while (!feof($handle)) {
        $rows[] = fgets($handle, 1000);
    }
    fclose($handle);
}

$count = 0;
foreach ($rows as $csv) {
 $count++;
 //skip header
 if ($count == 1) {
   continue;
 }
 $row = explode($csv, ',');
 // Do something
}

```

There's still a ton of bad tutorials and sites suggesting the above from old PHP versions. We can use either pure PHP or Laravel's LazyCollections to process very large datasets and not hit our memory limit.

### Processing a CSV with a while loop (PHP)

```php
$row = 0;
$import = fopen($filename, 'r');
while ($data = fgetcsv($import)) {
    $row++;
    //skip header row
    if ($row == 1) {
        continue;
    }

    // Process csv row 
}
```

### Processing a CSV with LazyCollection (Laravel)
```php
use Illuminate\Support\LazyCollection;

LazyCollection::make(function () use ($filename) {
    $file = fopen($filename, 'r');
    while ($data = fgetcsv($file)) {
        yield $data;
    }
})->skip(1)->each(function ($data) {
    // Process csv row
});
```

With both of the above code examples, we solved the memory limit issues. But, we're still going to run into a different problem eventually. When using pure PHP, I would just set that script's max execution time to unlimited `set_time_limit(0);` at the start of the file. In Laravel this processing should be moved into a queue
Using Configs in Laravel 8
Tags: laravel, php, tutorial
Published: 2021-01-18 08:48:03

One of the biggest things we do in modern web development is to consume API's and with that comes lots of keys, secrets, and config points. With that comes issues, now up until recently I would store the needed key etc in my .env and call it direct! Which worked and worked well. 

So let's say we have a support email that is used in many places, we store that in the .env file we call it. 

```json
MAIL_SUPPORT_ADDRESS: "support@grahammorbydev.com"
```

We grab that in blade or a controller as so 

```php
env('MAIL_SUPPORT_ADDRESS')
```

Which works just fine, but let's say you go into production, do not update your .env, and load the site? What will happen? That page will error that the address doesn't exist or the support email will not work. Now, this is a really basic use case for config, but I hope it will allow you to see the benefit.

So what we do is head over to the config folder and create a new file called contact.php. if we then add the following code

```php
<?PHP
return => [
     'email' => env('MAIL_SUPPORT_ADDRESS', 'help@grahammorbydev.com')
]
```

Then in my blade file or controller, I just use
```php
config('contact.email');
```

This allows me to use any value I set in my env or fallback should I forget and that's just the start. There are tons of other things you can do to allow you to write cleaner code and give you the edge in Laravel!
Configure Jupyter Global Imports
Tags: jupyter, config
Published: 2021-01-18 08:40:17

1. Open a terminal and go to the following directory 

    ```
        cd ~/.ipython/profile_default/startup
    ```
2. Now create a python file. You can name it anything you want:

    ```
        touch start.py
    ```
3. Now open the file you can do inside the terminal or open up your favorite IDE.
    ```
        nano start.py
    ```
    ![Screenshot 2021-01-18 at 09.32.07](https://dev-to-uploads.s3.amazonaws.com/i/jho1jk2bwsvmshw6aab7.png)
4. Place all the libraries that you want to get imported by default.
    ![Screenshot 2021-01-18 at 09.29.23](https://dev-to-uploads.s3.amazonaws.com/i/sk7qy8lfm8b7v6fukcto.png)
5. No press `CMD+X` and press `Y` to save.
6. If you have jupyter instance running you need to restart them.
7. To check if you successfully included those libraries you can check them in `globals()` in a notebook:
    ![Screenshot 2021-01-18 at 09.35.18](https://dev-to-uploads.s3.amazonaws.com/i/q929uf9i3aak4lduwaeu.png)
 
Ref: [How to Automatically Import Your Favorite Libraries into IPython or a Jupyter Notebook](https://towardsdatascience.com/how-to-automatically-import-your-favorite-libraries-into-ipython-or-a-jupyter-notebook-9c69d89aa343)
What is one of the most common mistakes beginner developers make
Tags: algorithms, programming, javascript, junior
Published: 2021-01-18 08:40:08

---
title: What is one of the most common mistakes beginner developers make
published: true
description: Why understanding data structures and algorithms helps to build robust applications. 
tags: algorithms, programming, javascript, junior
cover_image: https://dclrlzd4gl55u.cloudfront.net/481/hero2x?1554901487
---

It may seem that when you are a beginner, you'll do simple things only. No need to learn data structures and algorithms. No need to understand Big O notation, complexity and stuff like that. 

This couldn't be further away from the truth!

In 2008, when I just started learning to program, I spent a lot of time reading books on PHP and MySQL. Months later, when I felt confident, I took my first freelance project. It was a real estate website. A simple one. I used a custom-made ORM and everything worked just fine!

When I released it, the search feature quickly became sluggish and made the website unusable. 

I was wondering what the heck had happened. I figured out that database queries became very slow when there were over 200 real estate objects added to it. 

This is it. What worked fine during testing did not work in real life.

I was a self-taught developer. I did not know how to measure if my project scaled well. I didn't even know that I had to do it.

I thought algorithms mattered only for launching a spaceship.

If I had some basic understanding of algorithms, I would have known that the more the input, the longer it takes. 

I am not saying I would have come up with a robust solution as a junior, but I would have looked for a solution because I knew there would be a problem. 

Please, don't make the same mistake!

Of course, data structures and algorithms are much more than that and they apply differently depending on what you work on. 

But a basic understanding of data structures and algorithms is a must for every software developer. 

---

I am writing about my experience of what I wish I knew when I was a beginner and I review programming courses to find those that are worth learning. 

If you are a junior or a beginner and you want to know what you need to learn, I can help!

I am sharing my knowledge in a newsletter here https://ns.comparecourses.dev
How to send emails using python
Published: 2021-01-18 08:38:44

What are emails?
Emails are messages distributed by electronic means from one computer user to another. There can be many more recipient as well via network.

 Methods we can use to send an email:
1. We can use python web automation using selenium.
2. We have a python library which is SMTP library which can be used to send an email.
But for this article I shall be explaining how to use the STMP library.
STMP which means simple transfer mail protocol. STMP library, this library or the modules defines an SMTP clients session object which can be used to send an email to any other internet machine with an STMP or E-STMP listener daemon.
# Here's the full code

              :
              import smtplib
              server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
              server.login('example@gmail.com', 'password')
              server.sendmail('example@gmail.com', 
              'contact1@gmail.com', 'Hi happiness,how are you?')
              server.quit()

Quickly what you should note:
"example@gmail.com"-your email address should be there
"password"-the password to your email address
"contact1@gmail.com"-the receiver's email address.
then you go ahead with the body of the message.

So here's the output
![gmail ans.JPG](https://cdn.hashnode.com/res/hashnode/image/upload/v1610347510124/y6QB8bxJZ.jpeg)

Finally you have to enable your "less secure app" from your google account in order to send the message.
Сэнди Метц
Tags: ruby, refactoring, oop
Published: 2021-01-18 08:29:53

Все знают Фаулера и Мартина, а о Сэнди Метц слышали единицы. Это не круто: Сэнди очень хорошо понимает программирование и умеет ясно и доступно рассказывать про него.

Делюсь подборкой самых полезных ее видео и книг:

[Magic Tricks of Testing](https://www.youtube.com/watch?v=URSWYvyc42M)
Все, что нужно знать о модульном тестировании. Вообще все

[All the Little Things](https://www.youtube.com/watch?v=8bZh5LMaSmE)
Как видеть объекты за бесконечными ифами

[Nothing is Something](https://www.youtube.com/watch?v=OMPfEXIlTVE)
Как видеть объекты в пустоте

[Rules](https://www.youtube.com/watch?v=npOGOmkxuio)
Пять правил ООП

[Practical Object-Oriented Design in Ruby](https://www.amazon.com/gp/product/0321721330/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321721330&linkCode=as2&tag=sandimetzcom-20&linkId=d5bd799fb895b56032932fc813dca07d)
Все, что нужно знать про ООП, бизнес и управление зависимостями

[99 Bottles of OOP](https://sandimetz.dpdcart.com/)
Про Shameless Green, Good Enough и SOLID


P. S. Если вас держат в заложниках и можно выбрать только что-то одно, смотрите [Magic Tricks of Testing](https://www.youtube.com/watch?v=URSWYvyc42M).

P. P. S. Если видео смотреть нельзя (например, вы на работе в офисе), читайте [Practical Object-Oriented Design in Ruby](https://www.amazon.com/gp/product/0321721330/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0321721330&linkCode=as2&tag=sandimetzcom-20&linkId=d5bd799fb895b56032932fc813dca07d).
Java/ Split Contents in One Cell into Multiple Columns
Tags: java, excel, split
Published: 2021-01-18 08:13:34

When dealing with data in Excel documents, it may sometimes be necessary to split the information in one cell into mutiple columns so that each column can be processed separately in the next step. This article will introduce how to use Free Spire.XLS for Java (a 3rd party free API) to split the text or numbers in one Excel cell into multiple columns by delimiters. The delimiter characters could be Space, Comma, Semicolon, etc.

**Installation**
**Method 1:** Download the [free API](https://www.e-iceblue.com/Download/xls-for-java-free.html) and unzip it, then add the Spire.Xls.jar file to your project as dependency.

**Method 2:** You can also add the jar dependency to maven project by adding the following configurations to the pom.xml.
```xml
<repositories>
        <repository>
            <id>com.e-iceblue</id>
            <name>e-iceblue</name>
            <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
        </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.xls.free</artifactId>
        <version>3.9.1</version>
    </dependency>
</dependencies>
```

**Relevant Code Snippet**
```java
import com.spire.xls.*;

public class splitDataIntoMultipleColumns {
    public static void main(String[] args) {
        //Load the sample document from file
        Workbook workbook = new Workbook();
        workbook.loadFromFile("source data.xlsx");

        //Get the first worksheet.
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Split data into separate columns by the delimiter characters of space.
        String[] splitText = null;
        String text = null;
        for (int i = 1; i < sheet.getLastRow(); i++)
        {
            text = sheet.getRange().get(i + 1, 1).getText();
            splitText = text.split(" ");
            for (int j = 0; j < splitText.length; j++)
            {
                sheet.getRange().get(i + 1, 1 + j + 1).setText(splitText[j]);
            }
        }
        //Save to file
        workbook.saveToFile("SplitCell.xlsx", ExcelVersion.Version2013);
    }
}
```

**Result**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nsgposo8fh8pu0kcvjm9.jpg)
WhatsApp or Signal - Make an Informed Choice
Tags: privacy
Published: 2021-01-18 08:08:56

Signal has seen incredible adoption in recent days, mainly due to a change in the WhatsApp T & Cs that scares many people.
In this post, I am coming back on the purchase of WhatsApp by Facebook and the various scandals that have gradually eroded the love that people could have for a service like Facebook.

This loss of confidence is now leading to a massive exodus of the WhatsApp application.

But which application should we then look at?

I go through the possible choices and must-have features and tell you why Signal can be a great choice.

{% youtube tPj3jUQC4mw %}
<figure>
  <figcaption>Video with French Audio & English Subtitles</figcaption>
</figure>

---

*If you like this content, push the like button, that helps spread the message.* 👍🏼
*If you think it can be useful to anyone in your network, share it.* 📨

---

Video produced by [Wild & Secure](https://wildnsecure.com), your consulting firm to all things security and real estate.
If you want to receive weekly quality content about security, subscribe to our newsletter [on our website](https://wildnsecure.com/contact).
Understanding Docker: part 27 – Container
Tags: docker, devops, beginners, cloud
Published: 2021-01-18 08:02:58

---
title: Understanding Docker: part 27 – Container 
published: true
description: Serie of sketchnotes about Docker. Explaining in a visual way Docker principles.
tags: Docker, DevOps, beginners, Cloud
series: Understanding Docker in sketchnotes
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/oha5hsartxtbq60hz2qf.jpeg
---

Understanding Docker can be difficult or time-consuming. In order to spread knowledge about Cloud technologies I started to create sketchnotes about Docker. I think it could be a good way, more visual, to explain Docker (and other technologies like Kubernetes and Istio).

We continue the series of Docker sketchnotes with an explanation about container.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oha5hsartxtbq60hz2qf.jpeg)

If you want to know [how to run a container](https://dev.to/aurelievache/understanding-docker-part-3-run-a-container-44gp), please reet to the already draw sketchnote :-).

As usual, if you like theses sketchnotes, you can follow me, and tell me what do you think. I will publish others sketchs shortly :-).

If you are interested, I published all the sketchnotes on Docker (and new ones!) to make a "book" of 93 pages: ["Understanding Docker in a visual way"](https://gumroad.com/aurelievache#YTLzM).
TryHackMe's Advent of Cyber 11
Tags: security, tryhackme, student
Published: 2021-01-15 08:03:04

#Task 11: [Data Elf-iltration](https://docs.google.com/document/d/17vU134ZfKiiE-DgiynrO0MySo4_VCGCpw2YJV_Kp3Pk/edit)

This task was pretty fun for me. To start off we're given a pcap file and need to find some bits of information that's been exfiltrated from the server. 

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

The first question asks us to find information that's been exfiltrated by DNS. At first I didn't really know what I was looking for exactly and just clicked around on any of the 20-ish DNS packets in Wireshark and tried to look for information in the the many name:value pairs listed. After a while of this not getting anywhere, I re-read the supporting doc and did a little research to find [this: ](https://blogs.akamai.com/2017/09/introduction-to-dns-data-exfiltration.html)

[!alt Text](https://blogs.akamai.com/Data%20Exfiltration%20Blog%20Img1.png)

There's a lot of neat information in this blog post, but for our purposes all we need is the above image. Malware is able to send information (restricted to letters and digits) as a subdomain to an attacker's registered domain. I somehow missed this in the supporting doc because I didn't know what a subdomain was (it's the portion before the first period) and thought it was some field I could find in the DNS packets.

With this, I just went through every DNS packet in the pcap file and and eventually found packets 17 and 18 with a suspicious query to *43616e64792043616e652053657269616c204e756d6265722038343931.holidaythief.com*. Run the subdomain text through a hex decoder to get *Candy Cane Serial Number 8491*, the answer to our first question.

The next two questions are fairly straightforward. Exporting HTTP objects from Wireshark gives us two files: TryHackMe.jpg and christmaslists.zip. Using steghide, the hidden contents in the jpg file is written to christmasmonster.txt. Inside is a sort of poem: 
[![https://imgur.com/Rl4ieve.png](https://imgur.com/Rl4ieve.png)](https://imgur.com/Rl4ieve.png)

After a little bit of digging it turns out to be an **Request for Comments (RTF)**, which are usually used to describe *methods, behaviors, research, or innovations applicable to the working of the Internet and Internet-connected systems (Wikipedia)*. This particular one, RTF527 is an April Fool's play on the 1871 Jabberwocky poem from Lewis Caroll. RTF527 is also the answer to the third question.

Use fcrackzip on the zip file to get the password *december*. Use that to find this christmas list for timmy and the second answer: PenTester

Lots of cool information found in this one, learned about topics I never knew about and finished in not too bad of a timeframe. All in all not bad!

Learned: DNS Exfiltration, subdomains, steganography
🔴 Join YouTube LIVE Talk About Architecture and Code of DeckDeckGo: A Web open-source Editor for Slides
Tags: javascript, architecture, node, webrtc
Published: 2021-01-18 08:00:38

DeckDeckGo is A Web open-source Editor for Slides.

David Dal Busco is the Creator of DeckDeckGo.
He will talk about the Architecture and then a bit of things about code of all pieces.

DeckDeckGo is a Presentation/Slide App like Google Slides or MS Powerpoint.

The Talk will be streamed LIVE on YouTube Channel- <b>The Destro Dev Show</b>

You can Watch LIVE on YouTube https://www.youtube.com/watch?v=hsg7LLAQ1co

{% youtube hsg7LLAQ1co %}

👉 at 6:00PM 🇩🇪 (Central European Time) | 11:00 PM 🇧🇩 (BD Time) | 10:30 PM 🇮🇳 ( India Time) | 11:00 AM 🇺🇸 (Central Standard Time)

👉 on Wednesday 20th January, 2021

Enjoy 🌸

<h3>To get notifications, you can click the SET REMINDER Button on the Video !</h3>

Also SUBSCRIBE to YouTube Channel - https://www.youtube.com/c/TheDestroDevShow?sub_confirmation=1

LIKE FB Page - https://www.facebook.com/the.destro.dev.show/

Follow on Twitter - https://twitter.com/destro_mas

Follow on DEV - https://dev.to/destro_mas

Made with ❤️ in Berlin!

Cheers!
👋

<hr />
As I am trying to contribute contents on the Web, you can buy me a coffee for my hours spent on all of these ❤️😊🌸

<a href="https://www.buymeacoffee.com/destrodevshow" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 45px !important;width: 117px !important;" ></a>
What is the nightmare for programmers?
Tags: discuss, watercooler, beginners, codenewbie
Published: 2021-01-18 07:57:19

# Introduction
The struggle of being a programmer is understood by none other than another programmer. We came across a lot of problems all day long and we have to overcome each and every obstacle.

![NightMare](https://dev-to-uploads.s3.amazonaws.com/i/pxqyxfkzuwkf6rfodmvc.gif)

So today, I would love us to share things that a coder/programmer hates to encounter?

## My thoughts
As a coder/programer I hate following things to encounter 
- No Network🌐
- Stuck on one problem that takes a lot of time to get solve😨
- Can't execute the program that I found on the web▶️

# Discuss
- What you hate most as a Programmer?
- Nightmare for you as a Programmer?