teleren/devto huggingface dataset:
GoLand tip of the day: when Make run configurations don't find go
Tags: make, makefile, go, goland
Published: 2022-01-03 12:57:24

---
title: GoLand tip of the day: when Make run configurations don't find go
published: true
date: 2018-10-12 11:31:06 UTC
tags: ['make', 'Makefile', 'go', 'goland']
canonical_url: https://blog.riff.org/2018_10_12_goland_tip_of_the_day_when_make_run_configurations_dont_find_go
---

- [Computing](https://blog.riff.org/topic/computing)
- [Google Go = Golang](https://blog.riff.org/topic/computing/golang)
- [Goland](https://blog.riff.org/taxonomy/term/242)

### The problem

In a GoLand 2018.3 EAP run configuration, a Makefile run configuration finds the `go` binary on macOS, but not on Ubuntu, causing make targets like this one to fail:

```
# Makefile
client/test.wasm: client/main.go  # Building WASM
        GOARCH=wasm GOOS=js go build -o client/test.wasm client/main.go

$ /usr/bin/make -f (some edited path)/Makefile
client/test.wasm/bin/sh: 1: go: not found
make: *** [client/test.wasm] Error 127
$
```

Simple enough to fix...

### The diagnostic

On the command line, the same `GOARCH=wasm GOOS=js go build -o client/test.wasm client/main.go` line works normally. Looks like a path issue in Goland or the plugin. Checking in the Makefile:

```
# Makefile
client/test.wasm: client/main.go	
        # "${PATH}"	
        # Building WASM	
        GOARCH=wasm GOOS=js go build -o client/test.wasm client/main.go

$ # Building WASM
make: *** [client/test.wasm] Error 127# "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
$
```

So indeed, on at least this version, the PATH is not taken into account. Let's fix this.

### The solution

Of course, one could just add the Go bin path to the tasks in these targets, but this is uncalled for on other environments, so we can just remind GoLand to add this path to the run configuration.

1. Edit the Run configuration
2. Edit the `Environment variables` field
3. Add a definition for the `PATH` variable taken from an `echo $PATH` on the command line
4. Apply and close

### Oddities

As usual, Make has its own peculiar charm, requiring the variable name to use the braced format shown above instead of a plain `$PATH`. 

Trying to extend the PATH variable by just adding something like `$PATH:/usr/local/go/bin` or `${PATH}:/usr/local/go/bin` won't work:

- in the first case, Make will receive the result of evaluation `$P`, then the `ATH` string, so other binaries beyond the ones in `/usr/local/go/bin` will be missing
- in the second case, Make detects a variable referencing itself and aborts the task
Stack local functions in PHP
Tags: php
Published: 2018-10-12 10:15:50

---
title: Stack local functions in PHP
published: true
description: A workaround to stack local functions in PHP
tags: php
---
Recently, in one of my projects I needed to pass a local function to "stack" it.

## What is a local function?

In php a local function is a function within a function

{% gist https://gist.github.com/EduardLlach/8bef397acf7ac5bedb1a1e2a572e132a %}

## What I needed?

Well, basically I needed is to stack function calls in a list, so I could call it later.

In PHP you have the callable type, and you can call any function that is globally accessible or a method of an object which is _globally_ accessible, knowing the function's name.

## The solution
I used an interface to do something like this:

{% gist https://gist.github.com/EduardLlach/f2416dd881ea3929de6164f2cbc9215b %}

What do you thing?
Have I done an complicated workaround just to skip doing a function globally available and protected by a namespace?
Founder vs Employee
Tags: discuss, career, startup
Published: 2018-10-12 09:57:43

This is an everlasting question for developers, I believe most of us here already confront with it more than once in our lives.
This is a constant debate whether I should go my own way as a startup founder, freelancer or any other self-employed path or on the contrary join an existing company as an employee.

I chose the self-employed path as a co-founder of startup, as this is what really motivates me, working for my own cause. On the other hand, most of my friends are salaried and they love it as they have a clear separation between work and life.


I wonder what is your take?
DevThink Podcast
Tags: podcast, improvement
Published: 2018-10-12 08:52:20

---
title: DevThink Podcast
published: true
description: In the DevThink podcast we discuss ideas and practices that worked for us in our software development journey so far. We’re also discussing the topics that we’re currently exploring and learning about.
tags: podcast, improvement
---

![](https://thepracticaldev.s3.amazonaws.com/i/5n0wglqfocyd76ilpnw7.png)

I’m super happy to announce that my friend (and coworker) [Shawn Milochik](https://twitter.com/ShawnMilo) and I started our very own podcast called [DevThink](https://dev.to/devthink).

You can also view it [here on dev.to](https://dev.to/devthink)!

In the DevThink podcast, we discuss ideas and practices that worked for us in our software development journey so far. We’re also discussing the topics that we’re currently exploring and learning about.

We published 43 shows so far, and few of the most intriguing are:

+ [Is It Worth to Build a Profile on StackOverflow?](https://devth.ink/e000_stackoverflow/)
+ [Time Management and Productivity](https://devth.ink/e002_productivity/)
+ [Memory Techniques](https://devth.ink/e004_memory/)
+ [Imposter Syndrome](https://devth.ink/e005_imposter_syndrome/)
+ [Leadership and Self-Deception](https://devth.ink/e012_leadership_and_self_deception/)
+ [Documentation FTW!](https://devth.ink/e017_documentation/)
+ [Mindset: The New Psychology of Success](https://devth.ink/e033_mindset/)
+ [Should You Blog for Your Employer?](https://devth.ink/e028_writing_at_work/)
+ [Generalist vs. Specialist](https://devth.ink/e041_generalist_vs_specialist/)
+ [How to Read and Retain More?](https://devth.ink/e039_read_to_remember/)

Feedback is greatly appreciated (be it good or bad)... We’re also open to suggestions for what you’d like to hear us discuss 💪

Happy Friday! 🎉
Is coding easy? 
Tags: coding, jobs, beginners
Published: 2018-10-12 08:10:09

---
title: Is coding easy? 
published: true
description: 
tags: coding, jobs, beginner
---

My eldest son asked me - is coding easy?

Where do you start. At the Dev Academy bootcamp they were adamant that just about anyone can give it a go. Yet I still think an ability to think logically, some mathematical nous and basic communication skills are essential. 

I suspect their message was mainly to get people who had self-doubts over the sign-up line. Some people just don't realise what they can do and some of this can certainly also be taught.

If you can think logically and have a lot of patience then you can work through the hard-to-read documentation. If you can sit at a computer for hours. If you can create the right search online. If you can generalise off the examples that don't always match the difficult problem you face. Intuition helps immensely there too.

It can be easy if you don't have a constant need to interact with your colleagues - although working remotely mitigates this for me. If you enjoy that fully focused in-the-zone time when everything else disappears. If you enjoy solving puzzles and problems that you know must have a solution even if you just can't see it. That's part of the answer.

It can be easy. If it's something you've done a few times before. It's all relative to the difficulty of the problem you face and your familiarity with the tools you need to use. New and unknown have to be treated like exploring rather than doing.

It also depends on how tired you are and whether you are really doing in life what you want to do.

It will be easier if you surround yourself with people who are better at it than you. If you work in companies with big teams. With people who want to help you. If you love to hang out on technical forums and don't mind posting dumb questions. If you are a good person and look after your relationships with the people who are answering your questions.

It will be easier if you are immune to the sort of technical criticism that suggests you are the dumbest person in the room because you don't quite get something yet, when that is more about the other person's lack of communications skills or dumb ego. The reality is everyone is always learning.

It will be easier if you like to go to meet-ups with like-minded people and like pizza. If you like to go to conferences and can actually absorb what is being said. Or you love to watch tech videos or work through tutorials online in your spare time.

It will be easier if what you are working on actually inspires, your team is fun, and your boss doesn't suck.

And over time yes the technical side gets easier as you learn the tools. As you come across the same concepts in different guises and odd things you learnt on one job become useful in another.

It gets easier as you come to understand the parts of the job you are good at. When you learn to recognise when you need to go for help vs banging you head against a wall of unknowns.

So yes for me, after four years, while there is the occasional day when it seems impossible, it is otherwise easy. 

For you I don't know.
React Grid Component Comparison
Tags: react, javascript, webdev, discuss
Published: 2018-10-12 05:38:59

---
title: React Grid Component Comparison
published: true
description: 
tags: #react #javascript #webdev #discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/lnn794rnytvw6hrhlewu.png
---

As usual, there are so many choices when it comes to pick a React Component, in this case, a Grid Component. This post is an attempt to compare those choices.

Below is a list of popular grid components:

- react-virtualized grid (bvaughn) - MIT [Demo](https://bvaughn.github.io/react-virtualized/#/components/Grid)

- react-tools/react-table - MIT [Demo](https://react-table.js.org/#/story/readme)

- react-data-grid (adazzle) - MIT [Demo](http://adazzle.github.io/react-data-grid/#/examples/all-features)

- react-bootstrap-table2 - MIT [Demo](https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html)

- olifolkerd/tabulator (react version: [react-tabulator](https://github.com/ngduc/react-tabulator)) - MIT [Demo](http://tabulator.info/examples/4.0)

They are really high quality and popular components. So most common usecases are supported. But here, I am only comparing based on a few less common but "nice to have" features.

### Nice to have features:

#### Virtualized rendering

Virtualization means only render visible rows. It's very useful when you want to render a large amount of data. Without this, UI will slow down because of many DOM elements created.

react-tabulator - Yes
react-virtualized grid - Yes
react-data-grid - Yes

react-table - no info (support pagination)
react-bootstrap-table2 - no info (support pagination)


#### Resize-able columns

react-tabulator - Yes
react-data-grid - Yes
react-table - Yes

react-virtualized grid - no info
react-bootstrap-table2 - no info

#### Cell editing

It's also a common use case. Sometimes you want users to edit data from a grid.

react-tabulator - Yes
react-data-grid - Yes
react-table - Yes
react-bootstrap-table2 - Yes

react-virtualized grid - no info

#### Nesting tables

Not very common but in some report screens, when we want to show data in groups, nesting tables will be needed.

react-tabulator - Yes
react-data-grid - Yes
react-table - Yes

react-virtualized grid - no info
react-bootstrap-table2 - no info

#### Filter in columns

A convenient feature that most users will appreciate.

react-tabulator - Yes
react-data-grid - Yes
react-table - Yes
react-bootstrap-table2 - Yes

react-virtualized grid - no info

### Conclusion

At the end, I found these grid components satisfied all the nice-to-have requirements that I need: [react-data-grid](https://github.com/adazzle/react-data-grid) and [react-tabulator](https://github.com/ngduc/react-tabulator).

How about you? What is your favorite React Grid Component and why?
User Authentication with Express.js
Tags: dev, beginners, javascript
Published: 2018-10-12 04:16:20

---
title: User Authentication with Express.js
published: true
description: How to use user authentication on Express.js applications
tags: dev, beginner, javascript
---
Part of making an Express.js based application is being able to authenticate users. The question after getting them authenticated is what to do with that? 

My current strategy is to use a client-side cookie that is encrypted with a secret hash. To create a session, I use both the `cookie-parser` and `express-session` modules. I link them to my application with `app.use` in `app.js`.

```javascript
const cookieParser = require('cookie-parser');
const session = require('express-session');

app.use(cookieParser());
app.use(session({
    secret: application_secret,
    resave: false,
    saveUninitialized: false
});
```

Using that setup we can create sessions with `req.session`. With the login route on the user router, we can set the session.

```javascript
router.post('/login', (req,res) => {
    // login the user and return the user object
    // if the login is successful
    req.session.email = user.email;
    req.session.role = user.role
}
```

This sets the email and the role to the user session. I defined three roles so far: student, instructor, and admin. There are two ways that I use these roles right now. In the routes, I can run an if statement that renders a different page or passes a different property to the templates.

```javascript
if (req.session.role === 'student') {
    res.render('studentpage');
} else if (req.session.role === 'admin') {
    res.render('adminpage');
} else {
    res.render('unauthenticated');
}
```

That's not the most relevant example; you would typically check if the user is authenticated and then render a page if they are or redirect if they aren't. The other option is to take a middleware. In my middlewares directory I have `admin-auth.js` which defines a middleware.

```javascript
module.exports = function(req,res,next) {
    if (req.session.role === 'admin') {
        next();
    } else {
        res.render('unauthorized');
    }
}
```

Then on the route that I want to check if there is an admin authentication with the middleware. The middleware will process before the route is allowed to continue processing.

```javascript
const authAdmin = require('../middlewares/auth-admin');

router.get('/admin', authAdmin, (req,res) => {
    res.render('admin');
});
```

What this will do is pass the request to the middleware first. The middleware checks the role in the user session, and if the role is an admin role it allows the route to continue with `next()`. The else path changes this to the unauthorized webpage if the user doesn't have a role or the role is not an admin role.
Why no compiler help use log verbose thing
Tags: discuss
Published: 2018-10-12 03:52:33

---
title: Why no compiler help use log verbose thing
published: true
description: 
tags: discuss
---

Usually, after user report has a bug, 
we get the log, log only has 2 thing

1. `NullReferenceException` on line x
2. What data user has input

Then, we need make some test case or input in UI manually
Maybe need 0.5 - 1 day to reproduce it
It's too trouble

Why haven't a compiler add log some like debug mode `watch` function

Original
```csharp
var foo = "ABC"
var bar = "DEF"

foo = bar
```

After compile
```csharp
var foo = "ABC"
Console.WriteLine("foo = \"ABC\"")
var bar = "DEF"
Console.WriteLine("bar = \"DEF\"")

foo = bar
Console.WriteLine("foo = \"DEF\"")
```


-------

Off Topic: Where did you find a post banner image
My Top 3 Favorite Posts of All Time
Tags: top, favorite, bestofdev
Published: 2018-10-12 03:17:15

---
title: My Top 3 Favorite Posts of All Time
published: true
description: 
tags: top, favorite, bestofdev
---

It's been a while since I first signed in. And some of you might be since the [beginning of time](https://dev.to/ben/christopher-chedeau-on-the-core-philosophies-that-underlie-react), which means you and I have probably seen _everything_.

From #discuss to #explainlikeimfive, to #shecoded, to the launch of [DEV as an Open Source project](https://github.com/thepracticaldev/dev.to).

You can't imagine how difficult it was to narrow this list to just 3!

But here we go:

{% link https://dev.to/marcuscreo/the-4-letter-word-word-that-makes-my-blood-boil %}

{% link https://dev.to/sobolevn/i-am-a-mediocre-developer--30hn %}

{% link https://dev.to/isaacandsuch/if-you-dont-hire-juniors-you-dont-deserve-seniors-48kb %}
Stop Waiting for It
Tags: motivation
Published: 2018-10-12 02:44:49

---
title: Stop Waiting for It
published: true
description: Finding motivation to do what you want can be hard some times, but that shouldn't stop you.
tags: motivation
cover_image: https://thepracticaldev.s3.amazonaws.com/i/h363aevplopuy462gex8.jpeg
---

> _"What the heck, Chris? Who you talking about?"_ - Totally Not You.

Elementary, my dear Watson.

## Motivation

Everyone likes _it_. Yet, _it_ keeps giving us all the same treatment.

_It_ doesn't have friends or family.

_It_ might be with you for a few seconds, minutes or hours. But not more than that.

So... why are you waiting for _it_?

Why do you keep being loyal to _it_?

Yes, you might feel powerful when you have _it_. But you know _it_ won't last long.

> _"Okay, Chris. What's your point?"_ - Also Not You.

The idea behind this post comes from a quote a friend of mine shared with me a few days ago, and although he doesn't remember who or where he got it from, it goes like this:

> _"Motivation is for fools. Successful people are those who do what has to be done, no matter if they feel like doing it or not"._ - Someone Somewhere

And with this I would like to give you just one advice:

> _"Read the title one more time."_ - Finally we know who said this.
Explain Empty Returns Like I'm Five
Tags: explainlikeimfive, beginners
Published: 2018-10-12 00:56:38

---
title: Explain Empty Returns Like I'm Five
published: true
tags: explainlikeimfive, beginner
---

This kind of code can be confusing for beginners when they start coding:

```js
function doSomething() {
    if (somethingElseHappens())
        return;

    // ...
}
```

How would you explain this in a real life scenario that could tell how/why this is useful?
Choosing between R and Python... by asking the languages themselves
Tags: r, python
Published: 2018-10-12 00:28:43

There's been a lot of discussion over the years about R and Python in statistics/data science.  Which language should you pick if you're starting out in data science?  Which language is better at statistics? Which language is better for machine learning?  Which language is better at ______?

Of course, some really awesome people have gone out of their way to try and help you answer these questions.  For example, you can check out [this infographic](https://www.datacamp.com/community/tutorials/r-or-python-for-data-analysis) shared by Karlijn Willems on [DataCamp](https://www.datacamp.com).  The analysis goes through many different categories and presents hard data for its readers.  This post will do none of that.

Today we are going to ask the languages which of them is better.  This should provide an easy answer for us to go by if they both agree on the winner.

### Asking R

```r
> 'R' > 'python'
[1] TRUE
```

### Asking Python

```python
>>> 'python' > 'R'
True
```

Well... looks like we're still in the same spot.  There isn't a clear winner that's going to solve data science for you or your organization.  Both languages are great in different situations, and both languages have amazing open source communities behind them.

----

## A little bit about why the comparisons differ

As the header says, this will just be a *little bit*.  For R, you can read up on the [comparison documentation](https://stat.ethz.ch/R-manual/R-devel/library/base/html/Comparison.html); the details section discusses string comparisons.  For Python, you can check out the string comparison section in this post from [The Python Guru](https://thepythonguru.com/python-strings/).

In this post, we're going to ignore the details and the whys of the comparison.  We're just going to sort all the letters & numbers. This shows us how things could pan out differently if we wrote the comparison using different cases or leetspeak replacements.

### Sorting characters in R

```r
> # create and sort a vector of letters & digits
> sorted_chars = sort(c(LETTERS, letters, 0:9))
> collapsed_sorted_chars = paste(sorted_chars, collapse='')
>
> print(collapsed_sorted_chars)
[1] "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
```

### Sorting characters in Python

```python
>>> import string
>>>
>>> # create and sort a list of letters & digits
>>> sorted_chars = sorted(string.ascii_letters + string.digits)
>>> collapsed_sorted_chars = ''.join(sorted_chars)
>>>
>>> print(collapsed_sorted_chars)
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
```
Top 5 things to remember when adding a GraphQL backend
Tags: graphql, javascript, react, webdev
Published: 2019-12-24 06:55:17

---
title: Top 5 things to remember when adding a GraphQL backend
published: true
date: 2018-10-12 00:00:00 UTC
tags: graphql, javascript, react, webdev
canonical_url: https://blog.hasura.io/top-5-things-to-remember-when-adding-a-graphql-backend-6e08709d1e6b/
---

![](https://blog.hasura.io/content/images/downloaded_images/top-5-things-to-remember-when-adding-a-graphql-backend-6e08709d1e6b/1-GbDcwTfHonrUFdFjtPE8BA.jpeg)

Adopting GraphQL can result in a significant increase in feature velocity and shortened product development cycles. This has led to it being used in production systems by everyone from fortune 500 companies such as Intuit, Walmart and The New York Times to global startups including Airbnb, Docker and Github.

However, like with any shiny new piece of tech, it’s how you use it that counts. The key to reaping GraphQL’s benefits lie in thoughtful implementation. If you’re about to introduce GraphQL into your current stack, here are a few points to keep in mind:

- The learning curve when it comes to Implementing a GraphQL server from scratch is hard. But the ever-improving availability of community tooling is making the work easier.
- It is very important to figure out where a GraphQL server fits into your current backend architecture.
- You need to carefully think through your GraphQL server’s performance. Again, community tooling can help.
- Securing GraphQL APIs and queries is inherently different compared to REST APIs, especially with data access control lists (ACL).
- Support for specialized data, such as real-time data or data types such as geo-location, needs to be explicitly added.

We explored these points in more detail over at [**ProgrammableWeb**](https://www.programmableweb.com/news/top-5-things-to-remember-when-adding-graphql-backend/analysis/2018/10/01).