teleren/devto huggingface dataset:
Learning Rust 🦀 and making a Magic 8 Ball program!
Tags: rust, codenewbie, systems, backend
Published: 2021-04-03 03:03:35

Over the past couple of weeks, I've been wanting to expand my knowledge and to become more valuable as a developer.

*Well, I'm pretty decent at Frontend already... I guess I should try out the backend of things!*

After asking my friends for advice and for looking on different online forums, I've decided to go with **Rust**! 🦀

## Why did I choose it?

- High performance!
- Low memory consumption
- It's not too hard to learn (Yes, I lied. I know a little Python too so I know what I'm getting into.)
- Great for system-based ops
- Nice-to-have for backend experience
- I've always wanted to make an awesome CLI!

---

So... after a couple hours of learning the fundamentals of Rust, I created my first project!

A Magic 8 Ball program!

https://github.com/BraydenTW/8ball-rust

![Terminal shot](https://github.com/BraydenTW/8ball-rust/raw/master/img/terminal.png)

I would appreciate it if you gave the repo a ⭐ and some feedback in the comments below!

Thanks so much for your help. I can't wait to learn more!
WhatsMyIntent [Android Internals CTF Ex1 ]
Tags: cybersecurity, security, android
Published: 2021-04-03 02:35:40

Install the given [apk](https://github.com/wireless90/AndroidInternalsCTF/tree/main/WhatsMyIntent).

- Your task is to send an intent with action "dart_ctf". 
- Pull the flag from the returned intent. 
- Do not reverse the apk.


So what we need to do is to send an intent with action `dart_ctf`.

First lets create a new android application.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p5pgkizs50f2dzev2kah.png)

Click `Create New Project`
 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbj3gq0qtluarhfhi9bp.png)

Click `Empty Activity` 


![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ykd97bdybgzr7z8wa454.png)

Ensure its a `Java` based project.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zurk62ti3egvojobugfi.png)

Lets create a new Intent under the `onCreate` function. We can see that it accepts a string, `action`.


Following that, we are going to call `startActivityForResult(intent, requestCode:2);`

This basically tries to start that activity and expects a result. As multiple activities can be started, we have added a `requestCode` to uniquely identify the activity result that we want. I just gave an arbitary number, `2`.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/id65ijbn9fghxvb9mmj1.png)
 
The above is how your code should now look like.
  

Now let's try running the app. This is what I get in my emulator.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7wtx43dx6au465trnuc.png)
 
The reason is because I have not installed the given apk into the emulator yet. Simply drag and drop it into the emulator to install the vulnerable `.apk` package. Once installed, run your application again.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jsu9pvi9hy9z7sxo58q.png)
 
Great! Our application has successfully started an activity using the intent. But we have not configured the code to process the result.

In order to do this, I override the onActivityResult callback.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j96vqkyexllmw4znv571.png)
 
Basically, we check our request code if equals to the one configured, `2`, then extract out the dictionary keys. For each key, we print out to logcat the value. And we have got the flag!
Do you have a mentor?
Published: 2021-04-03 01:23:49

Cross-posted at https://www.msajid.cloud/2021/04/03/do-you-have-a-mentor/ and https://sajid-nazeer.medium.com/do-you-have-a-mentor-4969b0012dc0

As James Clear said 

> “We imitate the habits of three groups in particular: The close. The many. The powerful.”

Among these groups, the only group we can control is the close.

According to the **Self-expansion** model theory in psychology, we often achieve self-expansion through close relationships (family, friends, colleagues, etc) which allow the inclusion of the other in ourselves usually by imitating their habits and vice versa. 

**Self-expansion can be a growth or a failure both.**

For example, you might notice that you start reading books if you have a partner or a close friend who always reads and recommends books to you. Similarly, those who have friends and/or parents who smoke are more likely to start smoking than those who don’t.

You might also have heard about the **Pygmalion effect**, the idea behind the Pygmalion effect is that increasing the leader’s expectation of the follower’s performance will result in better follower performance.

High-performing mentors have high expectations from their mentees, which might result in better mentee performance.

