teleren/devto huggingface dataset:
acts-as-taggable-on causing SQL errors when ordered by relation
Tags: help, rails, actsastaggableon
Published: 2018-12-05 17:55:32

---
title: acts-as-taggable-on causing SQL errors when ordered by relation
published: true
description: 
tags: #help, #rails, #acts-as-taggable-on
---

I’m having a weird issue with acts-as-taggable-on when using tagged_with and the any flag.

My model looks something like this:
```ruby
class Document < ApplicationRecord
  ...
  belongs_to :phase, optional: true
  ...

  scope :search_by_drug, ->(drug) { tagged_with(drug, on: :drug) if drug.present? }
  scope :search_by_area, ->(area) { tagged_with(area, on: :area) if area.present? }
  scope :search_by_type, ->(types) { tagged_with(types, on: :doc_type, any: true) if types.present? }
  scope :search_by_tags, ->(tags) { tagged_with(tags, on: :tags, any: true) if tags.present? }
  ...

  acts_as_taggable_on :tags, :drug, :area, :doc_type
  ...
end
```

and in my controller this is where I'm querying: 

```ruby
class DocumentsController < ApplicationController
  include Pagy::Backend
  ...

  # GET /documents
  def index
    @pagy, @documents = pagy(
      Document.includes(:phase, :taggings)
              .search_by_drug(params[:drug])
              .search_by_area(params[:area])
              .search_by_type(params[:types])
              .search_by_tags(params[:tags])
              .order(sort_order),
      items: 5
    )
  end
  ...

  private

  def sort_by
    return 'phases.name' if params[:sort] == 'phase'

    @sort_by = params[:sort] || 'date'
  end

  def order
    @order = params[:order] || 'asc'
  end

  def sort_order
    "#{sort_by} #{order}"
  end
  ...
end
```

When I'm searching with tags or by types and I try to order the phase column I’m thrown an error that looks like this: 

`ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...) AND "taggings"."context" = 'doc_type') ORDER BY phases.nam...`.

