teleren/devto huggingface dataset:
Asking For Help
Tags: brainhack, adiecon, career, fear
Published: 2020-02-02 03:50:12

---
title: Asking For Help
published: true
description: Hack Your Brain to be a Better Developer Series
tags: brainhack, adiecon, career, fear, 
---
*This is part 1 of [Hack Your Brain to be a Better Developer](https://dev.to/lgranger/hack-your-brain-to-be-a-better-developer-with-science-1np8), my talk from AdieCon 2020.*

You’re so stuck on this ticket, and need to ask for help, but you’re been working on this ticket for far to long, should have asked that senior dev for help days ago.
Imagine starting to stand up to go talk to that person. How does that feel in your body? Stomach? Shoulders? For me this is a tightness in the middle of my chest.
Suddenly you realize that there’s one more thing you could try, one more thing to search the internet for, and you sit back down.
How does that feel in your body? Stomach? Shoulders?
Good, better, right?

*Bad News friends. Avoiding asking for help is increasing your fear of asking for help.*

Studies have shown that people with lower back injury who cope with pain, that is they tolerate some pain while recovering or doing physical therapy, [recover quicker and have less long-term pain](https://insights.ovid.com/spine/spne/2003/12/010/effect-fear-avoidance-based-physical-therapy/2/00007632) than people who avoid pain. 
In medicine this is called [Fear-Avoidance](https://link.springer.com/article/10.1007%2Fs10865-006-9085-0), in psychology it’s called [Avoidance Coping](https://emilykarpinski.blog/the-fear-avoidance-feedback-loop/).

So the question is, how do we avoid avoiding?

1. Knowledge is Power - knowing that avoiding will make it worse is often enough to help us do what we need to do. "This is no fun, but I don’t want to see what happens if it gets worse."
2. Get comfortable being uncomfortable - take the time to just sit with and really feel your discomfort. When you’ve sat with a feeling before it’s still uncomfortable, but now you know it won’t kill you.
3. Lower the Barrier - acknowledge that you will avoid at some point, saying you’ll never do this again isn’t realistic. What can you do to make it easier to ask *after* you’ve avoided?

My trick for lowering the barrier is to write out my question, and then leave in the text box of the DM or chat room where I should be asking the question. I hit send yet though - this is where I let my self avoid. I set a timer for a short but reasonable amount of time, 5 to 15 minutes. When the timer goes off, I flip over to the DM or chat room and press send. I don't re-read what I wrote, just hit send. It’s scary, but it’s worth it, and now the question has been asked!
Best icon & desktop themes for Linux distros 🤔, share your favs 🤓
Tags: discuss, opensource, linux
Published: 2020-02-02 03:40:28

I've been using MacOS icons and theme in XFCE desktop environment for a long time.

Theme:
https://www.xfce-look.org/p/1275087/
Icon:
https://www.xfce-look.org/s/XFCE/p/1305429

I also use QOGIR theme for icons and theme.

What's your favorite ?????? 🤔
How to write a recursive function
Tags: recursion
Published: 2020-02-02 03:09:01

## What is recursion/recursive function?

Simply put, a recursive function is a function that calls itself during execution. 

## When and why will you need this? 

There are problems in programming that may be easier solved through recursion rather than iteration, so you may end up using it as a solution. There's a greater space requirement for recursion, but it is simpler to write and easier to read. Some problems are also inherently recursive and it is preferred to use a recursive solution.

## The code

Recursion helps to solve smaller instances of a problem. In this problem, we are asked to push a number *n* times into an array and return it.        

The first thing we need to figure out is the base case/base condition, which is the condition that stops the function from calling itself otherwise the function will loop infinitely and cause a stack overflow. 

[![Image from Gyazo](https://i.gyazo.com/add1fdb697d2c1a94d273408bf4d3d99.png)](https://gyazo.com/add1fdb697d2c1a94d273408bf4d3d99)

In the first call, *result* is set to an empty array by default. It will check the if statement to see if the *result* length is the same as the *times* argument. 

Now we have to add the block that will put us closer to our base case. 

[![Image from Gyazo](https://i.gyazo.com/28482a4837af8de314af0528c7584665.png)](https://gyazo.com/28482a4837af8de314af0528c7584665)


This function will only run once, but we need it to continue calling itself until an execution of the function reaches the base case.  

[![Image from Gyazo](https://i.gyazo.com/7c2a88eff3a6c25e714b8ba9e2105017.png)](https://gyazo.com/7c2a88eff3a6c25e714b8ba9e2105017)

Now the function will call itself until the base case is called. But we are missing one thing here. As it stands, the last call will return the value to the second-to-last call due to the else block. But, the else block does not return the value of that call. The last call will break the loop and return it to the previous call stack, but will not return anything. Here's the fix:


[![Image from Gyazo](https://i.gyazo.com/2ccae4931701ea24a3e8147bb908d197.png)](https://gyazo.com/2ccae4931701ea24a3e8147bb908d197)

This will allow the return value of the last stack to be passed up to the second-to-last, and so on, until it reaches the first stack, which is then returned to the console. 


[![Image from Gyazo](https://i.gyazo.com/bbb04c7e5db425dc20006b4359587111.png)](https://gyazo.com/bbb04c7e5db425dc20006b4359587111)


So there you have it! Give it some practice, play around with it, and the mystery of recursion will unfold itself to you, over and over and over...
Day 8 of 100 Days Of Game Dev - Why is my 2DCamera node not working?
Tags: gamedev
Published: 2020-02-02 03:07:12

That is literally a question that has been bugging me during my game dev session.

Before I added the enemies, my 2DCamera node works properly.

But as soon as I added the enemies, the camera node doesn't work properly for some reason.

Maybe it is something with the script that I wrote for the enemy.

Anyways, here is also the whole video of my game dev session.

{% youtube lpkf1_PbsHg %}
Choose between wget.blog or [myName].[TLD] for personal blog
Tags: help, discuss
Published: 2020-02-02 02:07:59

I am currently using https://www.wget.blog as the domain name. I am planning to write more regularly. I want to focus on react, redux, gatsby, Java and SQL related contents. What do you think? Should I stick to wget.blog or should I buy [myName].[TLD] type of domain?
algodeck on github
Tags: algorithms, interviewing
Published: 2020-02-02 01:45:04

---
title: algodeck on github
published: true
description: 
tags: algorithm,interviewing
---

[Here](https://github.com/teivah/algodeck) is a nice collection of algorithms. Collected and organized with an interview in mind.

I interview programmers/techies regularly and I never really ask these types of questions.

That said it is good knowledge to have in case you ever interview with some besides me. :)
Flexibility and Boundaries in a Business Environment
Tags: career, productivity
Published: 2020-02-02 01:39:34

Remote work is becoming more and more common with the advent of technologies that enables remote work like the Internet, video conferencing, and other things.

Therefore, companies are moving towards having more flexible environments that benefit both employers and employees alike.

Microsoft Japan has rolled out a trial of a 4 day work week and they found that productivity jumped by 40%.

This is a big increase. People are more well-rested and so they work faster and make fewer mistakes.

They closed offices on Fridays to give their employees more rest.

Meetings are timeboxed to between 30 and 60 minutes. They are also small as they're capped at 5 people.

Employees are encouraged to collaborate on the Internet via emails, chat rooms and video conferencing.

These are all things that introduced efficiency to the system to increase the output of the teams.

PwC also encourages flexible work by letting employees shift to flexible schedules and remote work.

They let employees work in a schedule that's best for them./

Everyone is still learning. They showed that they cared about their employees and as a result, their employees are happier.

It's no longer just employers dictating what they want employees to do. Now employees are also being listened to by companies so they're happy and are willing to put their best foot forward.

Flexibility shows that employers care about their employees and therefore it's very useful for attracting the best talent. Otherwise, the best won't leave their jobs or will leave to find a better employer.
Remover a data da URL/Links permanentes e redirecionar no WordPress
Tags: tech, apache, seo, wordpress
Published: 2020-02-02 02:10:36

---
title: Remover a data da URL/Links permanentes e redirecionar no WordPress
published: true
date: 2020-02-02 00:51:11 UTC
tags: Tech,apache,seo,wordpress
canonical_url: https://marquesfernandes.com/remover-a-data-da-url-links-permanentes-e-redirecionar-no-wordpress/
---

Se você possui um blog em [WordPress](https://br.wordpress.org/), provavelmente já notou que sua URL vem no formato `/ano/mes/dia/url-do-post`. Esse formato cria links mais longos, e essa marcação de data pode ser prejudicial para o seu site, muitos usuários olham para o link e selecionam o site com o conteúdo mais recente, então mesmo se você mantém seus posts atualizados isso pode causar um impacto no alcance de seus artigos.

Nesse artigo vamos aprender como configurar o WordPress para usar um formato de url mais simples e a redirecionar os posts já indexados ou compartilhados para o novo formato usando o `.htaccess`.

## Configurando os links permanentes no WordPress

Entre no painel administrativo do seu WordPress e troque para o formato desejado, nesse artigo vamos usar o formato simples, apenas com o nome do post na URL:

`/%postname%/`

![Configurando os links permanentes no WordPress](https://marquesfernandes.com/wp-content/uploads/2020/02/image-7-1024x501.png)

## Redirecionando os links antigos usando o mod\_rewrite no .htaccess

Agora vamos adicionar uma pequena configuração em nosso **.htaccess** (Ele está localizado na raiz da sua instalação de WordPress).

`RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]`

Seu arquivo deve ficar parecido:

```
<IfModule mod\_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^([0-9]+)/([0-9]+)/(.\*)$ /$3 [R=301,NC,L]RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST\_FILENAME} !-fRewriteCond %{REQUEST\_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>
```

**Dica:** Se você usa alguma extensão de otimização de SEO, performance ou de redirecionamento no WordPress, muito provável seu arquivo é muito maior que o do exemplo acima, lembre-se de colocar a linha logo no começo do arquivo para o redirecionamento funcionar.

Teste algumas URLs antigas e veja se seu redirecionamento está funcionando corretamente, para monitorar possíveis erros de 404 confira o artigo: [Como monitorar erros 404 e páginas não encontradas no Google Analytics](https://marquesfernandes.com/como-monitorar-erros-404-e-paginas-nao-encontradas-no-google-analytics/)

O post [Remover a data da URL/Links permanentes e redirecionar no WordPress](https://marquesfernandes.com/remover-a-data-da-url-links-permanentes-e-redirecionar-no-wordpress/) apareceu primeiro em [Henrique Marques Fernandes](https://marquesfernandes.com).
Maintenance pages in NGINX without reload
Tags: nginx
Published: 2020-02-02 00:00:00

---
title: Maintenance pages in NGINX without reload
date: "2020-02-02T00:00:00.000Z"
tags: ["nginx"]
---

Configuring a maintenance page in NGINX is quite straightforward and, if configured correctly, allows for live toggling on and off without requiring the NGINX instance to be reloaded or restarted.

~~~nginx
location / {
	# Check for the existence of an enabled maintenance page
	if (-f {PATH}/{TO}/maintenance-page/index-on.html) {
  	return 503;
	}

	# Include the rest of this location's configuration as normal
}

location /maintenance-page {
  root {PATH}/{TO}/{MAINTENANCE_PAGE_PARENT_FOLDER};
}

# Serve out the maintenance page for 503, 504 errors.
error_page 503 504 /maintenance-page/index-on.html;
~~~

For each inbound request matched by this location, NGINX will check for the existence of an `index-on.html` page - if found, it will be served with an `HTTP 503` status code.

To toggle the maintenance page on or off, _simply rename the maintenance page_:

~~~bash
cd {PATH}/{TO}/maintenance-page
mv index-off.html index-on.html
~~~

~~~bash
cd {PATH}/{TO}/maintenance-page
mv index-on.html index-off.html
~~~
Upgrade bootstrap and jquery in ASP.NET Core 3.1 with libman
Tags: dotnet, libman, bootstrap, jquery
Published: 2020-02-02 17:35:09

---
title: Upgrade bootstrap and jquery in ASP.NET Core 3.1 with libman
published: true
date: 2020-02-02 00:00:00 UTC
tags: dotnet,libman, bootstrap, jquery
canonical_url: https://solrevdev.com/2020/02/02/upgrade-bootstrap-and-jquery-in-aspnet-core-31-with-libman.html
---

Building server-rendered HTML websites is a nice experience these days with ASP.NET Core. 

The new [Razor Pages](https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-3.1) paradigm is a wonderful addition and improvement over MVC in that it tends to keep all your feature logic grouped rather than having your logic split over many folders.

The standard `dotnet new` template does a good job of giving you what you need to get started. 

It bundles in bootstrap and jquery for you which is great but it's not obvious how you manage to add new client-side dependencies or indeed how to upgrade existing ones such as bootstrap and jquery.

In the dark old days, Bower used to be the recommended way but that has since been [depreacted](https://devblogs.microsoft.com/aspnet/what-happened-to-bower/) in favour of a new tool called [LibMan](https://docs.microsoft.com/en-us/aspnet/core/client-side/libman/?view=aspnetcore-3.1).

![LibMan](https://i.imgur.com/JoaMpl0.png "LibMan")

LibMan is like most things from Microsoft these days [open source](https://github.com/aspnet/LibraryManager).

Designed as a replacement for Bower and npm, LibMan helps to find and fetch client-side libraries from most external sources or any file system library catalogue.

There are tutorials for how to [use LibMan with ASP.NET Core in Visual Studio](https://docs.microsoft.com/en-us/aspnet/core/client-side/libman/libman-vs?view=aspnetcore-3.1) and to [use the LibMan CLI with ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/client-side/libman/libman-cli?view=aspnetcore-3.1).

The magic is done via a file in your project root called `libman.json` which describes what files, from where and to where they need to go basically.

I needed to upgrade the version of jquery and bootstrap in a new `dotnet new` project so here is the libman.json file that will replace bootstrap and jquery bundled with ASP.NET Core with the latest versions.

{% gist https://gist.github.com/solrevdev/59023acd7cce43f96ae2a3b9da826a8b %}

I was using Visual Studio at the time and this will manage this for you but if like me who mostly codes in Visual Studio Code on macOS or Linux then you can achieve the same result by installing and using the [LibMan Cli](https://docs.microsoft.com/en-us/aspnet/core/client-side/libman/libman-cli?view=aspnetcore-3.1).

Success 🎉
Ember {{on}} vs {{action}} caveat
Tags: ember, javascript
Published: 2020-02-01 22:48:05

Today I learned one important difference between the traditional way of invoking actions in Ember via an `action` helper:

```hbs
<button {{action "submit"}}>
  Click me!
</button>
```

And via the new `on` element modifier:

```hbs
<button {{on "click" this.submit}}>
  Click me!
</button>
```

The subtle, yet important thing is that [`action` helper](https://guides.emberjs.com/v3.4.0/templates/actions/#toc_allowing-default-browser-action) **prevents** default browser action, but [`on` element modifier](https://guides.emberjs.com/release/components/component-state-and-actions/) **does not**.

Why is this important? If you'd have the buttons from the example above inside a `<form>` tag, then the first button will work as expected (action will be triggered), but second button will cause an unexpected full page reload on click.

## Ways to fix

Two easy fixes come to my mind:

Either you can change the type of the `button` so that it does not trigger a submit:

```hbs
<form>
  <button type="button" {{on "click" this.submit}}>
    Click me!
  </button>
</form>
```

Or you can use [ember-event-helpers](https://github.com/buschtoens/ember-event-helpers) addon.
Callback Functions in Javascript
Tags: javascript, beginners
Published: 2020-02-01 17:28:08

What is a callback function and why do we use them? The purpose of one is related to the asynchronous nature of Javascript and web programming. Before I dive a bit deeper, first let's go through a few examples.

Try to guess which result returns first:

```javascript

function functionOne(){
    console.log(1);
}

function functionTwo(){
    console.log(2);
}

functionOne();
functionTwo();
```

In this case, functionOne logs 1 in the console before functionTwo logs 2, in the exact order we would have anticipated.

But what happens if functionOne takes a bit longer than functionTwo? Try to guess what happens when we make functionOne wait a while before logging in the console:

```javascript
function functionOne(){
    setTimeout( function(){
        console.log(1);
      }, 500 )
}

function functionTwo(){
    console.log(2);
}

functionOne();
functionTwo();
```
And here is the result:

[![Image from Gyazo](https://i.gyazo.com/45f9ee6cd623a7e542a8715dadd0bd03.png)](https://gyazo.com/45f9ee6cd623a7e542a8715dadd0bd03)

Interesting, this time functionTwo's return came back first. But why? It's because Javascript did not wait to call the next function, it is still running functionOne in the background while also calling the next function. This makes knowing the exact order of our execution difficult. This is where a callback function comes into play. 

###What is a Callback Function?

Callback functions(also called "higher order functions") are functions that take in a function as an argument. It's a way to control the order of execution, to make sure the right functions are running at the time you need them to.  

Let's take a look at an example:

```javascript


function eatfruit(fruit,callback){
    console.log(`This is a delicious ${fruit}`);
    callback();
}

eatfruit('strawberry', function(){
    console.log('I think I would like another')
})

```

[![Image from Gyazo](https://i.gyazo.com/c3d3de8390fd6c596b17f25321f1f6f6.png)](https://gyazo.com/c3d3de8390fd6c596b17f25321f1f6f6)



When defining the eatFruit function, we pass in a function as an argument and call it after the first console.log. As expected, the console shows 'This is a delicious strawberry' before the anonymous function runs. We can(and should) dry this even more by defining the anonymous function.

```javascript

 
function eatfruit(fruit,callback){
    console.log(`This is a delicious ${fruit}`);
    callback();
}

function fruitGlutton(){
    console.log('I think I would like another')
}
eatfruit('strawberry', fruitGlutton)

```
[![Image from Gyazo](https://i.gyazo.com/a07b9b66be7abbeac54eef8e6705779e.png)](https://gyazo.com/a07b9b66be7abbeac54eef8e6705779e)


The results stayed the same with the drier code, and the order in which your functions run are more predictable.
What is your morning routine?
Tags: discuss, watercooler, productivity
Published: 2020-02-01 22:30:23

So I wanted to try and do *at least* a post a week, and I didn't have much time to prepare one this week. So I wanted to open up another discussion!

So, to any of you glorious readers stumbling upon this post, what is YOUR morning routine? Wake up and sit on reddit until you're almost late to work? Make sure you got that cup of coffee before attempting anything?  Immediately get up and get to coding? 

I personally spend a bit too long reddit before stumbling into the shower, getting ready *just* in time, and racing off to work. On the train to work, listen to some DnD podcasts and study Japanese. Right before arriving to work I make sure to get some tea or water for the day and a coffee. Upon arriving at my desk, it's off to coding right away! Who needs to check emails or read chat anyways.

Here's a few threads from the past I dug up if you're interested in reading more about routines!
[Do you have a morning routine?](https://dev.to/lukewestby/do-you-have-a-morning-routine-3j39)
[Planning My Daily Routine](https://dev.to/justinhhorner/planning-my-daily-routine-32hn)
[The Miracle of a Morning Routine](https://dev.to/_patrickgod/the-miracle-of-a-morning-routine-1eho)
Current Tech Stack
Tags: laravel, vue, inertiajs, tailwindcss
Published: 2020-02-01 22:17:44

Figured I'd start this off with a list of what I'm currently building with. I'm a full-stack dev, so I work with both client- and server-side code daily.

## Server-Side

For my server-side code I typically work with the latest version of Laravel. Occasionally I'll build something custom or use a micro-framework like Lumen, but for most things, Laravel fits the bill nicely. 

## Client-Side

For client-side I use [VueJS](https://vuejs.org) when I need a JS framework or vanilla ES-6 when I just need to write a bit. I do want to checkout [AlpineJS](https://github.com/alpinejs/alpine) for the smaller things, as it does seem to be better suited for it. With my Laravel builds, [Livewire](https://github.com/livewire/livewire) looks promising, but I haven't used it in production yet.

For years I just wrote my CSS by hand. Then Bootstrap came out and I did enjoy its ease of use, but soon tired of how similar everything started looking, so back to hand written CSS for me. But then [TailwindCSS](https://tailwindcss.com) came out, and I jumped in with both feet. I have documented my [early](https://codeburst.io/a-week-with-tailwind-b5a5970b4093) [experiences](https://medium.com/alara-creative/a-year-with-tailwind-92f420b2f8b9) with it pretty well, but it's been 2+ years and it's still part of my daily workflow. Good stuff.

## Inertia

So between Laravel & VueJS I use a package called [Inertia](https://inertiajs.com). It's hard to say if it's really a server-side or client-side, though it definitely leans more client. It allows me to use VueJS instead of Blade files, turning the site into an SPA, but without the issues that typically come with SPAs. All the backend power of Laravel, with the ease of use of Vue. Perfect. And the beauty is, it's not vendor locked, so you can use Ruby & React or whatever you like, and it'll still work. If you haven't already, definitely check it out.

That's it for now, got questions or suggestions? Hit me up!