Remember both success and failure is contagious, surround yourself with people who you look up to, or want to be like.

Go get a mentor if you don’t have one already.
What I leaned from an HTML fundamentals cource
Tags: webdev, programming, productivity
Published: 2021-04-03 00:40:03

Being a self-taught developer hobbyist, I thought it would be a good idea to expand my understanding by taking an HTML and CSS fundamentals course at my community college while I am getting my associates.
I have taken a Coursera course and studied fundamental practices for web design and development, but I wanted to see what I could learn by formally going through a course about the fundamentals before I go to university.  
## The Course

HTML is so simple, "it's like Legos". Going through this course with something I am fairly familiar with, felt very tedious and as if I was not learning much or anything at all at times.

## Accessibility

The first topic of the course was accessibility. Accessibility was not something that was extensively familiar with. Learning about the importance of accessibility was interesting. Here are some of the things I learned from the topic:

<details><summary>What I learned about accessibility</summary>

- Meeting accessibility is required by law in some countries for web sites
- 10% of internet users have a disability (or something like that) says W3 I think
- So many (most) websites or apps fail in some way in accessibility such as keyboard navigation.
- Accessibility benefits not only the disabled but everyone
- Implementing Accessibility greatly improves the sites visual and usability
- W3 has specific color contrast standards that are important for impaired vision and easier readability of content.

</details>

## Re-Learning the languages
Anybody can use HTML or CSS like how anybody can play Legos, but accessibility, techniques, and design principles are what I think are important. Learning new tags, style attributes and concepts were very interesting and have helped me out.
<details>
<summary>Some of the syntactical things I learned</summary>

