teleren/devto huggingface dataset:
Staying in Your Lane is Hard
Tags: startup, career, leadership
Published: 2021-04-17 02:54:33

For the first few years, [Energy Ogre](https://www.energyogre.com) was fewer than ten people, and I was the only technical resource. We had contractors that came in for specialized work, but on most days, I was everything from technical support to the programmer behind all our systems. 

These were tumultuous times, not tracking when days ended and nights began, fitting in work before and after (and sometimes during) time with family. I was once in line at a roller coaster at Six Flags while spelling out a SQL query over the phone, one word at a time, to a coworker so they could type it in and hit run without understanding what it was doing. When it was our turn to get on, I told the group behind us to go on ahead because I needed another minute to finish the call. The look on my wife's face made me hang up and get on the ride because I'm not a complete idiot, but I was back on the phone the second the ride ended. It was not one of my better moments, but the website was down, and, well, someone had to fix it.

We were building something amazing, and the only thing limiting us was how fast I could make it.

We got a little bigger and brought in another programmer, and things started moving. We grew a bit more, brought in some fantastic people, and as that happened, naturally programmed less and less, opting instead to focus on the bigger picture. 
I have not been a software developer for over a decade, but when someone asks what I do for a living, I still say, “I’m a programmer.” It’s who I think I am, and it’s also something I am not likely to be again.

It’s a delicate dance between staying up to date with what's new and not putting in so much time to learn it that you fall behind on your day job. And while I can only speak to my own experience, I have seen and heard similar sentiments echoed by people in leadership positions in many other fields: I wish I had the time to do it again.

You find something you like, and you learn everything about it. You start to get good at it and get a job doing it. You do it well; well enough to move up. Move up enough to where doing it is not a good use of your time anymore. Then you look at someone else doing what you used to do, and long for that old time, maybe even give it a shot again for a little while, because staying in your lane is hard.

And so it goes.

I don’t have any advice or some lesson learned here, just a poem:

Look at that happy idiot,
He doesn’t give a damn.
I wish I were an idiot...
Well, damn, I think I am!


 

*Cover Photo by Matt Duncan on Unsplash*
El poder de la comunidad
Tags: communities, development
Published: 2021-04-17 02:09:22

Veamos la vida de un desarrollados del punto A al punto B, donde el punto A sea el sentirse el mejor desarrollador y el punto B, sentirse perdido, yo y muchos de los colegas que estamos en este mundo hemos vivido en ambos puntos.

Siempre que nos preguntan las cualidades de un desarrollador, la primera cualidad que mencionamos es, 'tolerancia a la frustración', y si, es algo que poco a poco vas desarrollando, pero cuesta mucho, quizá a algunos no tanto, pero a otros, si, soy un ejemplo de eso.

Que me ha hecho regresar al punto intermedio de mi camino, la comunidad (entiéndase como ese conjunto de personas que tienen un fin en común).

Mi comunidad son aquellos colegas con los que convivo cada día en mi trabajo (home office por el momento), y que me guían, aconsejan y retan a cada minuto, pero también son aquellas personas que, responden preguntas en facebook, aquellas que suben videos explicando por quinta vez como funciona grid, respondiendo en stackoverflow porque mi función no se ejecuta o aquellas personas que leo en esta plataforma, hablando sobre como configurar tal tecnología, como crearon un nuevo framework, hasta como crearon un sistema operativo en la web (wow), y a todos ellos les quiero agradecer, porque sin ese compromiso de compartir conocimiento por el simple hecho de hacerlo, programadores como yo o como muchos no encontraríamos la solución a horas de bloqueo y necedad o simplemente de frustración.

Les mando saludos y no dejen de hacer esa enorme y noble labor de compartir conocimiento y guiarnos!!

Cambio y fuera
Godot One Mouse Click Two Events
Tags: godot
Published: 2021-04-17 01:39:43

---
title: Godot One Mouse Click Two Events
published: true
description: 
tags: godot
//cover_image: https://direct_url_to_image.jpg
---

This is worth sharing. I was implementing a mouse click event on my game in Godot. This is the GScript code that I used:

```
func _input(event):
	if event is InputEventMouseButton:
		print("Mouse click")
```

I expected this to print once every time I click my mouse. But this code actually prints twice every time the mouse is clicked.

It turned out that there are 2 events that occur every time the mouse is clicked:
1. Event is emitted when we press down the mouse button.
2. Event is emitted when we lift our finger from the mouse button.

So, how should we alter the code to only get one event when the mouse button is clicked?

This is what I did:

```
func _input(event):
	if event is InputEventMouseButton:
		if event.pressed == true:
			print("Mouse clicked!")
```

So with this function, we only get when the mouse button is pressed.

You probably could write it like this too:

```
func _input(event):
	if event is InputEventMouseButton && event.pressed == true:
		print("Pressed")
```
Here we combined the if in a single line. I, however, prefer to have multiple ifs because I find it easier to understand it when I write multiple ifs. But hey, it's up to you and the team to decide which style you like.

I also found out that you can write it like this: 

```
func _input(event):
	if event is InputEventMouseButton && event.is_pressed():
		print("Pressed")
```

At this point of my learning, I'm not really sure what is the difference between `event.pressed == true` and `event.is_pressed()`

I'll write an entry about it when I find out the differences between the two.

Thanks for reading!
Horizon (Dark) iTerm2 theme
Published: 2021-04-17 00:58:15

If you've been searching for a Horizon (Dark) theme for iTerm2, look no further! Inspiration taken from the [Visual Studio Code theme plugin](https://horizontheme.netlify.app/). 

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

And as an added bonus, here's what your VIM could look like:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bx5fj3a9ccdwz3m110n.png)

[Download here](https://gist.github.com/hansjhoffman/9c7e29f67304e0c70cc24c12e81e2976)
React Functional vs Class Components Part 1: Props
Published: 2021-04-17 00:17:32

# The Times, They are a Changin'
If you, like me, learned React with class components doing all the lifting you may be wondering what's new with these functional components and their hooks that people are talking about? Maybe when you were learning React the curriculum you were following said to use functional components when you didn't need state or access to lifecycle methods. Now you're looking at React again and people are talking about hooks and how functional components are ***SO MUCH BETTER***. What happened?

In React 16.8, hooks were introduced. Don't worry, though, the stuff you learned about React is still true. There's no big shakeups to how class components work, though you may run into a deprecated method here and there. So don't worry, you didn't just inherit a huge technical debt on that side project you used react for a while back and want to add a feature to now.

React's bread and butter are props and state, we'll address how functional and class components deal with props in this article, then we'll address state, and finally lifecycle methods in their own posts.

## Props
Just as a refresher, when you pass props to a class component it might look like...
```
<OurComponent color={'purple'}/>
```
Good news, no change there! It doesn't matter if you're declaring a class or functional component, you pass it props the same way. 
```
class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.color}</h1>;
  }
}
```
In a class component props are handled by the constructor method from React.Component and we reference them with `this.props.color.`.

```
function OurComponent(props) {
  return <h1>Hello, {props.color}</h1>;
}

```
In a functional component, we accept props as an argument to the top level function, and can reference the color key in the props object with `props.color`.


Next week, we'll tackle state! Be excited, because we're going to meet our first functional hooks.
How to get the last accessed time of the file synchronously using Node.js?
Tags: node
Published: 2021-04-17 00:00:00

---
  title: How to get the last accessed time of the file synchronously using Node.js?
  published: true
  tags: Nodejs
  date: Sat Apr 17 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-last-access-time-of-file-synchronously-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-d20349fbb4a7baf1d1b013b6d9fcaef5.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-last-access-time-of-file-synchronously-nodejs)
  
To get the last accessed time of a file synchronously, you can use the `statSync()` method from the `fs` (filesystem) module and then use the `atime` property from the returned `stats` object in Node.js.

Let's say we have a file called `myFile.txt` in which you want to get the last access time. Here you can use the `fs.statSync()` method and pass:

- the `path` to the file as an argument.
- the method returns a `stats` object where we can use the property called `atime` to get the last access time.

**The `atime` property returns a valid `Date` object in JavaScript**

It can be done like this,

```js
// require fs module
const fs = require("fs");

// get last access time using fs.statSync() method
const stats = fs.statSync("./myFile.txt");

// get access time of the file
const accessTime = stats.atime;

console.log("File last accessed at: ", accessTime); // File last accessed at:  2021-04-30T23:53:07.633Z
```

See the above code live in [repl.it](https://replit.com/@melvin2016/get-last-accessed-time-of-file-synchronously-nodejs#index.js).

If you want to see the `Date` in a more human-readable way you can use the `Date` object methods. Let's use the `toUTCString()` method like this,

```js
// require fs module
const fs = require("fs");

// get last access time using fs.statSync() method
const stats = fs.statSync("./myFile.txt");

// get access time of the file
const accessTime = stats.atime;

console.log("File last accessed at: ", accessTime.toUTCString()); // File last accessed at: Fri, 30 Apr 2021 23:53:07 GMT
```

That's it! 😀

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

---
The Twelve-Factor App
Tags: devops, microservices, practices, stateless
Published: 2021-04-17 13:16:37

---
title: The Twelve-Factor App
published: true
date: 2021-04-17 00:00:00 UTC
tags: devops,microservices,practices,stateless
canonical_url: https://jhall.io/archive/2021/04/17/the-twelve-factor-app/
---

I was recently reminded of the concept of the Twelve-Factor App. As a methodology, I’ve read about it many times, and most of the concepts are by now second nature to me when I’m designing software and larger systems with a software-as-a-service model. If you’re not already familiar, I suggest you [read the full description](https://12factor.net/). In summary the twelve factors are:

1. **Codebase** One codebase tracked in revision control, many deploys
2. **Dependencies** Explicitly declare and isolate dependencies
3. **Config** Store config in the environment
4. **Backing services** Treat backing services as attached resources
5. **Build, release, run** Strictly separate build and run stages
6. **Processes** Execute the app as one or more stateless processes
7. **Port binding** Export services via port binding
8. **Concurrency** Scale out via the process model
9. **Disposability** Maximize robustness with fast startup and graceful shutdown
10. **Dev/prod parity** Keep development, staging, and production as similar as possible
11. **Logs** Treat logs as event streams
12. **Admin processes** Run admin/management tasks as one-off processes

* * *
If you enjoyed this message, [subscribe](https://jhall.io/daily) to _The Daily Commit_ to get future messages to your inbox.
Small Store with Vue.observable
Tags: javascript, vue, vuex, observable
Published: 2021-04-16 23:03:09

In large and medium sized projects we usually use Vuex. But what to use in small projects? Would it be necessary to install a new dependencie in such a simple project?

Vue.observable (included in Vue v2.6.0) can be a lightweight alternative to state management in smaller applications. It was thinking about it that I tried to create a solution to access this state and manipulate it in a simple way. Similar to Vuex, in this store the functions that return the value of a property that is in the state are in getters and the manipulators in mutations.

Note: When there is a need to use "actions", use Vuex.

#### createStore.js

```javascript
import Vue from 'vue'

const err01 = 'does not exist'
const err02 = 'is not function'
const err03 = 'function returning undefined'

function showErr(msg){
  const err = new Error(msg)
  console.error(err.message)
}

function createStore({ state, getters, mutations }){
  const myGetters = {}

  if(getters){
    Object.entries(getters).forEach(([key, value])=> {
      Object.defineProperty(myGetters, key, {
        get: () => {
          return typeof value !== 'function' ? 
          showErr(`${key} ${err02} (getters)`) :
          value(state) === undefined ? 
          showErr(`${key} ${err03} (getters)`) : 
          value(state)
        }
      })
    })
  }

  return {
    state: Vue.observable(state),
    getters: myGetters,
    commit(key, ...args){
      const cb = key => key == key
      !Object.keys(mutations).some(cb) ? 
      showErr(`function ${key} ${err01} (mutations)`) :
      typeof mutations[key] !== 'function' ? 
      showErr(`${key} ${err02} (mutations)`) :
      mutations[key](state, ...args)
    }
  }
}

export default createStore
```

#### store.js (importing the createStore function)

```javascript
import createStore from './createStore.js'

const store = createStore({
    state: {
      tasks: []
    },
    getters: {
      tasks(state){
        return state.tasks
      }
    },
    mutations: {
      addTask(state, payload){
        state.tasks.push(payload)
      }
    },
})

export default store
```

####Use methods in a component

```javascript
<script>
import store from "@/store";

export default {
  computed: {
    tasks() {
      return store.getters.tasks;
    },
  },
  methods: {
    addTask() {
      store.commit("addTask", this.task);
    },
  },
};
</script>
```
I know that there are some articles that deal with the subject, but I didn't like the way the problem was solved. So I decided to create my solution. This is my first article, I hope you like it. I thank everyone who read it.

Here is a demo about small store: https://github.com/davR7/small-store
Notes: Strings, Backlashes, Quotes etc.
Tags: javascript, tutorial, beginners
Published: 2021-04-16 22:47:23

####During this part of the section or at least my blog, I'll be learning and showing you about strings.
```
var myFirstName = "Randy";
var myLastName = "Rivera";
```
 I created two variables myFirstName and myLastName and assigned them values.
"Randy" is called a string literal. It's a string because it is a series of zero or more characters enclosed in single or double quotes.

####Escaping literal quotes in strings.
When you're creating a string you must start and end with a single or double quote. Although what if you need a literal quote: " or ' inside of your string?.
You can definitely use them by placing a backslash (\) in front of the quote.
```
var someStr = "My cousin said, \"Randy wants to become a programmer\".";
```
When you print this to the console you will get:
```
My cousin said, "Randy wants to become a programmer".
```
```
Code	Output
\'	 single quote
\"	 double quote
\\	 backslash
\n	 newline
\r	 carriage return
\t	 tab
\b	 word boundary
\f	 form feed
```
* Helpful chart.

####Concatenating Strings with Plus Operator
In JavaScript, when the + operator is used with a String value, it is called the concatenation operator. You can build a new string out of other strings by bringing them together.
Example:
```
var myStr = "I'm First. " + "I'm Second."
```
Note: Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you'll need to add them yourself.
The console would display the string I'm First. I'm Second.

####Constructing Strings with Variables
Sometimes you will need to build a string, Mad Libs style. By using the concatenation operator (+), you can insert one or more variables into a string you're building.
Example:
```
var myName = "Randy";
var someStr = "Hello, my name is " + ourName + ", how are you?";
```
someStr would have a value of the string Hello my name is Randy, how are you?.

####Finding the Length of a string
You can find the length of a String value by writing .length after the string variable or string literal.
For example:
we create a variable
```
var firstNameLength = 0;
var firstName = "Randy";
```
we could find out how long the string Randy is by using the firstName.length property. Let's  count the number of characters in the FirstName variable and assign it to firstNameLength.
```
firstNameLength = firstName.length;
console.log(firstName.length) // 5
```
New friend
Published: 2021-04-16 21:00:38

I came across this post whilst scrolling through my new followers (very rewarding thing to do btw)

{% post https://dev.to/raeclaude/new-friend-1mei %}

It triggered me😊 Let's help a comedian out and give this post some love, and perhaps some funny comments 😅 I'm sure a comedian can appreciate something like that.
Inventory Tracker 
Tags: javascript, railsapi
Published: 2021-04-16 21:24:01

Making a project...

I made an Inventory tracker with a JavaScript, HTML, and CSS frontend; and a Ruby on Rails JSON API on the backend. 

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

For now the Inventory Tracker has four departments to choose from Lawn and Garden, Electronics, Grocery, and Housewares. In the future the user will be able to add and modify the different departments. You are able to add new products and remove them, modifying them is a feature coming soon.

The frontend uses the backend to alter the elements on the DOM. It does this by utilizing AJAX and javascript to make fetch requests to the rails backend to access the database containing our information.

While creating this project we also learned about CORS. CORS is the mechanism that provides browsers a way to request remote URLs only when they have permission and allows servers to reject requests from unknown origins.
Рефакторинг React.FC компонентов
Published: 2021-04-16 21:21:00

хуки: существуют*
разрабочики: аааааа это тоже самое что и раньше, только не class а function и опускаем this

Иногда мне кажется что именно так, плюс-минус, некоторые разработчики видят использование хуков, но они упускают САМОЕ ВАЖНОЕ ДОСТОИНСТВО хуков: возможность написание компонента в декларативном стиле!

Благодаря хукам вы можете разделить компонент на три части:
1. Переменные
2. JSX
3. Логика

ДО
![Screenshot 2021-04-17 at 00.51.19](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e1thwalp1ftjri56b2yu.png)
 
ПОСЛЕ:
![Screenshot 2021-04-17 at 00.50.43](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wt276kemql2on6lo2cn3.png)

### useEffect заиграл новыми красками
 ![Screenshot 2021-04-18 at 20.13.52](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tfmp2rzajiessu9eq9t.png)

Вау! Можно легко прочитать какие события происходят при изменении каких данных.

### Сортировка функций и быстрый поиск нужной
Так как у вас логика теперь находится в одном месте, вы с командой можете обкашлить в каком порядке будут выстраиваться функции, например:
1. Функции для useEffect
2. Функции для useMemo
3. Функции для построения данных
4. Прочие


### Const vs function
Тяжело читать код когда пишут не функцию, а const и в нее сохраняют стрелочную функцию! Из-за этого взглядом приходится прослеживать, а не map ли это? Значит это будет не переменная с функцией, а переменная с данными!
Notes; JavaScript Algorithms and Data structure.
Tags: javascript, beginners
Published: 2021-04-16 21:09:04

It was time to start working on adding or subtracting(dividing, multiplying and so forth) numbers in JavaScript.
## Whether it be adding.
```
 myVar = 5 + 10; // assigned 15
```
## Subtracting.
```
myVar = 12 - 6; // assigned 6
```
##Multiplying.
```
myVar = 13 * 13; // assigned 169
```
##Dividing.
```
myVar = 16 / 2; assigned 8.
```
After completing some challenges I went ahead and started working understanding Uninitialized variables, Initializing variables with the assignment operator, Case sensitivity in Variables.

##NOTES:
####You can initialize a variable to a initial value in the same line as it is declared as followed:
```
   * var myVar = 0;
```
   * variable called myVar and assigns it to a initial value of 0.

####When the variables are declared and also have a initial value of undefined, if you do a mathematical operation on an undefined variable you will be Getting NaN ( "Not a Number" ). Example:
```
      var a;             
      var b;
      a = a + 1;
      b = b + 5;

This will you give undefined.
```
```
Now let's define them.

      var a = 5;
      var b = 10;
      a = a + 1; // 6
      b = b + 5; // 10.
```
In JavaScript is extremely important that all variables and function names are case sensitive. (Capitalization matters)

* MYVAR is not the same as myVar or MyVar. For Example:
```
var someVariable;
var thisVariableIsLong; 

Always remeber camalCase!
```