teleren/devto huggingface dataset:
What is the $this keyword and how to use it in PHP
Published: 2021-01-11 23:01:02

Check out this post on the [devdojo.com](https://devdojo.com/) website!

It is a post on [What is the $this keyword and how to use it in PHP](https://devdojo.com/bobbyiliev/what-is-the-this-keyword-and-how-to-use-it-in-php) 🔥!

To make things even better you can use this referral link to get a free $100 credit that you could use to deploy your virtual machines and test the guide yourself on a few DigitalOcean servers:

[Digital Ocean $100 Free Credit](https://m.do.co/c/2a9bba940f39)

Link to the post:

https://devdojo.com/bobbyiliev/what-is-the-this-keyword-and-how-to-use-it-in-php

I strongly encourage everyone to go ahead and check out the [devdojo.com](https://devdojo.com/) website, there's a lot of valuable content there.
Git remote backups
Tags: git, tutorial, beginners, productivity
Published: 2021-01-11 22:47:55

As part of my development process, I've made a habit of keeping two remote repositories for every project I work on. One remote repository is on services such as Github, Gitlab etc. and second remote is on a separate/external hard disk.

It has saved me lot of hassle when I accidentally made some mistakes while committing or shouldn't have committed something in the first place and want to backtrack, and it's always good to have a backup, in case something goes wrong with your computer.

#### So here's how you do it:

1. Create an empty repository i.e one without a working tree.
2. Add the empty repository as a remote from your project's git repository.
3. Push your changes to the empty repository.

### Step 1: Create an empty repository i.e one without a working tree

You can create this repository anywhere you like, I usually create it on an external hard disk. Now open your terminal and run following command:

```
git init --bare /path/to/external_hdd/remote_backup.git
```
Make sure you change the path above.

The --bare flag tells git to create a repository without a working tree because we won't be working with the files directly. We will only sync our changes with it.

### Step 2:  Add the empty repository as a remote from your project's git repo.

Add the remote_backup.git as a remote so we can push changes to it, it is just how we push changes to Github or any other git service you use.

```
git remote add backup /path/to/external_hdd/remote_backup.git
```
Great, you can check by running following command that the remote was added correctly:

```
git remote -v
```

### Step 3: Push your changes to the empty repository

```
git push backup master
```
I'm pushing master branch here, you can push changes from any branch, just like how you would push changes to Github.

#### That's it!

Whenever you make changes, push to both repositories.

I hope this tip comes in handy, especially to beginners who are starting out. I remember when I first started using git in a professional setting few years ago, I was afraid of making mistakes, but making mistakes is the first step in mastering something. All the best!
Magrittr R in VScode
Tags: rprogramming, vscode, keybindings, magrittr
Published: 2021-01-11 22:42:57

# Hi!
Using Magrittr in your R script is very useful. If you use them frequently and your IDE is Vscode, you're in luck!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lggzei7pdupdzvvqn5nu.png)
## Step by step :
1. Execute the following key combination
"Ctrl + K Ctrl + S"
2. In the upper right corner enter "Open Keyboards Shortcuts (JSON)"
3. Copy the code
4. Done!

## Link:
https://gitlab.com/-/snippets/2059588
Organization Strategy 2.0
Published: 2021-01-11 22:39:50

---
title: Organization Strategy 2.0
published: true
description: yes, I updated my strategy again
tags: 
//cover_image: https://direct_url_to_image.jpg
---

In this new year (2021) I'm re-thinking how I organize and process tasks due to ineffective productivity last year. I did a lot of deep thinking got stuff done, but that I wasn't enjoying it along the way and the results were not where I wanted them to be.

The solve for both of these issues lies in being part of a team vs working solo - because the nature of the work is building community and team. So far I've been building a community of 1.

To recap my previous organization:

* Things 3 uses Areas, projects, and tasks
* Areas are Work, Upkeep, and Meta
* Work is active projects
* Upkeep is projects that will never end
* Meta is organizing and refining tools and processes

After thinking through exactly where my time was going and why I was less effective I found I'd been putting a ton of time into personal growth, learning, development, etc. And a reasonable amount of time into meta. But needed to be hard prioritizing non-growth related projects first to see the implementation results of all the thinking and growing.

So I started by taking some notes thinking through the categories of where I want my time to go. I found I could put everything into these buckets:

* Work
* Growth
* Hobbies
* Fun
* Family

While there is some grey area between these, they give a good structure to deciding what I should be doing at any moment. I won't go into it here but it also helped to write down how each of these interact with each other because they ALL do.

So without further adieu... my new things3 areas are:

* Work
* Work Upkeep
* Growth
* Growth Upkeep
* Meta

This lets me to prioritize and keep focus primarily on what drives direct results.

Now, to fill the work bucket, I needed to get the team and my PM involved so I was not working on side projects but rather working with the team to a common goal. I'm now setting out to merge any work I was doing with the team's roadmap and picking up work from the team backlog. I'm already feeling 1000x better about working with the team rather than beside the team and the quality of the work has also gone way up.

Final note, I've also had these Areas in the background that didn't change:

* Lists and ideas
* Project Queue
* Archive (won't do)
* Archive (done)
When quitting is ok
Tags: reactnative, react
Published: 2021-01-11 22:38:32

I recently finished a month-long project I had been working on.  The project was to create an Instagram clone in order to put into practice the knowledge I had gained so far in the React framework.  It seemed instantly intimidating and basically impossible but I kept hope.  I had help from friends and mentors and finally completed it.  

I started this project amidst learning React's basics and working on practice problems.  These problems consisted of created basic components that would render a basic button and create a simple function once the button was pressed.  The last one I was working on was called roulette gun.  Roulette gun rendered a statement inviting you to play by pressing the button.  Once the button was pressed, a method would be activated in which the new statement now said, "spinning the chamber and pulling the trigger...".  The component took in a prop with the number 8 so when the button was pressed there was also a random number generated from 1-8.  If the randomly generated number equaled the given prop number then the statement will now read "BANG!!!!" otherwise it will display "you're safe!".

I couldn't understand exactly how to make this all work at first so I quit.  I quit the problem and started on a new endeavor which was creating a clone of Instagram.  Trust me I know that seems sort of backward but, I must say that it was the best decision I made.  I spent a month sort of pulling my hair on how to figure things out.  If it wasn't for my mentor, and friends and the results I was seeing while completing the project piece by piece (Bootstrap helped a lot as well) I would have probably given up on it as well.

While figuring things out I could notice myself understanding the flow of the code a bit more each time.  Once I completed the clone, my confidence grew as well.  I went back to the roulette gun problem and, with the new gained knowledge and confidence, I was able to see where I was going wrong, correct it and add a whole conditional for what happens when the button is pressed.

All this to say that sometimes it is ok to quit on something like a personal project.  Take some time, gain new knowledge or develop what's already there, and then come back to it and pull that trigger.
A Quick Developer's Guide To Avoiding Repetitive Strain Injuries
Tags: discuss, devjournal, health, codenewbie
Published: 2021-01-11 22:33:18

[RSI](https://www.nhs.uk/conditions/repetitive-strain-injury-rsi/), or repetitive strain injury, is a real risk if you spend hours a week coding. They're caused by remaining in a fixed position, or making the same motion, for long periods. I wrote down some tips to help you (and me) avoid them. 


- Get a standing desk. You can [go fancy](https://www.homedepot.com/pep/Mind-Reader-2-Tier-Adjustable-Sit-and-Stand-Rolling-Desk-White-SDROLL-WHT/303136946?source=shoppingads&locale=en-US&mtc=Shopping-BA-F_HDH-G-D59-59_34_INTERIOR_FURNITURE-MULTI-NA-Feed-PLA-NA-NA-Home_Office_Target_ROAS_experiment&cm_mmc=Shopping-BA-F_HDH-G-D59-59_34_INTERIOR_FURNITURE-MULTI-NA-Feed-PLA-NA-NA-Home_Office_Target_ROAS_experiment-71700000077185891-58700006543731730-92700059189584867&gclid=CjwKCAiAi_D_BRApEiwASslbJ5CTZbuX0o4B9i2LMfoEqhCzURLtYiollC5CRTeqIeN5dN3S2u4LYhoCmh4QAvD_BwE&gclsrc=aw.ds) and get a whole new desk, [get a converter](https://smile.amazon.com/Adjustable-Ergonomic-Aluminum-Portable-Computer/dp/B07B9MHT4V/ref=sr_1_3_sspa?crid=3HHK03EYBQWNW&dchild=1&keywords=standing+desk+converter+for+laptop&qid=1610403233&sprefix=standing+desk+%2Caps%2C240&sr=8-3-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEzQUc2V1JYSzRaNjZDJmVuY3J5cHRlZElkPUEwNzI1ODA5MjdGUEpYNFc4UzNKNiZlbmNyeXB0ZWRBZElkPUEwODQzNTk5MUZBNlU1QjhNSEZIViZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=) for your existing desk, or if you're like me and you don't have a desk, nail a shelf into a wall. 

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

- Now that you're standing, you can also get one of those squishy kitchen mats for your feet. 

- I'm reading this heartwarming book called [Sourdough by Robin Sloan] (https://www.robinsloan.com/books/sourdough/). The main character is a programmer named Lois who uses a [drawing tablet](https://officeorbiter.com/drawing-tablet/#:~:text=If%20you%20are%20unfamiliar%20with,tool%20instead%20of%20a%20mouse.&text=The%20main%20purpose%20of%20a,strokes%20directly%20into%20the%20computer.) instead of a mouse to stay healthy. This looks like a great idea to me-- it would take me a lot of courage to learn how to navigate with it but I feel like the benefits could be huge.

- Do exercises for avoiding carpal tunnel syndrome. [Yoga with Adriene](https://www.youtube.com/watch?v=gb3_oSAGoXs) has a classic guide. (Doing yoga at the end of the day is great for your posture and avoiding RSIs in general.)

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

- Take breaks! The thing about repetitive strain injuries is that they're repetitive. Take a break and get active frequently to avoid hurting yourself by remaining in the same posture for too long.

What are your tips for maintaining postural health during the day?
Snippets RMarkdown templates in VScode
Tags: snippets, rprogramming, vscode, latex
Published: 2021-01-11 22:23:42

Hello!
I use R in VScode and using Snippets for my R Markdwon templates makes my time really fast. This is why I decided to share them with you.
https://gitlab.com/-/snippets/2059664
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sz54trt083pa22hk4kga.png)
React Flexible Lists
Tags: programming, codenewbie, javascript, tutorial
Published: 2021-01-11 22:22:36

###### *This article is sponsored by [Fiverr](http://www.fiverr.com/s2/fa85266916) - Freelance to get extra income or become a full-time freelancer.*

This article is pending... Check out my other React articles above.

**Happy Coding!!!**

<a href="https://www.buymeacoffee.com/bellotech" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a> 

{% user bello %}
#### Techstack | Fiverr
Techstack article, sponsored by Fiverr.
- Connect to freelancers with proven business experience.
- Get matched with the perfect talent by a customer service manager.
- Freelance to get extra income or become a full-time freelancer.

[Sign up](http://www.fiverr.com/s2/fa85266916) to find the perfect freelance services for your business or become a freelancer.

{% youtube EkPDLVqKkLc %}

[Support](https://dashboard.flutterwave.com/donate/3lo9klliqwbu) what I do and push me to keep making free content.
How to setup your Typescript server in three steps
Tags: server, typescript, javascript
Published: 2021-01-11 21:45:23

In three simple steps, I will show you how to set up your server.

## Steps

1. Create a folder called 'typescript-server'
2. Create <code>src</code> folder inside 'typescript-server' and create index.ts file.
3. cd into the typescript-server folder and initialize your project by running;

Before we go on please add the following code we will be testing on into the index.ts file

```
console.log("Hello, Dev.to");
```

So that anytime we run our code we will be seeing some output on the console.
 
```
npm init -y

```
the above code will create a package.json file that will hold all your dependencies for the project.

4. install the needed dependencies:

```
yarn add -D @types/node

yarn add -D typescript

yarn add -D ts-node

yarn add -D nodemon

```
or you install all of them once

```
yarn add -D @types/node typescript ts-node nodemon
```

5. Create the ts config by running;

```
npx tsconfig.json
```
at the terminal, some options will pop up asking you to select which platform are you using, select node.

6. open your package.json file and add the following code under the script tag

```
"watch": "tsc -w",
```
then your package.json will look like this
```
{
  "name": "lireddit-server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "watch": "tsc -w",
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/node": "^14.14.20",
    "nodemon": "^2.0.7",
    "ts-node": "^9.1.1",
    "typescript": "^4.1.3"
  }
}

```

to test if what we have done so far is correct, now run the app with <code>yarn watch</code>. Note, you must have npm, and yarn install in your system to avoid any complexity.

### To use the Installed nodemon

you need to add another line onto your script section in the package.json file. Now add the follow to your package.json file;

```
"dev": "nodemon dist/index.js",
```

I know you will be wondering where do we have the <code>dist/index.js</code> from, don't worry about it. when you run the yarn watch, it compiles and generates a <code>dist/index.js</code> file.

For us to have all the different ways of running our project, I will just go ahead and add all the run scripts for you. after adding all the run script, this is how your package.json will look like now.

```
{
  "name": "lireddit-server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "watch": "tsc -w",
    "dev": "nodemon dist/index.js",
    "devIn": "nodemon --exec ts-node src/index.ts",
    "start": "node dist/index.js",
    "startIn": "ts-node src/index.ts"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/node": "^14.14.20",
    "nodemon": "^2.0.7",
    "ts-node": "^9.1.1",
    "typescript": "^4.1.3"
  }
}

```

You can now run your app using the following commands;

```
yarn watch

yarn dev

yarn devIn

yarn start

yarn startIn
```  

Thank you for reading this little piece of my typescript set up!
Youtube Resume Review #2: Value-Based Experience
Tags: career, beginners, resume, video
Published: 2021-01-11 21:38:36

---
title: Youtube Resume Review #2: Value-Based Experience
published: true
description: 
tags: career, beginner, resume, video
cover_image: https://img.youtube.com/vi/-hHesPlEzTk/sddefault.jpg
---

{% youtube -hHesPlEzTk %}

Last week I published my first ever Youtube Video where I review developer's resumes and provide feedback. Thanks again for the dev.to members who got the ball rolling.

Here's the second in the series (With more queued up!).

This resume has fantastic content, and in particular, I want to point out the experience section. The stuff they have there is going to get interviews. Many of the bullet items listed are talking about the results they had.

Results get interviews!

Think about it this way, you're a developer applying for a developer job. How interesting is it to list things like you wrote code, designed software, etc? Those are the activities every developer does. So, you need to talk about something else. How did you lead to some new results, grow the business, improve the team?

This resume has it in spades. Unfortunately, the formatting is dense and a little bit of a turn-off, but hey that's an easy fix!

If you want me to review your resume, reach out to me (Email is in my profile).
Dedicated test databases with Laravel Sail
Tags: laravel, php, sail
Published: 2021-01-12 21:58:50

---
title: Dedicated test databases with Laravel Sail
published: true
date: 2021-01-11 21:36:20 UTC
tags: laravel, php, sail
canonical_url: https://michaelheap.com/laravel-sail-test-database/
---

I’ve been playing around with [Laravel Sail](https://laravel.com/docs/8.x/sail) on a project that I’ve just started and wanted to be able to run my tests on a separate database and leave my main DB intact for development.

Adding a second database for tests involves adding a second container and configuring your tests to point at the newly created host.

Add the following to `docker-compose.yml` under the `services:` key:

```
mysql_test:
  image: "mysql:8.0"
  environment:
    MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
    MYSQL_DATABASE: "${DB_DATABASE}"
    MYSQL_USER: "${DB_USERNAME}"
    MYSQL_PASSWORD: "${DB_PASSWORD}"
    MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
  networks:
    - sail
```

Next, configure your `.env.testing` file to point at the `mysql_test` host (Docker Compose uses the service name as the host name for networking):

```
# Don't forget to set APP_KEY too
DB_HOST=mysql_test # This is the important bit
DB_DATABASE=
DB_USERNAME=root
```

Then finally, run your tests:

```
./vendor/bin/sail test
```
Why I love programming
Tags: story, personal
Published: 2020-12-22 21:44:53

---
title: Why I love programming
published: true
tags: story, personal
---

I am now for 16 years in this industry. And still I become exited about new technologies and there possibilities.
I like to have the chance to program everything what comes in my mind.

I have a boring workflow? I can write a script for this.
I want to scan a qr code to prepare my groceries and prepping the week? I have a script for that. 
The current look of my media center is not on point of my taste? I can change how I want it, or writing one from scratch. 
I want to build my custom keyboard? Considered as done. 

And with every small script, or every time I "just play" I am learning new stuff or even new languages.

I started with rust, because of curiosity, and start to work on a media center based on mpv.
On the way, I learn rust with real problems to solve. How to do Frontend, how to manage Backend. Writing to a database and on a socket to use mpv. Scanning the directories for Content, and ask third-party APIs to get movie informations and some other bits and bytes to solve my problems, or my feature list.

Today I played around with python and speech-recognition and hacking something together to have an alexa "clone". 

I wrote a tool for smoke testing our solutions also in rust. This contains writing on a message queue, and getting the logs from the remote server, where the solutions is deployed. Of course in that manner, that I just can copy and paste the outcome to jira. Now when I am thinking of, my next task will be that the smoke tester will do the comment as well (yeah I am lazy af and hate jira). 

I am using awesome wm. You can literally program every aspect and not only related to the look and feel. Its written in Lua. I write lots of smaller things in bash.

The power of coding in general is, to make my life easier when I am sitting at my pc. I really enjoy the process of fiddling stuff out, learn new languages or get a peak in side a new technology. To solve complex problems and provide a program for that in the best way possible, is pure excitement for me. 

I hope that I will never lose that joy and my curiosity for my profession. I am really in the lucky position, that my hobby is my job.
How do I remove a TAB from text that is pasted in from the clipboard?
Published: 2021-01-11 21:12:37

I think I am failing on my regular expression, the best I can tell.

        $(document).ready(function() {
          $('input').bind('paste', function() {
            setTimeout(function() {
              var obj = ('input').val();
              var text = obj.replace('^[a-zA-Z0-9\\-\\s]+$', ' ');
              $('input').val(text);
            });
          });
        });

I have made a fiddle here:

https://jsfiddle.net/jp2code/5enmojb2/20/
Revisiting The S in SOLID
Tags: discuss, oop, productivity, programming
Published: 2021-01-11 21:09:32

to start with, this is how I understood it. If you want to add something to it, feel free to contact me. I would be happy :).

#WHAT IS SOLID?

__Single Responsibility (S)__
__Open/Closed (O)__
__Liskov Substitution (L)__
__Interface Segregation (I)__
__Dependency inversion (D)__

SOLID principles were first defined by Robert C. Martin in his book Design Principles and Design Patterns. Then the acronym SOLID was introduced by Michael Feathers.

Martin’s and Feathers’ design principles encourage us to create more maintainable, understandable, and flexible software.
But today we will be talking about the Single Responsibility Principle.

##The problem that they address :

The main problem that they tackle is working with legacy code.
But wait for a second, what is the problem with legacy code?

Here you go :
1. Re-reading code multiple times to get the part you need to change
2. Hard to understand what a method does
*(Big giant methods that do everything )
*(or weird old names that do not refer to the logic of the method anymore)

With the legacy code, we spend more time reading than writing code

Simply:

It is most of the time bad code. And what leads to that?
###The strategy that many of the startups adapt:
1. Constantly adding new features
2. No formal process
3. No time to worry about code structure ( daily releases, very dynamic)

And like uncle Bob says: Bad code slows us down, we want to be quick right, but not quick in a sloppy way.

A developer should behave like a surgeon, steady, confident but have the deadline in mind.

#Single Responsibility Principle:

####“A class should have one, and only one reason to change”

In other words, don’t put functions that change for different reasons in the same class.

We want to create small classes with very specific names that are responsible for only one thing.

Example: We have a car that has model, speed and interior components as properties.

Our class would look like this:
![Car Class](https://dev-to-uploads.s3.amazonaws.com/i/etdckxk5rkyp7nkevod2.PNG)

And let’s suppose we want to print out the properties:
![Output Class](https://dev-to-uploads.s3.amazonaws.com/i/y23hcebilejm9hkq90vw.PNG)

Notice here we don’t want to declare the printer methods inside the car class, but that would violate our principle.

The Car class shouldn’t change because we want to output the text to some domain.com but only because the properties of the car changed.

Benefits: Easier Testing, fewer dependencies

#Sources :
Meyer, B. (1997): Object-Oriented Software Construction, 2nd edition
http://www.cvc.uab.es/shared/teach/a21291/temes/object_oriented_design/materials_adicionals/principles_and_patterns.pdf
Robert C. Martin “Principles of OOD”
https://www.youtube.com/watch?v=zHiWqnTWsn4&t=2707s
https://www.youtube.com/watch?v=rtmFCcjEgEw
https://www.baeldung.com/solid-principles