- familiarity with floating. I knew how to float and clear elements, but I now am able to understand it much better.
- Less common tags such as figure, kbd, image and q I had not known before
- New CSS properties like text columns and other random things I have never seen before
- I never knew about [normalize.css](https://duck.com/normalize.css_github)

</details>

## Being Certified
I was able to get a free Microsoft MTA certification with the class. It is nice to know that I knew somewhat that I was certified in some way and not just looking at the MDN or W3Schools to learn everything.

## Why I Recommend A fundamental course
The fundamentals allowed me to understand websites in a new way. Self-teaching allows me to get into more advanced concepts while the college course was able to expand my understanding about how everything works.
Understanding Prefix & Postfix Operators
Tags: java, codenewbie
Published: 2021-04-03 00:04:31

I just started my journey to learn how to build mobile apps with [@ingressive4Good](https://twitter.com/Ingressive4Good) and [@thezuriteam](https://twitter.com/theZuriTeam) who are providing free software development and design trainings to young people all over Africa. I joined the Kotlin (Java) track and have been leveraging [SoloLearn](https://www.sololearn.com/) for Java lessons and [Replit](https://replit.com/) to practice.

On getting to Operators on SoloLearn, I found prefix and postfix operators a little confusing. The difference between what happens when the operator is before and after the operand seemed a bit strange. So I practiced a bit on my Replit scratchpad and arrived at a way to correctly interpret their actions:

> 
- prefix: take action (increment or decrement) on operand first before doing any other thing.
- postfix: take action on operand after doing every other thing.

The interesting part of this story is that I tried to see if I was the only one who found this challenging. I posted a poll with a simple problem and was both surprised and relieved by the result. Even though only a few person voted, they all got the answer wrong!

{% twitter 1377694001365667841 %}

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

Do you really know how prefix and postfix operators work? Think again!
Don't double log
Tags: logging, debugging, programming, productivity
Published: 2021-04-06 10:05:38

---
title: Don't double log
published: true
date: 2021-04-03 00:00:00 UTC
tags: logging, debugging, programming, productivity
canonical_url: https://jhall.io/archive/2021/04/03/dont-double-log/
---

If there’s one programming anti-pattern I see repeatedly, that makes everyone’s lives more difficult, it’s this:

```
	req, err := http.NewRequest(http.MethodPost, fmt.Sprintf(checkVerifURL, t.cfg.ServiceVerificationSID), strings.NewReader(body.Encode()))
	if err != nil {
		t.log.WithError(err).WithField("phone", phone).Error("failed to create request for check code")
		return err
	}

```

This is actual code, copied verbatim, from a project I’m consulting on. For those of you who don’t speak [Go](https://golang.org/), let me translate:

> Create an HTTP request object. If that results in an error, log the error, then return the error to the caller.

“What’s wrong with this?” you may ask. Well, let me show you the caller, also copied verbatim:

```
	err = h.twilio.SendVerifyCode(req.Phone)
	if err != nil {
		h.log.WithError(err).Error("Failed to send verification code")
		return c.JSON(http.StatusInternalServerError, errs.InternalServerErr)
	}

```

And the translation:

> Send a verification code vai Twilio. If that results in an error, log the error, then send a JSON-formatted error as the response to the client.

Hopefully now the problem is more apparent:

The _exact same error message_ is logged _twice_.

This makes debugging difficult, because the log file will show two errors, when only one occurred. And the only way to make sense of this is by reading the code along with the log file—effectively creating tight coupling between your code and logs. Isn’t that a lovely thought?

And this isn’t actually the worst failure mode this type of code can exhibit.

Imagine that our caller to the original function had some fallback mode. Perhaps when Twilio fails, it sends an email. In this case, we’d have an error log _that shouldn’t exist at all_ and can only serve to confuse people.

The solution?

**Handle each error exactly once.**

Dave Cheney talks about this in his post [Don’t just check errors, handle them gracefully](https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully#handle-errors-once). Although his post offers Go-specific examples, the principle applies to any language choice. In summary:

> You should only handle errors once. Handling an error means inspecting the error value, and making a decision. If you make less than one decision, you’re ignoring the error. Making more than one decision in response to a single error is also problematic.

So when you encounter an error state, make a decision about it. This means either handle it (i.e. log it, do a fallback, maybe halt program execution), or defer that handling to the caller (by way of re-throwing, returning an error value, etc). But _never do both_.

* * *

If you enjoyed this post, you’ll enjoy [6 ways to RUIN your logging](https://jhall.io/posts/6-logging-mistakes/), which covers 5 other logging anti-patterns I see frequently.
What is Python Django?
Tags: python, webdev, django
Published: 2021-04-02 22:36:37

[Django](https://www.djangoproject.com/) is a high-level [Python](https://www.python.org/) *Web framework* that encourages rapid development and clean, pragmatic design. It's free and open source.

Django was created in the fall of 2003 by a group of people who wanted to develop a scalable Web application framework, written in [Python](https://pythonprogramminglanguage.com/). Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. 

Django's primary goal is to ease the creation of complex, database-driven websites. You can [deploy them online](https://www.pythonanywhere.com/?affiliate_id=00535ced) with a few clicks.

![django hello world](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pg9u44swjc1xtrf1jl8l.png)

Django's secondary goals are to help facilitate community-building and to advance the practice of Python programming. These goals are followed by the Django project with the creation of events, documentation, and online resources.

* Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
* Django's primary goal is to ease the creation of complex, database-driven websites.
* Django focuses on automating as much as possible and adhering to the DRY principle.
* It can be used in conjunction with an existing CMS such or it can stand alone.

![python django web framework](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y0xuz2sx08h6zsz16hnj.jpg)

## Why Django?

Django 1.0 was released in October 2005. Since that time, the framework has gained a large following and has become one of the most popular Web frameworks available today, with millions of users worldwide. In fact, it is estimated that Django is now used more than Zope, PHP, Perl, and Ruby combined.

The [Django Software Foundation (DSF)](https://www.djangoproject.com/foundation/) was formed in 2008 to provide support and governance for the framework and its community. The DSF is run by an elected board that oversees several aspects of community development.

A number of companies have chosen to sponsor Django's ongoing development. It has good documentation, a large customer base and is [easy to deploy online](https://pythonbasics.org/django-web-app/) .

While Python does support other frameworks like [Flask](https://pythonspot.com/flask-web-app-with-python/) or [Bottle](https://bottlepy.org/), they are minimalist and you have to use different modules to achieve the same kind of functionality.
Start Developing with Laravel in Ubuntu 20.04
Tags: webdev, install
Published: 2021-04-03 23:11:01

---
title: Start Developing with Laravel in Ubuntu 20.04
published: true
date: 2021-04-03 00:00:00 UTC
tags: webdevelopment,install
canonical_url: https://blog.jonesrussell42.xyz/laravel/2021/04/03/start-developing-with-laravel-in-ubuntu-20.04.html
---

First and foremost, I find [Ubuntu](https://ubuntu.com/tutorials/install-ubuntu-desktop#1-overview) the Linux distribution easiest to install and best supported when learning Web Development. I’m sure that’s open for debate, but that’s what the comments are for.

## OK, I’m running Ubuntu, what next?

I suggest that your [install Homebrew](https://blog.aamnah.com/sysadmin/install-homebrew-ubuntu-linux), “The Missing Package Manager for macOS (or Linux)”. It’s great but if you choose another path, I hope you can still follow along.

## I have Homebrew, now what?

### Install DDEV

> [DDEV](https://github.com/drud/ddev) is an open source tool that makes it dead simple to get local PHP development environments up and running within minutes. It's powerful and flexible as a result of its per-project environment configurations, which can be extended, version controlled, and shared. In short, DDEV aims to allow development teams to use Docker in their workflow without the complexities of bespoke configuration.

Follow the directions at https://ddev.readthedocs.io/en/stable/#installation which will ensure you have everything needed to install DDEV and then Laravel.

### Install Laravel

Copy and paste from below, replace MY\_SITE=”” with the name you wish to choose for you site:

```
MY_SITE=my-laravel-app
mkdir $MY_SITE
cd $MY_SITE
ddev config --project-type=laravel --docroot=public --create-docroot
ddev start
ddev composer create --prefer-dist laravel/laravel
ddev exec "cat .env.example | sed -E 's/DB_(HOST|DATABASE|USERNAME|PASSWORD)=(.*)/DB_\1=db/g' > .env"
ddev exec "php artisan key:generate"
ddev launch

```

## Bing, bang, boom. I have some Laravel

The _ddev launch_ command should have opened your default browser to this screen:

![](https://blog.jonesrussell42.xyz/assets/img/laravel.png)
Help with bootstrap 4 div cell
Published: 2021-04-02 23:50:54

Hello guys.Please take a look on this picture.If anyone can make something like this using only html,css and bootstrap 4 i will be soo happy.Link of website with this example: https://bitkong.com/

If you have time for this and if you finish it,put code in github and comment this post with link of your githu account.Thanks in advance guys


https://dev-to-uploads.s3.amazonaws.com/uploads/articles/946bmh9luuaj8p5ca6go.png
IT development company
Published: 2021-04-02 23:30:00

Hi everyone, I apologize for my English because I do not have a good in English, I speak French better, I am a professional master's student in Business Intelligence, I want to start my IT development company but I do not know, if I must choose a specific language and framework or more, or if I must choose web or mobile development or both, thank you I need your advice and assistance
How To Import Data From an Excel File To Your Database(MySQL) using PHPMyAdmin.
Tags: php, mysql, webdev
Published: 2021-04-02 22:59:10

  Have you ever encountered a situation where you had to import records from an Excel file to your database in MySQL?

 Once, I found myself at this point, I was confused for a few minutes😢 but then I decided to consult my knowledgeable friend, Google😉.
Here I'll describe a step-by-step process to achieve this successfully.

### SECTION 1
__(Saving the file as a CSV document).__

1. Open the Excel file and then select 'File', a dropdown will appear and then you click 'SaveAs'.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnkphfvhg6qpljxi2joy.png)


2. Fill in the name of the document and for the document type, Save it as (comma separated) or (comma delimited) which must have an extension of '.csv'.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wv9u1v4wr4iuxjglg0w.png)


3. You will get a prompt like this, Select Yes.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1swx1v3fjenybda97v3g.png)


### SECTION 2
__(Importing the CSV file to the database).__


1. Go to your PHPMyAdmin and create a new database.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uc41cn31efbj9e1xqkg4.png)


2. At the top navigation bar of your page, select Import.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xf0mxiqp5b61o0eruinn.png)


3. Select the .csv file that you saved at 'Choose File'.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5s0jmh7z3iy3mljeotbe.png)


4. It is optional to fill in the table name and if you don't, the name of the file will be the table name. 
If the first line of the file contains the table column names check that box (if it is unchecked, the first line will become part of the data). 
Leave every other setting at the default unless there is a need to change it.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vip81xqgtg2jmc1nhx0k.png)


5. At the bottom right corner, Select Go. Then your import is successful if your output is similar to this without any query error.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3xx328bfuhyw1379mcd4.png)

> NB: If you had multiple sheets that you saved as CSV documents you import each of them repeating the above process. They will constitute the different tables in your database.

Hurray!😊 It's simple and awesome right! 

__Conclusion__
These tips are in my own opinion, so if you have a conflicting view or a better approach, kindly drop them in the comment box, I really enjoy learning.

Thanks for reading.🤝
Find the N+1 Query Problem in Rails Apps in Under 5 Mins
Tags: ruby, rails, sql, performance
Published: 2021-04-02 21:57:20

This video is based on the brilliant [Eager Loading and the N+1 Query Problem](https://news.learnenough.com/eager-loading) blog post by [Kevin Gilpin](https://dev.to/kgilpin).

It is a short demonstration of how to identify the N+1 Query anti-pattern using the [AppMap extension for VS Code](https://marketplace.visualstudio.com/items?itemName=appland.appmap), [jq](https://stedolan.github.io/jq/) and the [Rails Sample Application Sixth Edition](https://github.com/mhartl/sample_app_6th_ed) as an example.

The N+1 anti-pattern happens when a query is executed for every result of a previous query.  If left unchecked N+1 queries result in a gradual slowdown in the performance of an application.

![N+1 Query Problem](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hv2gp0fd2oaiigqmkval.jpg)

Detecting  N+1 queries is tricky, because they are not revealed by any mainstream testing strategy.

To detect the N+1 query problems we need to look at the number of SQL queries that are performed in a realistic situation, such as an integration test, and compare this number with a “reasonable” expectation.

You can find full usage instructions, and all these links, on the [AppMap](https://marketplace.visualstudio.com/items?itemName=appland.appmap) page in the VSCode marketplace.

Thanks for watching!
How do you bookclub? 
Tags: firstpost, books, discuss
Published: 2021-04-02 21:49:24

*We would love to hear your thoughts on what you do to share knowledge with your team.*

Here at LoadUp we had our first developer book club today.  First of all this isn't just a bookclub, but an avenue for us to [pod, parking lot, table, hold off on talking about an interesting topic until an assigned time during the week to discuss in depth] any kind of knowledge that we think will benefit the team, or is worth exploring in depth. 

### Here is how we currently run our 'book club'

1. You don't talk about bookclub
2. You get a week to read the book chapter
3. Anyone can add other knowledge avenues they would like to share and they will be discussed in a FIFO manner
4. We try to ask two questions: 1. How does that differ from what we do now? 2. What could we use?  
5. Most importantly no topic is off the table - radical ideas   change the world.

Like all things that are new we started with an idea and came out the other side with something different. Next week we may end up changing how we do this because this thought experiment will evolve. 

### Why is this important to us?

As a growing team we will be constantly in the storming, forming, norming, and hopefully performing stages of team dynamics. These discussions will help our tribe through each of these constant evolutionary stages as we grow as a company.

Not only will this help our culture it will help our developers to push the boundaries of their comfort zones by learning new things, learning to speak their mind, and navigate passionate discourse. We never should stop learning, but we stop learning when things aren't interesting anymore.  

I leave you with this tidbit of random knowledge that came into our conversation today courtesy of @jamessral 
> Code is a translation of what people do into machine language. It is perfectly legitimate to go the other direction. Shapeup is like an interface that we can interact with, but how we implement is up to us.