teleren/devto huggingface dataset:
Launch Apps through the Terminal
Tags: linux
Published: 2023-01-06 01:15:37

---
title: Launch Apps through the Terminal
published: true
date: 2020-09-27 01:48:09 UTC
tags: Linux
canonical_url: https://brandonrozek.com/blog/launchappsthroughterminal/
---

Normally when you launch an application through the terminal, the standard output appears, and closing the terminal closes the application.

## Using `systemd`

[Tem Tem](https://fosstodon.org/@ralismark) recently [tooted](https://fosstodon.org/@ralismark/108266728217245129)a [blog post](https://www.ralismark.xyz/posts/systemd-run) they wrote on replacing `nohup` with `systemd-run`

To run a graphical application it’s as easy as:

```
systemd-run --user application

```

If you want to see any of the application terminal output, then when the service is running you can check the status like any other systemd service.

```
systemd --user status application

```

Note that the current directory information is not known to `systemd-run`. Therefore, if you’ll need to specify absolute as opposed to relative paths. For example:

```
systemd-run --user okular "$PWD/document.pdf"

```

Check out Tem Tem’s [blog post](https://www.ralismark.xyz/posts/systemd-run) for more on `systemd-run`!

## Using `nohup` (Legacy)

When the terminal closes, it sends a hangup signal to all of the processes it manages. The `nohup` command allows applications to run regardless of any hangups sent. Combine that with making it a background task, and you have a quick and easy way to launch applications through the terminal.

```
nohup application > /dev/null &

```
Bootcamp Java Developer Day #7
Tags: java, bootcamp
Published: 2020-09-27 01:44:21

#### Day 7:

Yay! Finished the first course in Java (9 hours). It took me a lot of time to work with checkstyle and pmd, but they are working now. :D
I'm tired, so I'm not going into the specifics.
I think this course (from Digital Innovation One) is a good introduction. I think the Array and Exception topics were weak though.

#### 6) Completed: Basic Development in Java

Topics:
- Strings, java.lang
- Conditionals, operators, loops
- Arrays
- Exceptions
- Object Oriented with Java
- SOLID
- Date: DateFormat, LocalDateTime, etc
Submit Your Hacktoberfest Repos to up-for-grabs!
Tags: hacktoberfest, github, opensource
Published: 2020-09-27 00:25:39

As [Hacktoberfest 2020](https://hacktoberfest.digitalocean.com/) descends in less than a week (!!!), I wanted to give a shoutout to [up-for-grabs.net](https://up-for-grabs.net/).

{% github up-for-grabs/up-for-grabs.net %}

I find it a super useful resource when looking for OSS to contribute to with my current skillset. I'd love for others who are prepping their projects for Hacktoberfest to make use of it - or those who are also exploring what's out there.

If you are prepping your repos for Hacktoberfest, you can use the Hacktoberfest label as the "beginner-friendly" tag when submitting. [OpenFaaS](https://www.openfaas.com/), an open source implementation of Function as a Service, and [Matomo](https://matomo.org/), "the leading open alternative to Google Analytic", both use their "Hacktoberfest" issue labels in this manner, for example.

Hope you find this resource as helpful as I do. I'm more than happy to assist with any PRs if you want your repo added to the listing. Good luck during Hacktoberfest!
Invert Binary Tree Python
Tags: python, algorithms, computerscience
Published: 2020-09-27 00:04:40

This is a leetcode question which could be found [here](https://leetcode.com/problems/invert-binary-tree/)

You are given a Binary Tree and you are to invert it or swap every left node with its corresponding right node. 

Each BinaryTree node has an integer Value, a Left child node, and Right child node. Children nodes can either be BinaryTree themselves or None/Null.

```python
# Given class definition of a binary tree
# DO NOT TOUCH THIS
class BinaryTree:
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

def invertBinaryTree(tree):
    if tree is None:
        return
    swapLeftAndRight(tree)
    invertBinaryTree(tree.left)
    invertBinaryTree(tree.right)

def swapLeftAndRight(tree):
    tree.left, tree.right = tree.right, tree.left
```

The `swapLeftAndRight` function is the most important part where it does the actual swap of the left and right nodes. Python is really nice where you can put a swap onto one line.

Then you would recursively call the invertBinaryTree function to continue swapping the following left and right child nodes.
How to loop through Buffers in Node.js?
Tags: node
Published: 2020-09-27 00:00:00

---
  title: How to loop through Buffers in Node.js?
  published: true
  tags: Nodejs
  date: Sun Sep 27 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/loop-through-buffers-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-6c6eb8f22d106ac599794fc50161a027.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/loop-through-buffers-nodejs)
  
To loop through a `Buffer` instance we can use the `entries()` method available in the buffer instance with the `for...of` looping statement.

Let's say we have a Buffer instance with String `Hello World!` like his,

```javascript
// Buffer instance with string Hello World!
const buff = Buffer.from("Hello World!");
```

Now to loop through the Buffer let's use the `entries()` method and the `for...of` looping statement like this,

```javascript
// Buffer instance with string Hello World!
const buff = Buffer.from("Hello World!");

// loop through buffer instance
for (let pair of buff.entries()) {
  console.log(pair);
}
```

- The `entries()` method returns the data in `[index, byte]` format.

The output of the above code looks like this.

```js
/*

[ 0, 72 ]
[ 1, 101 ]
[ 2, 108 ]
[ 3, 108 ]
[ 4, 111 ]
[ 5, 32 ]
[ 6, 87 ]
[ 7, 111 ]
[ 8, 114 ]
[ 9, 108 ]
[ 10, 100 ]
[ 11, 33 ]

*/
```

But if you don't want this in the `[index, byte]` format but as a single string, you can use the `String.fromCharCode()` method to get the appropriate character inside the loop like this,

```javascript
// Buffer instance with string Hello World!
const buff = Buffer.from("Hello World!");

// loop through buffer instance
for (let pair of buff.entries()) {
  // get the byte of character
  const charCode = pair[1];
  // use String.fromCharCode() to get the appropriate character
  // for the byte
  console.log(String.fromCharCode(charCode));
}
```

The output of the above code looks like this,

```js
/*

H
e
l
l
o

W
o
r
l
d
!

*/
```

See this example live in [repl.it](https://repl.it/@melvin2016/loop-buffers).

### Feel free to share if you found this useful 😃.

---
YaraSilly2 - YARA Rule Generator
Tags: malware, python, yara, ssdeeep
Published: 2020-09-26 23:51:10

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

A Semi-automatic handy tool to generate YARA rules from sample virus files ( WIP ) for Malware Analyst, inspired by the DIFF function of VirusTotal Premium Account. It generates all the artifacts from samples ( Static Analyzer ) needed to create good Yara Rules, with less false positive. 

**Features**:-
1. It uses a fuzzy match to find similar malware files based on tolerance the percentage set by the user. 

2. String dump from the files in binary mode and find the occurrences of the files and take those string that occurs the specified number of times set by the user.

3. Eliminate all the blacklist strings that are provided from the match occurrences criteria.

4. Generate YARA rule and also prints the MD5 hash of the files within the meta section of YARA rules.

You can find the project repo at [https://github.com/YARA-Silly-Silly/yarasilly2](https://github.com/YARA-Silly-Silly/yarasilly2)
Hosting Rails project on Heroku
Published: 2020-09-26 23:46:14

After you finished your projects, you want to be able to host your project online to show off to your friends and family, and there's a ton of available options when it comes to hosting your project, including popular cloud based solutions like AWS, which has a lot more customization options. If you want something simple, Heroku has everything you'll want for your hosting purposes. There's a ton of documentation on the Heroku website for how to set up for different languages, but this is what you'll need to do for a Ruby on Rails project.

1) Create a heroku account

Go to [https://www.heroku.com/](https://www.heroku.com/) to create a Heroku account.

2) Create a new Heroku project

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

After signing in you should be redirected to this homepage. You'll want to create a new heroku project by clicking on the new button in the top right corner.

3) Download Heroku Cli

Go [here](https://devcenter.heroku.com/articles/heroku-cli#download-and-install) to download the Heroku Cli onto your machine which will allow you to run heroku command in your console. 

4) Login to Heroku

Run `heroku login` on your console and type in your heroku account credentials to login.

5) Link heroku remote to your existing Git repo

If you don't already have a git repo you'll have to create that first. Navigate to your git repo on your local machine, and run this command 

`heroku git:remote -a PROJECT_NAME`

6) Push to heroku and build. 

Run these to start your build

`git add .`
`git commit -m 'commit message'`
`git push heroku master`

7) Make database migrations and seed your data

After your build is successful you can run these to create necessary migrations and seed data.

`heroku rake db:migrate`
`heroku rake db:seed`

8) Open your heroku project!