I’ve done a bunch of searching but the closest issues I could come up with was an [old issue on the acts-as-taggable-on github](https://github.com/mbleigh/acts-as-taggable-on/issues/519) but it was closed because (according to them) they had [merged a PR](https://github.com/mbleigh/acts-as-taggable-on/pull/570) that fixed the issue and there’s nothing new in their issues or SO. 

Can anyone point me in the right direction?
Silly Questions I am Afraid To Ask On StackOverflow: 001 
Tags: beginners
Published: 2018-12-05 20:23:23

---
title: Silly Questions I am Afraid To Ask On StackOverflow: 001 
published: true
description: User submitted photos
tags: beginner
---

Hey everyone, me again. 

Can anyone push me in the right direction to understand how a website like Product Hunt stores its data once someone submits a project? 

Is this done with a normal database? 

Thank you.
The hiring manager's dilemma / perspective ?
Tags: discuss, career, webdev, interview
Published: 2018-12-05 19:09:29

---
title: The hiring manager's dilemma / perspective ?
published: true
description: What are the dilemma's faced when evaluating candidates coming from different work environments ? What is the developer's perspective and most importantly what is the hiring manager's perspective ?
cover_image: https://thepracticaldev.s3.amazonaws.com/i/myby6602339can636kb1.jpg
tags: #discuss, #career, #webdev, #interview
---

I was wondering lately how a decision is made when a company is looking for a developer of any position and how the previous environment a candidate has worked for can affect the decision and in what ways.

What are the dilemma's faced when evaluating candidates from different work environments ? What is the developer's perspective and most importantly what is the hiring manager's perspective ? 

Lets say for the sake of simplicity that there are only **2 candidates** applying for the same position. 

**Candidate 1 (C1)** always worked in companies that were advanced and efficient, with great  managers, the salary always more than enough, the environment ideal, company paid for education and conferences and meetups, and and never had to work overtime because everyting was pretty much laid out and never had to deal with customer support.

**Candidate 2 (C2)** always worked in companies that were all opposite of previous candidate's, No established channels of communication or progress or reporting, unit or even functional tests were unknown, outdated infrastucture, people communicated with emails attaching DOCX revisions, has spend a fair amount of time supporting customers, probably overworked and underpaid.

Both take a technical test for a developer's position for a company that pretty much resembles C1's previous companies and C1 scores 97% while C2 scores a mere 85%.

From a purely technical view I understand that perhaps C1 deserves to get the job.

Some extreme perspectives I could think of 

### C2 Developer's perspective
Has fought his/her way to become the best but it was always an uphill.  He/she is thinking that if has managed to be a 85% competent while being paid X gets excited with what he/she could achieve if can land a job getting paid 2X-5X as much.

### Hiring manager's perspective
Perhaps there is no dilemma since C2 has failed to be up to the company's standards and is not fit therefore C1 will get the position.

Personally if I was to make the decision on the above scenario I would probably hire C2. 

I know the above is a very extreme scenario but only presenting it in order to serve the basis of a discussion.

If anyone has some real (or even no) experience on either the developer's or hiring manager's side of things I would love to hear your thoughts or general comments.
Effective Database Design: Part 3
Tags: database
Published: 2018-12-05 18:44:37

---
title: Effective Database Design: Part 3
published: true
description: A walkthrough of the second normal form in database normalization.
tags: databases
---

This is the third post in a series about database design and normalization. In our [last post](https://dev.to/adammc331/effective-database-design-part-2-2ben), we discussed the first normal form and took an initial step toward proper database design. We learned that we should have a primary key, atomic values, and no repeating groups. We also learned how to separate our entities to avoid redundancy. 

Now we can go a step further and make sure we abide by the second normal form. 

## Second Normal Form

A table is in 2NF if it is in 1NF, and there are no partial dependencies. This means that non-prime columns (columns that are not part of the key, or possible keys) depend entirely on the primary key. 

In a table that has a single primary key column, this will always hold true, so we don't need to stress about it. If we have a composite key, though, we could break this rule.

For example, let's add a teacher column to our `student_classes` table from the last part. Let's say that Ms. Smith teaches math, Ms. Jackson teaches programming, and Ms. James teaches history. 

| student_id | class_id | teacher |
|---|---|---|
| 1 | 1 | Smith |
| 1 | 2 | Jackson |
| 2 | 3 | James |

The teacher column is determined only by the class_id, _not_ by the entire primary identifier of (student_id, class_id).

## Problem

Before we discuss a solution, let's look at the problems this could cause. Consider if Prince also took programming:

| student_id | class_id | teacher |
|---|---|---|
| 1 | 1 | Smith |
| 1 | 2 | Jackson |
| 2 | 3 | James |
| 2 | 2 | Jackson |
 
Notice any familiar problems? We have data redundancy issues. Twice we see that Ms. Jackson teaches programming, which also indicates we could be at risk of an update anomaly if I only changed one of those rows. 

## Solution

Since the teacher column is dependent only on the class_id column, we should group those entities together.

Let's put the teacher column in the classes table:

| id | class_name | teacher |
|---|---|---|
| 1 | Math | Smith |
| 2 | Programming | Jackson | 
| 3 | History | James |

We've got a lot to keep track of in our three tables so far, so we'll just look at a high level diagram. Shout out to [dbdiagram.io](https://dbdiagram.io/) for making a helpful tool:

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

The 2NF was a quick one to explain, but now we've got a pretty well designed database. Let's recap everything up to the 2NF:

* Each table has a primary identifier. 
* Each column only has atomic values.
* No tables have repeating groups.
* There are no partial dependencies. 

We're in a good spot now that we know how to ensure these four things. In the [next post](https://dev.to/adammc331/effective-database-design-part-4-jbj), we'll continue on this normalization adventure to comply with the third normal form.
Building Browser Extension - Book
Tags: javascript, beginners, programming, book
Published: 2018-12-05 18:32:11

---
title:  Building Browser Extension - Book
published: true
description: A simple book to get started with Cross Browser WebExtension Development.
tags: #javascript , #beginners, #programming , #book
canonical_url: https://dev.to/iamvp7/mozwebext-book/
---

I recently published my first book on [Cross Browser WebExtension development](https://heyvp7.gumroad.com/#iyoBl). This book can be downloaded for free from leanpub and is licensed with Creative Commons license. This book will be good for beginners who are interested to learn more on Javascript. This book contains 7 experiments with good number of API's explained with code examples and another 7 suggested experiments which we can try.

### Contents in book

- With this book we can learn about setting us the Firefox Extension development.
- We can learn the amazing 7 experiments listed below.
- We can learn about publishing to Firefox AMO.

#### Experiments

1. Building Motivational Tab
2. Building Power Search Add-on
3. Building Tabs Closer
4. Building PDF WebPage Extension
5. Building Water Notifier Extension
6. Building Shortcuts for Youtube Controller
7. Building Quick Stackoverflow searcher

Download the book, try it share your experience.
🎂 My birthday gift to you. The Planet Argon Tech Internship Toolkit 🚀
Tags: mentoring, internships, leadership
Published: 2018-12-05 18:14:27

---
title: 🎂 My birthday gift to you. The Planet Argon Tech Internship Toolkit 🚀
published: true
description: We're releasing our guide to running great technical internships.
tags: mentoring, internships, leadership
canonical_url: https://blog.planetargon.com/entries/my-birthday-gift-to-you-the-planet-argon-tech-internship-toolkit
cover_image: https://thepracticaldev.s3.amazonaws.com/i/7gwpbzhajkt3sudx63a9.png
---

In recent years, running tech internships at [Planet Argon](https://www.planetargon.com/) has become a constant activity. We’ve had nine separate interns this year (2018) alone and will have around the same number next year. We’re a small company (< 12 employees)…yet we find a way to make this work well for our interns and ourselves.

[![Go download our tech internship toolkit — it’s free!](https://thepracticaldev.s3.amazonaws.com/i/6w8vt957a288dwzxeppu.png)](https://www.planetargon.com/internships/toolkit)

One of our business goals is to be seen as an example for running [great internships](https://www.planetargon.com/internship) and to “open source” how we do it.

We know there are a lot of organizations that are intern-curious but don’t know how and/or where to start.

…which is where I found myself back in 2009 when I tweeted:


{% twitter 6284196527 %}

A decade later, I’m delighted to share our philosophy and approach to running a great internship with you.

Are you considering bringing on an intern or five in 2019 and aren’t quite sure where to start? OR are you want to streamline an existing internship program a touch?

Today I’m delighted to share the [Planet Argon Tech Internship Toolkit](https://www.planetargon.com/internships/toolkit) with you. It’s free.

We touch on how to a) recruit interns b) how to onboard interns c) how to challenge interns d) how to learn from interns and e) how to send them off into the wild — ready to get their new career started.

Today is my birthday and this is my gift to you.

## [Read and/or download the toolkit](https://www.planetargon.com/internships/toolkit)

Should you find some valuable tidbits in the toolkit, please consider sharing it with your peer networks.

{% instagram Bm4Ibe5hlNC %}


P.S. a huge thanks to all or our past interns for helping each of us become better versions of ourselves.

_This post was [originally published on blog.planetargon.com](https://blog.planetargon.com/entries/my-birthday-gift-to-you-the-planet-argon-tech-internship-toolkit)._
PyKup - Web App backup manager
Tags: webdev, python, devops, linux
Published: 2018-12-05 18:07:42

![Pykup](https://raw.githubusercontent.com/RobyFerro/PyKup/master/logo.jpg) 
# PyKup - WebApp backup manager

A simple tool to easily manage and schedule backup for any web app!
With PyKup you can backup your web applications in just one command.
Everything will be compressed and stored in your favorite storage location.

## Usage

```
python pykup.py -d <APP_FOLDER> -cF <PATH_CONFIG_FILE> -uD <UPLOAD_DRIVER dropbox|scp> --cron 
```

## Multiple application backup
With crontab integration you can schedule multiple application backup:

```
python pykup.py -d <APP_FOLDER_1> -cF <PATH_CONFIG_FILE_1> -uD <UPLOAD_DRIVER dropbox|scp> --cron 
python pykup.py -d <APP_FOLDER_2> -cF <PATH_CONFIG_FILE_2> -uD <UPLOAD_DRIVER dropbox|scp> --cron 
```

## Getting started
First of all ensure that Python 3 is installed on your machine, then you can get all file with:

```
git clone https://github.com/RobyFerro/PyKup.git
```

Install all requirements with:

```
pip install -r requirements.txt
```

After that you can get all information by typing:
```
usage: pykup.py [-h] -d DIRECTORY [-n APP_NAME] -cF CONFIG_FILE
                [-uD UPLOAD_DRIVER] [-rF REMOTE_FOLDER] [--cron]

PyBack WebApp backup utils

optional arguments:
  -h, --help         show this help message and exit
  -d DIRECTORY       Set a backup directory
  -n APP_NAME        Define application name
  -cF CONFIG_FILE    Define configuration file
  -uD UPLOAD_DRIVER  Define upload driver dropbox|scp
  -rF REMOTE_FOLDER  Define scp remote folder
  --cron             Set command in crontab
  --telegram         Send telegram notification after backup
```

## Config
To config your web app you should rename config.ini.example in config directory
and replace all values with your parameters.

You can set multiple .ini file to schedule multiple backup

```
first-app.ini
second-app.ini
third-app.ini
```

**This trick it will be useful combinated with --cron option.**

## Crontab events
To set the current command inside linux crontab job you've just to specify --cron option.
Use the following command to show all existing crontab job:
```
crontab -l
```

## Dropbox integration

To upload your backups on dropbox you've to create a new application inside your [Dropbox account](https://www.dropbox.com/developers/apps/create) 
and follow this steps:

* Select Dropbox API
* Select "App folder"
* Select your app name

Once created you've to generate a new access token and put it on config/integrations/dropbox.json

## Telegram confirm notification

To send a notification to your own telegram channel you've to create a [Telegram bot](https://core.telegram.org/bots#6-botfather)

* Insert your TOKEN and Telegram user ID in config.ini file

### Todo list:
- [x] File backup and compression
- [x] Log activity
- [x] PostgreSQL dump
- [x] MySQL dump
- [x] Dropbox integration
- [x] SCP Sync
- [x] Rsync integration
- [x] Crontab integration
- [x] Telegram confirm notification
- [ ] Telegram bot remote control
- [ ] Google Drive Integration

## Need help? 
Join in our [Telegram community](https://t.me/ikdev)
Manage a Collection of Secure API Endpoints with Postman
Tags: postman, api, apidevelopment
Published: 2018-12-05 17:41:39

---
title: Manage a Collection of Secure API Endpoints with Postman
published: true
description: Learn how to use Postman to manage a collection of public and secure API endpoints
tags: #postman #api #apidevelopment
canonical_url: https://auth0.com/blog/manage-a-collection-of-secure-api-endpoints-with-postman/
---

Postman is an API development environment that helps you develop your APIs. It can be used to streamline the development process and creates a single source of truth for an organization's APIs with rich documentation produced from the very tool you use to manage and test your API. 

In this post, you'll learn how to use Postman to interact with an API for both public and secure API endpoints. 

[Read on 👨‍🚀](https://auth0.com/blog/manage-a-collection-of-secure-api-endpoints-with-postman/?utm_source=dev&utm_medium=sc&utm_campaign=postman_secure_api)

![Manage a Collection of Secure API Endpoints with Postman](https://thepracticaldev.s3.amazonaws.com/i/q3o3bn6xdyz3s6xd9e1n.png)
Enable linting in your React App
Tags: react, javascript, eslint, vscode
Published: 2018-12-05 17:18:55

_Photo by [rawpixel](https://unsplash.com/photos/svvName5USA) on Unsplash_


Linters helps you write better code (along with tests). 

When you remove the dependency on the built-in linting that comes with your IDE/Code editor you can wire up the checks to your continuous delivery pipeline. Now your build quality is improved!

In short: linting is good.

The choice of linter I've gone with is [eslint](https://eslint.org/), this is because it's extensible (plugins) and should continue to evolve when others won't (looking at you [jshint](https://jshint.com/)).

Nearly all linters use some form of ruleset. These are available as [plugins](https://www.npmjs.com/search?q=eslint-config) and I've opted for the [one](https://www.npmjs.com/package/eslint-config-react-app) used bundled when you run `create-react-app`.

## Install

```console
yarn add --dev eslint@latest \
    babel-eslint@latest \
    eslint-config-react-app \
    eslint-plugin-flowtype@latest \
    eslint-plugin-import@latest \
    eslint-plugin-jsx-a11y@latest \
    eslint-plugin-react@latest
```

Create the following file `.eslintrc` in your react project

```json
{
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "node": true
  },
  "extends": "react-app"
}

```

## Add to your `package.json`

```json
  "scripts": {
    "lint": "eslint src"
  }

```

## Test

```console
yarn run lint

```

## Bonus: enable in Visual Studio Code

Install this extension: [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).

This is mostly a post to let y'all know I'm still alive ;)
Next.js vs Gatsby vs React-Static vs CRA
Tags: react, javascript, webdev, discuss
Published: 2018-12-05 16:06:02

---
title: Next.js vs Gatsby vs React-Static vs CRA
published: true
description: Explain it like I'm 5
tags: react, javascript, webdev, discuss
---
Dear Dev.to community.
A couple weeks ago I started learning React and also introduced it at work as the goto frontend development framework/library.
I started out with the create-react-app cli and had no big limitations so far.
I'm now at the point where I hear about all the other cool stuff that tries to enhance react.

So my question is:
What's the main difference between all these frameworks and when/why would/should I use any of those?
Lambda Layers for NodeJS - An Example
Tags: aws, awslambda, serverless, node
Published: 2018-12-05 14:46:39

---
title: Lambda Layers for NodeJS - An Example
published: true
description: A writeup of nodejs lambda using lambda layers, on aws-cli
tags: #AWS #AWSLambda #Serverless #NodeJS
---

{% github https://github.com/nsriram/aws-lambda-layer-example/ %}
How to set up Babel 101
Tags: javascript, webdev, learning
Published: 2018-12-05 03:43:47

---
title: How to set up Babel 101
published: true
description: Compile ES6 code into ES5 using babel!
tags: javascript, webdev, learning
---

> I'm constantly having to look up how to set up babel to convert ES6 to ES5 so I figured I would write a post to help myself and possibly others!

## Project Set Up
Ok so lets create a project directory and initialize our package.json
```
mkdir babel-dummy-dir
npm init
```

Now lets install the needed babel packages.
```
npm install --save-dev babel-cli babel-preset-env
```

[babel-preset-env](https://babeljs.io/docs/en/babel-preset-env) is the main library that we use to convert our ES6 to ES5. It works by having version mappings which allows babel to take our ES6 features and find ES5 features.

After that has finished we need to create our `.babelrc` file in the root directory. 

```
touch .babelrc
```

Then we need to add the following.
```
{
  "presets": ["env"]
}
```

Now let's create our `src` folder!
```
mkdir src
cd src && touch index.js
```

## Start Hacking
Now we can enter some fancy ES6 code into our index.js. I'll be using the code below.
```javascript
class Dog {
  constructor (name) {
    this.name = name;
  }

  static bark(){
    console.log('woof');
  }
}

Dog.bark();
```

Now we are ready to run our program, but first we need to go into our `package.json` and add our build command.  We can add two commands to our package!
```
"build": "babel src -d build",
"start": "node build/index.js"
```

## Build & Run
We are ready to run our code now. Lets call our build command with `npm run build`, this will build all the files in our src directory into our build directory. Now it's time to run our ES5 code! Enter `npm start` and you should see something like the output below...

```
babel-dummy@1.0.0 start .../babel-dummy
node build/index.js

woof
```

There we have it, we compiled our ES6 code into ES5 using babel!
Easy Gravity in 30 lines
Tags: javascript, gravity, animation, physics
Published: 2018-12-05 14:09:36

---
title: Easy Gravity in 30 lines
published: true
description: a little gravity in js
tags: javascript, gravity, animation, physics
---

Not sure why I felt like making this little example this morning. It's a very short bit of code that causes a div to move with gravity... while there is not much code, I made a point not to golf it (even though I was tempted).

{% codepen https://codepen.io/ZevanRosser/pen/eQwmeP/ default-tab=js,result %}

If you want to learn more about how to move stuff like this, I have a *pretty old* tutorial I made that you can check out:

{% youtube YCI8uqePkrc %}

_video is old, but basic concepts still work_