teleren/devto huggingface dataset:
How to stop a java program gracefully?
Tags: java, thead, shutdownhook
Published: 2021-07-03 07:35:22

---
title: How to stop a java program gracefully?
published: true
date: 2021-06-14 04:04:10 UTC
tags: java, thead, shutdownhook
canonical_url: http://bazlur.com/2021/06/how-to-stop-a-java-program-gracefully/
---

Sometimes you may want to stop your java program using SIGINT hitting your `CTRL+C`. For example, your program may be doing something important, e.g., opening a server socket and waiting on a port or doing some background work on a thread pool. You want to stop it gracefully shutting down your socket or the thread pool. For such scenarios, what you can do is, add a shutdown hook to the java runtime. The following code demonstrates precisely that.

![100DaysOfProgramming_Day008](http://bazlur.com/img/Day008.png "100DaysOfJava")

for **copy/paste** pleasure: [https://github.com/rokon12/100DaysOfJava/blob/main/src/main/java/com/bazlur/Day008.java](https://github.com/rokon12/100DaysOfJava/blob/main/src/main/java/com/bazlur/Day008.java)
Live Unit Testing in Visual Studio
Tags: visualstudio, testing, unittesting
Published: 2021-06-14 04:55:47

---
title: Live Unit Testing in Visual Studio
published: true
date: 2021-06-14 04:04:08 UTC
tags: visualstudio,Testing,unittesting
canonical_url: https://blog.toddmeinershagen.com/live-unit-testing-in-visual-studio-ckpw3dyox0d8s0ms1d5pigyez
---

I am a big proponent of unit testing my code because of the many benefits it provides:

- Helps me to reduce bugs by forcing me to clarify expectations for various success and failure scenarios
- Provides a safety net for future code changes
- Leaves a documentation trail for those that come behind me to understand my code

The only irritation/friction I have found in the past is the fact that running unit tests has required me to manually run them on a periodic basis. Having keyboard shortcuts has helped to make that fairly painless, but it would have been nice to have the tests automatically run as I am working on the code. That way I am continually receiving feedback and don't have to explicitly do anything to receive it.

While there have been custom add-on options in the past ([SpecWatchr](https://www.nuget.org/packages/specwatchr/) and [nCrunch](http://www.ncrunch.net/)), Microsoft has added this functionality into the Enterprise version of Visual Studio.

Find out more about it [here](https://docs.microsoft.com/en-us/visualstudio/test/live-unit-testing?view=vs-2019).

![Live Unit Test Screenshot](https://docs.microsoft.com/en-us/visualstudio/test/media/lut-codewindow.png?view=vs-2019)
Want to learn JavaScript ? Here's a Detailed Roadmap for you
Tags: javascript, webdev
Published: 2021-06-14 03:49:02

A Detailed Roadmap for you👇
- Start with https://freecodecamp.org's - JavaScript Algorithms and Data Structures Certification and finish the "Basic JavaScript" module.

 You'll get a basic understanding of JavaScript and Programming in 
 general.
 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rtitqksn0i3ugh5i74uk.jpg)

- Move to http://JavaScript.info and complete the following parts:
 - An Introduction
 - JavaScript Fundamentals
You'll start to understand Basic JavaScript concepts and their details.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mx7a23pxfqyhma3p3otp.jpg)

- Complete "Objects: the basics" section in http://JavaScript.info

By this point you'll have a decent understanding of JavaScript Objects

- Time to return to freeCodeCamp. Finish the following sections:
 - Debugging
 - Basic Data Structure
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bumbczo7yq1241bpkuqn.jpg)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bumbczo7yq1241bpkuqn.jpg)

- Complete "Data types" Section in http://JavaScript.info

Congratulations!🎉🎉🎉
Now you have a great understanding of JS

- Time to move back to freeCodeCamp. Complete the following sections in order:
 - ES6
 - Object Oriented Programming
 - Functional Programming

- Finish Part 1 of http://JavaScript.info

- Finish freeCodeCamp's JavaScript Algorithms and Data Structures Certification

- Now you'll have to learn something called DOM. For that you'll need a basic understanding of HTML and CSS.

For learning DOM, I would recommend the following two resources:
 - Part 2 of http://JavaScript.info
 - MDN https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model

- Practice by making small projects from http://JavaScript30.com

Congratulations! You know JS🔥💯
My Learning Methods (applicable on mostly every technical skill)
Tags: webdev, programming, productivity
Published: 2021-06-14 03:21:46

I had started a #21DaysOfJavaScript challenge where I learnt JavaScript for 21 days. This was to build the habit of coding for a lifetime and have a fixed routine where I have time-blocked a few hours for my learning. Here is a list of the five most useful things which helped in my journey:

### 1. Accountability

The first reason and the most important one is accountability. I informed publicly through the social media platforms and so by committing myself out in public I'm making sure I stick to my goals. Also psychologically we are prone to achieve something if it's announced and seen by people. I might not procrastinate much as I used to and start getting things done.

### 2. Pseudo Teaching

The other reason I did this is was because I would have been learning the fundamentals of JavaScript but also I would also be teaching my own self. I had gone through a ton of resources and curated (much of it is curated online I'm just choosing) many lessons and topics that I'll be learning.

### 3. Time Management

I had alloted my whole morning to this challenge where I revised, learnt new concepts, and hard-coded them into projects.

### 4. Note-Taking

I usually do not like to take notes, thinking that I might remember it in the long term. I don't. Hence I also created a summary of all the concepts I've learned for that day.

### 5. Documentation

This is new and quite effective to me. I document my process of learning and iterated and always tried to make it better. Documenting will also help me later on with different opportunities and grow my social profile. Highly recommended.

These are some of the reasons I had  come up with to take this step. It was quite new and exciting for me since I was experimenting but it turned out really good.
.Net Decompiler
Tags: dotnet, ptbr, braziliandevs, csharp
Published: 2021-06-14 03:15:36



Olá Devs! 👩‍💻👨‍💻

Perder um fonte não é uma preocupação que você deveria ter nos dias de hoje. Temos várias ferramentas que podem auxiliar no processo de armazenagem e versionamento de código, mesmo assim sabemos que isso pode acontecer. Caso aconteça, existe uma opção que pode ser útil. Estou falando dos "Decompilers". A ideia é simples, pegar o binário e gerar o código fonte através dele.

Pode ser utilizado também como uma forma rápida de consultar o código, sem a necessidade de pegar um fonte completo no repositório, é uma opção.

Para .Net existem opções interessantes e é importante conhecer alguma.

Vou listar 3:
🎯 JustDecompile --- http://www.telerik.com/products/decompiler.aspx

🎯 dotPeek --- http://www.jetbrains.com/decompiler

🎯 ILSpy --- http://ilspy.net

Nos comentário recebi uma sugestão do [Damjan Cvetko] (https://dev.to/zobo) sobre uma ferramenta interessante também

🎯 dnSpy --- .NET debugger and assembly editor - https://github.com/dnSpy/dnSpy
 
Então meu código está disponível para qualquer um mesmo compilado? Em teoria sim, mas você pode obfuscar caso ache interessante. Com essa técnica você vai dificultar um pouco a vida de um decompiler.

O processo de obfuscação protege um pouco mais o binário, mas possui algumas possíveis desvantagens preocupantes: Perda de performance, impossibilidade de uso de reflection e serialization.

Como tudo nessa vida, tem o lado bom e o lado ruim. Pense bem antes de adotar.


https://docs.microsoft.com/pt-br/visualstudio/ide/dotfuscator/?view=vs-2019


Até a próxima! 👊
Code Smell 79 - TheResult
Tags: webdev, programming, oop, tutorial
Published: 2021-06-14 03:11:40

*If a name is already used, we can always prefix it with 'the'.*

> TL;DR: don't prefix your variables.

# Problems

- Readability

- Meaningless names

# Solutions

1. Use intention revealing names.

2. Avoid *Indistinct noise words*.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/eba3cf3c61494bd4e6a087776bfc5484)
```javascript
var result;

result = getSomeResult();

var theResult;

theResult = getSomeResult();
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/35dba1f621ebe19431e5fbe693546c9a)
```javascript
var averageSalary;

averageSalary = calculateAverageSalary();

//..

var averageSalaryWithRaises;

averageSalaryWithRaises = calculateAverageSalary();
```

# Detection

As with many of our naming conventions, we can instruct our linters to forbid names like *theXxx...*.

# Tags

- Readability

# Conclusion

Always use intention revealing names. 

If your names collide use local names, extract your methods and avoid 'the' prefixes.

# Relations

{% post https://dev.to/mcsee/code-smell-38-abstract-names-34ng %}

# More info

- [What is in a name](https://dev.to/mcsee/what-exactly-is-a-name-part-ii-rehab-20gd).

- [How To Be Great At Giving Meaningful Names](https://medium.com/shipmnts/how-to-be-great-at-giving-meaningful-names-54b19de66cdf).

# Credits

Photo by <a href="https://unsplash.com/@josuemichelphotography">Josue Michel</a> on <a href="https://unsplash.com/s/photos/chosen-one">Unsplash</a>  

* * *

> One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king. Professionals use their powers for good and write code that others can understand.

_Robert C. Martin_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Rust - Tipe Data Compound
Tags: rust, programming, beginners, codenewbie
Published: 2021-06-14 02:33:26

## Compound Types


> Semua materi merupakan rangkuman belajar.
>
> Untuk bacaan yang lebih langkap & update, dipersilahkan akses pada
> [The Book](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html#compound-types)


Seperti disebutkan sebelumnya, _Compound Types_ merupakan kelompok dari beberapa nilai. 

Dibagi menjadi 2:
1. Tuple
    - dapat menampung beberapa tipe data yang berbeda 
2. Array
    - hanya dapat menampung tipe data sejenis

Persamaan dari 2 jenis _Compound_ di atas adalah 
__sama-sama memiliki panjang yang pasti (tidak dapat dirubah)__


Oke, langsung contoh

### Tuple

```rust
fn main() {
  // Deklarasi dengan tipe data
  let nilai: (u8, f32, u8) = (80, 9.3, 77);

  // Deklarasi tanpa tipe data
  let nilai_b = ('A', 79, 9.3);

  // Destructuring
  let (x, y, z) = nilai;
  println!("{}, {}, {}", x, y, z);

  // Directly access element
  let h = nilai_b.0;
  println!("{}", h);
}
```
- _Tuple_ ditandai dengan tanda kurung `( )`.
- Dapat dideklarasi dengan atau tanpa tipe data _element_-nya.
- Mengambil nilai element dapat dilakukan dengan 2 cara
    1. Destructuring
        seperti saat deklarasi, akses pun menggunakan tanda kurung `( )`.

        Perlu diperhatikan, akses nilai dengan _destructuring_
        harus menyesaikan dengan panjang _tuple_-nya.

        Bila ada element yang tidak akan dipakai,
        maka dapat menggunakan `_` sebagai _variable_ nya

        ```rust
        fn main() {
          let nilai_b = ('A', 79, 9.3);

          let (h, _, _) = nilai_b;

          println!("{}", h);
        }
        ```
    2. Directly access
        dengan menggunakan `.`, dan index yang diawali dengan 0.


### Array

Hanya satu tipe data dan panjangnya tidak dapat diubah.
```rust
fn main() {
  // Deklarasi dengan tipe data
  let nilai_matematika: [u8; 5]  = [8, 4, 9, 8, 8];

  // Deklarasi tanpa tipe data
  let nilai_ipa = [8, 7, 5, 6, 5]; 

  // Destructuring
  let [_, kedua, _, keempat, _] = nilai_matematika;
  println!("{}, {}", kedua, keempat);

  // Directly access element
  let ipa_kedua = nilai_ipa[1];
  println!("{}", ipa_kedua);
}
```
- _Array_ ditandai dengan tanda kurung siku `[ ]`.
- Dapat dideklarasi dengan atau tanpe tipe data.
    Saat menggunakan tipe datanya, yang ditulis adalah
    `[u8; 5]` tipe datanya (`u8`) dan panjang array nya (`5`),
    dengan `;` sebagai pemisah.

    Denga metode ini, kita juga dapat membuat array dengan panjang dan nilai yang sama,
    contohnya,

    ```rust
    let nilai_ips = [7; 5];
    ```
    Hal ini sama dengan kita menulis `let nilai_ips = [7, 7, 7, 7, 7]`.
- Mengambil nilai element dapat dilakukan dengan 2 cara, sepertihalnya _Tuple_
    1. Destructuring
        dengan tanda akses nya `[ ]`.

        Dan ketentuan error sepertihalnya _Tuple_.
    2. Directly access
        dengan menggunaan tanda `[ ]`, dan index 0 sebagai awalnya.



Demikian Sesi Tipe Data.
Semoga bermanfaat, dan terima kasih.
Java Garbage Collecting
Tags: beginners, java, memory
Published: 2021-06-14 00:20:13

Hello everyone, for today’s post I am going to discuss garbage collecting for Java.  For those that don’t know, garbage collecting is the process of clearing up memory in the application at runtime.  As objects are created over the life cycle of the program they will eventually take up too much space.  In programming languages like C or C++ programmers will have to manage memory on their own.  Java is different in that it handles it in house and will delete object that are no longer referenced automatically in the JVM.

Each JVM can implement its own form of garbage collecting as long as the type chosen meets the requirements of the JVM.  The most common garbage collector is Hotspot by Oracle.  Hotspot uses a generational garbage collector method that categorizes objects by the number of collections cycles it has lived through.  Hotspot’s philosophy is that most objects are short lived and in order to increase efficiency most passes of the garbage collector should just look at newer objects since they are most likely to be deleted. Looking at the graphic below, Hotspot breaks up the memory heap into sections called the young generation, old generation, and permanent generation.

![HotspotHeapStructure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a6wsi4x5awa6ne7gsco.PNG)

The young generation consists of the eden, S0, and S1 blocks.  Eden is where new objects are stored.  They are frequently deleted in this phase since many are no longer used each collection cycle.  Objects that live past the first cycle move into S0 or S1 depending on which one is the survivor block for the rotation.

![ObjectAging](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywdf69so114lghw5epvl.PNG)

Objects already in one of the survivor blocks move between them together with each rotation they survive.

![AdditionalAging](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ceoet7cixyf8vhkwdk24.PNG)

If an object has aged a specific threshold of cycles it then moves on to the tenured block.  Minor garbage collecting cycles of the young generation do not pass over this part of the heap.  Eventually, a major garbage collection event will occur which will clean up and compact this space as well.

The permanent generation is used to contain metadata and is populated by the JVM at runtime.  This data labels and describes the classes and methods used by the program.  Java standard libraries are also stored in this section.  Classes here can be removed during a full garbage collection if the JVM determines they are no longer needed and space is required for other classes.

Sources:

1. Altvater, A. (2017, May 11). What is Java Garbage Collection? Best Practices, Tutorials & More. Stackify. https://stackify.com/what-is-java-garbage-collection/#:~:text=Java%20garbage%20collection%20is%20the,Machine%2C%20or%20JVM%20for%20short.&text=The%20garbage%20collector%20finds%20these,them%20to%20free%20up%20memory. 


2. Oracle. (n.d.). Java Garbage Collection Basics. https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html.
Please ELI5 what Parquet is for, and NOT for
Tags: explainlikeimfive, datascience, sqlite, help
Published: 2021-06-14 00:14:55

I am trying to understand how good is [Apache Parquet](https://parquet.apache.org/) for

- Data storage format (when you DO NOT have a Hadoop; only on your local computer)
  - How big is the size?
  - How reliable is it?
- Query-able format
  - Do I have to index first? (Probably unique indices are not possible?)
  - Speed?
  - Resource usage?

As far as I understand, Parquet may not be good for frequent writes or updates; but is it good enough for a **static database**?

You can compare to the always popular SQLite, as a benchmark; disregarding SQLite features, such as foreign keys, unique indices, full text search and multiple tables.

BTW, I have seen SQLite file size goes to 700 MB for a few megabytes for final CSV data, and not sure if it is [reliable as a storage](https://www.quora.com/What-are-the-problems-associated-with-using-SQLite-as-a-data-storage-and-sharing-format) anymore...
How to learn a new tech stack
Tags: career, language
Published: 2021-06-14 13:11:22

---
title: How to learn a new tech stack
published: true
date: 2021-06-14 00:00:00 UTC
tags: career,language
canonical_url: https://jhall.io/archive/2021/06/14/how-to-learn-a-new-tech-stack/
---

I see a lot of discussion about how to learn a new tech stack. Whether you’re a frontend developer, interested in learning a backend langauge, or vice versa, or maybe you’re interested in branching out into more operational disciplines, like Kubernetes and Docker.

There are four basic approaches I’m aware of for this type of career move, and I’ve used each (except the first) in my own career, in various ways.

1. **Go back to school.** There’s always the option to just quit your job, and go back to school to learn something new. This is probably _not_ a good approach for most of us, and I would advise almost everyone to skip this option. I only mention it to be complete.

2. **Afternoons and weekends.** This is probably the default option most of us consider. We grab a stack of Python books (or online tutorials), and hack away in our spare moments. But once you’ve learned something this way, there’s the problem of _proving_ that you’ve learned it to a potential employer when you’re ready to change roles. Also, many people simply don’t have the time (or interest) in hacking in their spare time. For this reason, this approach is often best coupled with one of the following.

3. **A new or side project at your current job.** This isn’t possible in all companies, depending on size, management style, and other factors. But there’s often a good chance that you might be able to at least dabble in some new technologies in the course of your current role. This is how I first experimented with Go. My job at the time predominantly used Perl, so I volunteered to re-write a poorly performing service in Go. This is especially powerful if you’ve been learning a new technology in your spare time. Even a few hours per week at your day job using the new technology can let you legitimately put it on your CV.

4. **On-the-job training.** Many companies are willing to hire engineers who don’t have direct experience with their tech stack, as long as they believe they are willing and eager to learn. This is probably most common for up-and-coming technologies, where it may be difficult to find experienced developers already trained in that area. This may also be difficult to do very early in your career, before you have a track record, but even with as little as 2 years experience in another technology, I have hired people onto my teams to learn the technology we’re using.

There is no silver bullet if you want to make a lateral jump in careers, but these are some solid and proven approaches you can take to make a move if that’s where you want to go.

What other tactics have you used successfully to change technologies in your career?

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Notes on ”Advice for Your First Dev Role”
Tags: codenewbie, firstyearincode
Published: 2021-06-14 12:07:08

---
title: Notes on ”Advice for Your First Dev Role”
published: true
date: 2021-06-14 00:00:00 UTC
tags: codenewbie, firstyearincode
cover_image: https://www.rockyourcode.com/static/img/2021-06-14-team-marvin-meyer.jpg
canonical_url: https://www.rockyourcode.com/notes-on-advice-for-your-first-dev-role/
---

[Virtual Coffee][virtualcoffee] is a remote community for developers that aim to support each other.  
They offer "brown bags" which are talks and discussions about a specific topic.

Here are my notes from **[Advice for your first dev role][youtube]** by Bryan Healey:

Remember that there will be a **ramp-up period**. You should take the time to talk to other engineers in your team.  
Learn about the tooling stack as soon as possible.  
Talk to your manager regularly.

Keep in mind what you want to achieve in a year, 5 years, etc. Be proactive. Don't wait for tasks to come to you — _gradually_ ask for more complex tasks. Take ownership.

Many juniors try to jump in and contribute at scale. That hinders them from seeking help, and **opening a dialog**. Having a "set of fresh eyes" is valuable for a company.

Bryan looks for **continuous contributions on an escalating scale**. He doesn't expect a junior to contribute major features right away.  

Good engineers should be **comfortable with asking questions** as its part of the process.  
A functional team will collaborate and discuss, so your questions should be welcomed, too.

_When_ should you ask questions? As a beginner, don't spend too much time on trouble-shooting. Nobody gains much when you try to solve a problem yourself that could be solved faster by asking for help.  
Rule of thumb: don't spend more than 30 minutes banging your head against the wall.

When you start a new job, there is a "grace period" where everyone expects you to ask questions. Build trust by doing your due diligence (take notes, learn, listen for feedback, etc.).

Also remember that seniors developers can learn from _you_.

Bryan hires junior developers for their personality, creativity, problem-solving, not for their technical skills. He looks for people that can push the team. He doesn't care about failure, not delivering things.  
Don't be quiet, be part of the team.

## Links

- [Advice for your first dev role – Bryan Healey – Virtual Coffee Brownbag][youtube]
- [Bryan Healey's website](https://www.healeyengineering.com/consultants/Bryan-Healey) and [Twitter account](https://twitter.com/Bryan_Healey)
- [Virtual Coffee][virtualcoffee]

<small><em>image credit: <a href="https://unsplash.com/photos/SYTO3xs06fU">Marvin Meyer</a></em></small>

[youtube]: https://www.youtube.com/watch?v=cwTFHDgDDeY
[virtualcoffee]: https://virtualcoffee.io/