Run `heroku open` to open your project. If you get something like "Something went wrong on your webpage" you can type `heroku logs` for more information on your particular error. If you're here, good luck on Stack Overflow.
My Hacktoberfest Project 😊
Tags: hacktoberfest, javascript, codenewbie
Published: 2020-09-26 22:58:34

I started my open source journey with **Hacktoberfest** last year. I have come a long way and learned new things, thanks to open source. This year I am very happy and excited to create my own project for hacktoberfest. Though I have very little skills in maintaining projects, I suppose I could learn it this year. 

## This is what I created 🙃. 

[![ReadMe Card](https://github-readme-stats.vercel.app/api/pin/?username=Souvikns&repo=JContainer&theme=dracula)](https://github.com/Souvikns/JContainer)

### About
The main idea behind the project is to create a prebuilt **REST API** for all our data storage needs. With the help of [vercel](https://vercel.com), we can set it up with just a click. 
After deploying it, you can use the **REST API** to interact with this container and store your data. 

### Yeah I know what you are thinking 😋
If it's an API won't anyone be able to access my data? The first time when you enter your container you set up a passcode and it generates an `API_KEY`. Then you need to pass the `API_KEY` in the headers to authenticate yourself. Anyone with the `API_KEY`can access your data so, keep it safe.

---

> The project is at its early stage, do check it out and show some love. Leave a star if you like it. 😊

[![GitHub issues](https://img.shields.io/github/issues/Souvikns/JContainer?style=for-the-badge)](https://github.com/Souvikns/JContainer/issues)
Back-Pressure strategy: AWS SQS polling from a sharded Akka Cluster running on Kubernetes
Tags: akka, kubernetes, scala, aws
Published: 2020-09-26 22:46:47

This blog was originally published on Medium:

https://medium.com/congruence-labs/back-pressure-implementation-aws-sqs-polling-from-a-sharded-akka-cluster-running-on-kubernetes-56ee8c67efb
Binomial Test
Tags: datascience, beginners
Published: 2020-09-26 22:41:47

###**Hypothesis testing using binomial distribution**

Here we will use the binomial probability distribution function for the exact binomial test. For example, we played a board game against a computer and found that it is quite easy to win the game. So, one of the players has a hypothesis that a die roll is not fully random, but biased to the player’s advantage. So he checked the stats and found that out of 100 rolls, he had 23 ‘sixes’. Is the player’s assumption correct that the game is biased to give more ‘sixes’ to a human player?

So, the expected value for this case is 100*⅙=16.7, while the observed value = 23.
Let’s do the exact binomial test and it will be one-tailed test. 
The null hypothesis is that the probability of getting ‘6’ p = ⅙, 
The alternative hypothesis is that p>⅙.
For this exercise, we will use critical value alpha = 0.05, so if our p_value calculated using binomial distribution is less than 0.05 then we can reject the null hypothesis. Because the p_value is just a conditional probability - the probability of the particular event given the null hypothesis is true. For example, if p_value = 0.01 it means there is 1% probability of getting this observation (23 ‘sixes’ out of 100 rolls) when the null hypothesis is true (die is fair). But if p_value = 0.1 then there is 10% probability that we can observe 23 sixes out of 100 roles when the null hypothesis is true. 

Using binomial cumulative mass distribution:

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

Because p_value=0.063>0.05, we cannot reject the null hypothesis (fail to reject). Basically, there is more than 5% chance that the null hypothesis is true. 

But what if we continued to play and got the same observed value = 23, meaning we got 46 6s out of 200 rolls. Let’s check this potential situation.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4woacjcp0cne6n7m8fuc.png)

In this case p_value <0.05, and we would reject the null hypothesis.

P_values for both scenarios are shown below.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oyfsrsstvjarfmprk2ge.png)

###**Conclusion**

The binomial test example can be used as an exact test for hypothesis testing without calculation test statistic as p_value can be calculated by using binomial pmf.
Accessing AWS ElastiCache (Redis) from multiple AWS accounts via AWS PrivateLink
Tags: aws, redis, elasticache, crossaccountaccess
Published: 2020-09-26 22:36:51

Initially published at Medium: 

https://medium.com/@programmerohit/accessing-aws-elasticache-redis-from-multiple-aws-accounts-via-aws-privatelink-8938891bec6c
WPF ItemsControl
Tags: dotnet
Published: 2020-09-26 22:31:53

The `ItemsControl` element is a great way to implement customized representations of collections in a WPF application. Assuming that you have a view model with an observable collection, you can use the `ItemsControl` element to dynamically generate a button for each member of the collection.

```xml
<ItemsControl ItemsSource="{Binding MyCollection}"
              x:Name="MyCollectionControl">
    <ItemsControl.ItemsTemplate>
        <DataTemplate>
            <StackPanel>
                <Button Content="{Binding Name}"
                        Command="{Binding ElementName=MyCollectionControl, Path=DataContext.SelectMemberCommand}"
                        CommandParameter="{Binding}" />
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemsTemplate>
</ItemsControl>
```

The markup above will generate buttons for each member of `MyCollection`. The content of each button will be the `Name` property of the member, and the command will be the `SelectMemberCommand` command implemented in the view model. Since the context of each button points to a member of our observable collection, we need to reference the command by pointing to the `DataContext` of the parent element, which is our `ItemsControl`.

With an observable property in the view model we can track which member was selected and update the view accordingly.

There are endless ways in which you could use the `ItemsControl` to create UI elements for members of a collection; This is just a small example.
How to obtain information from your customers?
Published: 2020-09-26 22:27:09

I work for a local startup company. Like most companies, we build customized ecommerce solutions and we have a team of graphics designers for social media and others works related with design. 

At the moment of writing this, we are growing and all the information our customers give us are coming from email (text, docs, sheets, images).. so sometimes we lost the information between the gmail pyramid of mails
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/aqg4yl4fz3xobak0zr8m.png)

I want to know how you receive the information from your clients, maybe you use telegram, frontapp.. I know the best way is to use the mail because all data is saved on the server, but maybe there is a better way.
Design and development of a minimalistic fashion photography website
Tags: design, webdev
Published: 2020-09-26 21:31:57

Our design team continuously strives to develop, grow, and be ready to change. So they are constantly learning and trying new things. In 2020, Evrone designer Natasha Yankelevich decided, as an exercise, to create the concept of a personal website for an individual who inspired her - photographer Elizaveta Porodina.

Natasha published the concept on social networks and tagged Elizaveta. She almost immediately received a message from the photographer praising the site concept. Elizaveta wanted us to fully develop the site and turn it into a representation of herself and her style. We reached an agreement on all the documentary details, discussed the nuances of the fashion photography website project, and got down to work.

https://evrone.com/porodina
Bringing science-based health & technology together
Published: 2020-09-26 21:31:42

Otri is a Russian-British comprehensive health app project, initiated by British company Biolink.tech LTD and founded by two entrepreneurs, Ivan Degtyar and Evgeny Chereshnev. Ivan, as the CEO, oversees the project, while Evgeny deals with the partners and investment side.

https://evrone.com/otri
Go Functions: Pointer vs Value params
Tags: go, pointers
Published: 2020-09-26 21:25:39

In Golang we have the concept of pointers. It works similar to languages like C, C++ and represents the memory address where the variable value is stored.

You can see more  about pointers [here](https://en.wikipedia.org/wiki/Pointer_(computer_programming)), since it is not the objective of this post.

From this concept, we can have functions that works with pointer params and value params.

The difference is the way we declare the function and how the variable will be handled during manipulation.

### The code

To better explain the differences we will create a struct so we can manipulate its attributes inside the function, declare a variable with the struct type, and the functions. One with pointer param and a function with value param.

So, we will have the struct **User** containing **Name** and **Github**:

```golang
type User struct {
	Name   string
	Github string
}
```

And the functions responsible to change the **Name** attribute and print the struct values.

```golang
func changeAndLogPointer(user *User) {
	user.Name = "Bruno Vasconcelos"
	fmt.Printf("Name: %s, Github: %s\n", user.Name, user.Github)
}

func changeAndLogValue(user User) {
	user.Name = "Bruno Vasconcelos"
	fmt.Printf("Name: %s, Github: %s\n", user.Name, user.Github)
}
```

Note that the first one (changeAndLogPointer) receives a pointer and the second one (changeAndLogValue) a value.

So we will execute a main function that uses the pointer approach

```golang
func main() {
	user := &User{Name: "Bruno", Github: "brunohgv"}
	changeAndLogPointer(user)
	fmt.Printf("Name: %s, Github: %s\n", user.Name, user.Github)
}
```

The result of the execution is:

```
Name: Bruno Vasconcelos, Github: brunohgv
Name: Bruno Vasconcelos, Github: brunohgv
```

It happens because when a pointer is used, all changes are related to the memory address that the value is stored. I means that any changes to the parameter will impact the variable that was passed as param.

Now we will execute the function using a value:

```golang
func main() {
	user := &User{Name: "Bruno", Github: "brunohgv"}
	changeAndLogValue(*user)
	fmt.Printf("Name: %s, Github: %s\n", user.Name, user.Github)
}
```

And the result is:

```
Name: Bruno Vasconcelos, Github: brunohgv
Name: Bruno, Github: brunohgv
```

Why is this happening?
Since we are passing the value as parameter, the Go compiler will create another memory space to handle this variable internally. It means that any changes inside the function will impact in an internal variable, keeping the original one untouched.

### So, what is the best approach?

Well, it depends. The pointer is a better option if you want to change the original value, than use that modified values in the future.
If your objective is to prevent changes and manipulate it only inside the function, the value is the best approach.

There are other usages for any of the approaches, but understand the basics is the best way to decide what will be the best choice for your application.
WORD COUNTER: A simple python script that counts a specific word in text file
Tags: showdev, python, algorithms, 100daysofcode
Published: 2020-09-26 21:22:13

During a rainy and boring morning, I decided to write an algorithm that displays how many times a word appears in the bible.

---
To start with, I searched for a kjv bible in a text file and found one that was in this format:
__*bible.txt*__
```
Genesis 1:1	In the beginning God created the heaven and the earth.
Genesis 1:2	And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
Genesis 1:3	And God said, Let there be light: and there was light.
...
Revelation 22:21	The grace of our Lord Jesus Christ be with you all. Amen.
```
---

Then I wrote this code to do the word count magic for me:
__*search_bible.py*__
```python
search = input("Search for: ")
total_count = 0
with open("bible.txt") as bible:
    for line in bible:
        bible_verse = line.split("\t")[-1].lower()
        verse_count = bible_verse.count(search.lower())
        total_count += verse_count
print(f"{search} appears {total_count} times")
```

---
Testing the program (_where script and text file are in same directory_)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4zlzrfiwr1bxohkl1n9a.png)

---
__*Feel free to share your insight on the comment and don't forget to like.*__
My #100DOC - Day 31
Tags: 100daysofcode, challenge, log
Published: 2020-09-26 21:17:45

### Day 31: September 26, 2020

#### **Today's Progress**: 
1. **[Redesign of my portfolio](https://github.com/pablohs1986/pablohs1986.github.io)** (1h 30min):<br>I did the basic template of the project and started write the navbar.
    
#### **What I learned**: 
* Review of html basics.
* Review of Bootstrap basics.

#### **Total time**:
1h 30min.
What to/not to test when building an App with MERN stack? 👨🏻‍💻
Tags: discuss, webdev, node, react
Published: 2020-09-26 21:10:54

Hi guys, I'm trying to keep learning testing, but I'm not sure what to test and what not to test, I been reading posts, seeing tutorials and everybody agree that you should avoid testing implementation details...

but if you guys have some more experience, what should I focus on when it comes to testing either in the backend and the frontend, and what libraries/frameworks do you recommend?

Also if you want to recommend any book, articles, video-tutorial or any other source that you consider useful, go ahead  , if not, it's ok, I'll look into the docs and search for examples and articles by myself.

thank you guys! enjoy your weekend 👍