teleren/devto huggingface dataset:
PostgreSQL: How To Setup Our Installed PostgreSQL
Tags: beginners, tutorial, postgres
Published: 2019-09-05 14:30:54

---
title: PostgreSQL: How To Setup Our Installed PostgreSQL
published: true
description: PostgreSQL: How To Setup Our Installed PostgreSQL
tags: beginners, tutorial, javascript, postgres
series: Intro to PostgreSQL (for NodeJS & Express)
---

## Intro

So we [installed PostgreSQL](https://dev.to/miku86/postgresql-what-is-it-how-to-install-it-16hk) on our machine.

Now we want to learn how to setup our installed PostgreSQL.

---

## Create a new PostgreSQL database cluster

initdb must be run as the user that will own the server process, therefore it is recommended to create a new user and login with it.

```
# login as user
sudo -iu [username]
```

initdb creates a new PostgreSQL database cluster (a collection of databases that are managed by a single server instance).

```
initdb -D /var/lib/postgres/data
```

If you get `permission denied`, you can find a solutin in the [initdb docs](https://www.postgresql.org/docs/current/app-initdb.html)

---

## Start PostgreSQL server

If you don't know how to start a system service, [read this](https://tableplus.com/blog/2018/10/how-to-start-stop-restart-postgresql-server.html).

Example for Arch:

```
systemctl start postgresql
```

If you get some problems, [read this](https://www.postgresql.org/docs/current/server-start.html).

---

## Create a Role (= Database User)

Now we need a role, that can do some operations.

Don't forget to be logged in as the user you created before:

```
# login as user
sudo -iu [username]
```

Create user:

```
createuser --interactive
```

[createuser docs](https://www.postgresql.org/docs/11/app-createuser.html)

---

## Create a Database

No we need a database, that is owned by our new user

```
createdb -O [username] [dbname]
```

---

## Connect to the Database Shell

We've just created a user and a database.

Now we can connect to the database shell:

```
psql -d [dbname]
```

[psql](https://www.postgresql.org/docs/current/app-psql.html) is a terminal-based front-end to PostgreSQL, you can type in queries, issue them to PostgreSQL, and see the query results.

---

## Next Part

We will write our first commands to get some data.

---

## Further Reading
[PostgreSQL Homepage](https://www.postgresql.org/)
[PostgreSQL Docs](https://www.postgresql.org/docs/current/index.html)
[SQL Syntax](https://en.wikipedia.org/wiki/SQL_syntax)

---

## Questions

- What's your favorite SQL database?
Rails File Structure Overview
Tags: rails, ruby, explainlikeimfive
Published: 2019-09-05 14:18:55

---
title: Rails File Structure Overview
published: true
description: A quick walk through of files in a new rails app
tags: ruby on rails, ruby, explainlikeimfive
cover_image: https://thepracticaldev.s3.amazonaws.com/i/luuc60bziu8oyw7vjt15.jpg
---

# The Gist

This is a quick read, more so a reference guide as to what those files in your new rails app are about

![KEAUNUUUU](https://media.giphy.com/media/U6Fxnc2jTlBh2GKCTU/giphy.gif)


If you're like me and just are getting to know RBENV after uninstalling rvm then you'd want to start with:

```bash
gem install rails
```

Then you get a long list of gems that installed successfully

After which you hit your keyboard with the good ol' 

```bash
rails new cool-project
``` 

Once you navigate over to your code editor of choice you would see the following files, let's take a look at what each one does in general.

## File Structure

* APP
  * contains models, views, controllers
  * core functions found here
  * __only place__ where you can make changes and not have to restart your rails server
  * location of Non-Ruby files such as, but not limited to
     * JS, CSS, images, fonts, more assets  such as these
* BIN
  * built in rails tasks. You shouldn't be worrying about this folder way too much
* CONFIG
  * Settings that control behavior:
    * Environment Settings
    * modules that initialize when app starts
    * app settings
    * data base settings
    * __app routes__
    * __secret key base__
* DB
  * __schema.rb file__
    * this lists:
    * database tables
    * columns
    * column associated data types
  * __seeds.rb file__
    * enables you to create data to be used in the app
    * can quickly integrate data into the app
* LIB
  * houses __custom rake tasks__
    * example case: can run in the background, make calls to an external API, and sync returned data in app's db.
* LOG
  * application logs
  * __DEBUGGING!__ 
  * for a prod env, you'll probably use outside service
* PUBLIC
  * Custom error pages
  * robots.txt
    * controls how search engines index the app
* __SPEC__/test (will mostly use RSPEC)
  * test suite:
    * specs, factories, test helpers, test configuration
* TMP
  * for temporary files, never really had to deal with this
* VENDOR
  * mainly used to integrate client-side MVC framworks, such as Angular
* GEMFILE
  * all of your gems from your project
  * outside libraries used in the app
  * _after changing gemfile, rerun_ __BUNDLE__
    * calls in code dependencies of application
    * (Gems are ruby files that extend functions of app)
* GEMFILE.lock
  * _don't edit!_
  * __dependencies and associated versions__
* README.rdoc
  * for your to document details of app
  * instructions for other devs

Hopefully this helps you the next time your trying to remember what folder to look into to fix a bug 🐛
  
Photo Credit:
[Helloquence](https://unsplash.com/photos/EPppwcVTZEo)
Daily Challenge #58 - Smelting Iron Ingots
Tags: challenge
Published: 2019-09-05 13:55:26

---
title: Daily Challenge #58 - Smelting Iron Ingots
published: true
series: Daily Challenge
description: Create a calculator that will let Steve know how much fuel he needs.
tags: challenge
---

Minecraft has gotten to be a very popular game. No doubt many reading this have played it themselves or watched someone else. In Minecraft, collected ore must be smelted in a furnace to change the resource into a usable form. 

Each ingot takes *11 seconds* to produce. Steve has the following fuel options to add to the furnace:

   ` Buckets of lava, each lasts 800 seconds`
    `Blaze rod, each lasts 120 seconds`
    `Coals, each lasts 80 seconds`
  `  Blocks of Wood, each lasts 15 seconds`
`    Sticks, each lasts 1 second*`

Write a function that calculates the *minimum amount* of fuel needed to produce a certain number of iron ingots. 

Ruby: `{:lava => 2, :blaze_rod => 1, :coal => 1, :wood => 0, :stick => 0}`
JavaScript: `{lava: 2, blazeRod: 1, coal: 1, wood: 0, stick: 0}`

Good luck!~

***
_Today's challenge comes from arwengu on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Introducing Simple Smarthome System
Tags: kotlin, smarthome, vue, sideprojects
Published: 2019-09-05 13:06:13

Some developers like to have side projects that they can work on in their free time. I’m one of them. I always have some code and electronics lying around, waiting to be finished. This time I wanted to test my skills in back end and learn a little bit in the process. I have experience with Kotlin, so the obvious choice for me was to try Ktor.

This approach has the benefit of seeing Kotlin in action on other platforms since Kotlin multi platform might be a valuable tool in my toolbox. As frontend I’ve chosen Vue.js since I’ve already tried React in the past. Ok so I’ve got the tools, but what should I work on. The answer came to me when I was not satisfied with existing solutions in smart home dashboard environment.

What I didn’t like about existing solutions?

-   They are hard to configure
-   They have too many features
-   They are configured through configuration files with a little of documentation

So I decided to build my own. How hard can it be?

After more than half a year I present you Simple SmartHome System:
![Dashboard](https://www.netguru.com/hs-fs/hubfs/image1-33.png?width=2900&name=image1-33.png)
![working](https://www.netguru.com/hs-fs/hubfs/image5-1.gif?width=960&name=image5-1.gif)
![settings](https://www.netguru.com/hs-fs/hubfs/image2-26.png?width=2999&name=image2-26.png)

It also works on mobile:
![mobile](https://www.netguru.com/hs-fs/hubfs/image3-18.png?width=2538&name=image3-18.png)

What can it do?

-   It can show latest status of devices.
-   Group devices into logical groups like rooms or garages
-   Send events back to mqtt broker

What is missing?

-   Rule engine that can change state of sensor based on events.

There are a couple of concepts I’ve tried to follow while developing SSS:

1.  It is based on MQTT. MQTT is standard in IoT world with a lot of devices already supporting it.
2.  It should easily integrate with two tools I use:  [zigbee2mqtt](https://www.zigbee2mqtt.io/)  (gateway software that allows you to use proprietary zigbee devices without proprietary gateways) and  [Tasmota](https://github.com/arendst/Sonoff-Tasmota)  (open source firmware for devices based on ESP8622 chips).
3.  Everything should be configurable through UI.

Please see  [github](https://github.com/netguru/smarthome)  for installation details and source code.

I’ve learned a couple of things during development. I think I like React more than Vue. MVVM approach of Vue is nice, but observable variables didn’t always work as expected. Kotlin is superb technology even on backend, but Ktor is not opinionated at all, so I needed to figure out a lot of stuff like which database to use and what is database connection pool :)

I need to mention great support from Netguru in developing this tool. Not only I have opportunity to promote it here, host it on netguru github, but also great people on Vue team helped me with this framework. Growing in Netguru is a pleasure :)
The Top 10 JAMstack Community Resources
Tags: react, graphql, javascript, webdev
Published: 2019-09-05 13:04:36

###Here are the top 🔝 10 JAMstack resources from the community!

More than just a modern web development architecture 🏛 based on client-side JavaScript, reusable APIs, and prebuilt Markup, JAMstack is revolutionizing the way we think about workflow by providing a simpler developer experience, better performance, lower cost and greater scalability. 🤟

1. [A simple guide that will help you understand why it exists and how to get started. 🎬](https://jamstack.wtf/)
2. [A directory of tools and services from the New Dynamic 🛠](https://www.thenewdynamic.org/)
3. [The New Dynamic Slack channel 🗣](https://join.slack.com/t/thenewdynamic/shared_invite/enQtMjkwNjYwNTY0NjkxLWI1NDhlNjZkZjA5ZGJmODE1OThiMjkwN2ZkMzE1YjEwN2YwNWUxYTNjZTUxMGQ2MzU3NWQ0YmVjNGU1NTkxMDk)
4. [The subreddit for JAMstack developers 👾](https://www.reddit.com/r/jamstack_dev)
5. [A talk about the powerful front end developer 🎤](https://www.youtube.com/watch?v=grSxHfGoaeg)
6. [The hub for JAMstack conferences throughout the world 🌎](https://jamstackconf.com/)
7. [A JAMstack guide, set of resources, and more 🤝](https://jamstack.org/)
8. [A carefully curated list of awesome JAMstack tools 📝](https://github.com/automata/awesome-jamstack)
9. [A radio show all about the JAMstack 📻](https://www.heavybit.com/library/podcasts/jamstack-radio/)
10. [A talk about the rise of the JAMstack from the person who coined the term 🎙](https://www.youtube.com/watch?v=uWTMEDEPw8c)
JavaScript as a Foreign Language
Tags: healthydebate, discuss, education, learning
Published: 2019-09-05 12:43:39

---
title: JavaScript as a Foreign Language
published: true
description: Should credits from programming and technical courses count towards credits of foreign language classes? Should JavaScript be at the same level as Spanish or French?
tags: healthydebate,discussion,education,learning
canonical_url: http://alvaromontoro.com/blog/67841/javascript-as-a-foreign-language
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pzo0kct8cws4oytdsvqx.png
---

Talking to some people, the topic of programming and STEM education came up. And, although maybe a bit old, we ended up discussing the initiative in the United States to consider programming as a second language at a high school level.

In summary, the idea involves counting the credits from programming classes (Coding, Computer Science, Technology, etc.) towards the credits of foreign language classes (Spanish, French, German, etc.)

Some states are proposing or already implementing a similar initiative: Kentucky and Oklahoma passed bills enhancing coding as a foreign language, Texas offers it only to certain students, Florida ended up rejecting a similar bill (after pressure from education lobbies)... 

I find it an interesting topic, but it has me divided.

On one hand, there is a clear need in the workforce for people with a technical and programming background. Learning how to code would light a path into a career that -at least for now- means job security and high-paying jobs. 

In that sense, students would be learning something that they could actually apply in a professional environment. Something that could level the field, and break some social barriers.

On the other hand, and on a personal level, foreign languages were of extreme importance to me. Knowing some English and French opened many doors and gave me opportunities that I could have not even imagined: working in multinational companies, traveling the world, and meeting new cultures and people. I wouldn't be the person that I am now without learning a foreign language.

For many people, the second language they learn in high school may not be really useful. But for some others, it is a life-changing class. 




What is your opinion? Do you speak JavaScript? Do you think Coding should count as a Foreign Language?
Thought for the day: Software should promote inclusivity
Tags: inclusion
Published: 2019-09-05 12:33:55

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Interesting thought: software should be marketed based on how inclusive, kind, and equal-minded it is. Could be that the creators have those values, or even better, it could be that the software promotes those values. Let&#39;s build THAT. <a href="https://twitter.com/hashtag/appdev?src=hash&amp;ref_src=twsrc%5Etfw">#appdev</a> <a href="https://twitter.com/hashtag/webdev?src=hash&amp;ref_src=twsrc%5Etfw">#webdev</a> <a href="https://twitter.com/hashtag/equality?src=hash&amp;ref_src=twsrc%5Etfw">#equality</a> <a href="https://twitter.com/hashtag/kindness?src=hash&amp;ref_src=twsrc%5Etfw">#kindness</a></p>&mdash; Joel Varty (@joelvarty) <a href="https://twitter.com/joelvarty/status/1169230341233631233?ref_src=twsrc%5Etfw">September 4, 2019</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
Kotlin for better helper methods
Tags: kotlin
Published: 2019-09-05 12:25:41

When implementing helper classes in Kotlin you can, compared to Java, take advantage of a less verbose and more powerful idiomatic style.

Let’s check this easy _but verbose_ Java example; the method body is not important...

```
package io.earroyoron.helpers;

public class EarroyoronHelper {

/* A private constructor to avoid class instantiation */
 private EarroyoronHelper() {}

/* Just some helper method */
 public static String doSomething
 (final String a, final String b) {
 //.... whatever
   return a + " and then " + b;
 }
}
```

Too many things just for such a simple thing, isn’t it?

The Kotlin version just shows *what a modern language is*:

```
package io.earroyoron.helpers

/* Just some helper method */
 fun andThen (a: String, b: String): String {
 return"$a and then $b"
 }
}
```

We don’t need things that, actually, does not add value or improve the intention or readiness.

- Of course the ; that is useless
- The class, as we will not instantiate it. Kotlin adds the function (method) to the package namespace. You can import as:  

`import io.earroyoron.helpers.andThen`

the method could indeed return directly the response as in:

`fun andThen (a: String, b: String) = "$a and then $b"`

## Even better with extensions

A better version uses class extensions:

```
package io.earroyoron.helpers

fun String.doSomeTransformation (b: String) = "$this and then $b"
```

So you can call this helper as:

`"original string".andThen ("more letters")`

## infix

or if you add infix to the function ( infix fun ) to improve as a DSL style:

```
infix fun String.doSomeTransformation (b: String) = "$this and then $b"

val sillyString = "original string" andThen "more letters"

```
This is the most kotlin idiomatic way; you may use object to instantiate a singleton, or companion class to have an static block in a not-singleton class but both are not the perfect way.

## Functional style

As you are not creating the object and the method is just an static one, with only depending on the input parameters to produce the results you are using a functional style. Is a plus.
Keeping WordPress up to date is really important
Tags: wordpress
Published: 2019-09-05 12:38:36

---
title: Keeping WordPress up to date is really important
published: true
tags: WordPress,wordpress
canonical_url: https://kevinhq.com/keeping-wordpress-up-to-date-is-really-important/
---

The WordPress team released 5.2.3 nine hours ago. Since I’ve set up this site’s WordPress to update automatically, I do not need to update it manually when the new version came.   However, some folks I know used to delay or postpone the update for various reasons. Whatever the reasons (or excuses?) they have, leaving the… [Continue reading »Keeping WordPress up to date is really important](https://kevinhq.com/keeping-wordpress-up-to-date-is-really-important/) ![](http://feeds.feedburner.com/~r/kevinhq/~4/I-OSLsU9P00)
What is the most overlooked Laravel feature?
Tags: laravel, discuss
Published: 2019-09-05 11:45:38

---
title: What is the most overlooked Laravel feature?
published: true
description: 
tags: laravel,discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/ekse8pc92ppzow30ablc.png
---

Tell us about hidden gems and useful -but often overlooked- features!

> What do you like about it? 
Why might it not be used as much as it should?

Bonus points if you include an article with an introduction for others to learn.
Google Docs VS Microsoft Office
Published: 2019-09-05 11:37:07

We have been using Microsoft Office for decades. It was socially considered as a default tool for any documentation (word file or PPT or accounts sheet ) till google stepped in with its own version of Microsoft Office(Google Docs). Now, they both are trying to dominate this specific market.

So, let’s discuss how they both are different from each other and which one you should choose for better productivity.

Differences Between Microsoft Office And Google Docs



Microsoft Office –

Microsoft office is not an independent platform. There is a massive Microsoft Office 365 package including more than half of dozen applications as Microsoft Word, Excel, Powerpoint, Outlook, Publisher, Access and OneNote.
Ms word is one of main application of MS Office which we can use offline as well as online.

We can integrate the third-party app with MS office via office store as Microsoft has expanded its platform for Integration.
OneDrive’s 1TB cloud storage is integrated into Microsoft Windows.
We can also work on MS office as Offline in a desktop and can simply save our files on the computer.

Microsoft office can be installed in windows and IOS systems and MS word comes up as a pre-installed app in android and IOS.

Microsoft package starts at $5 user per month with a business essential package with 1TB cloud storage in Onedrive. The next package comes with a full version of office(MS word, powerpoint, excel, outlook, publisher and one-note ) with $8.25 per month. Office business premium package costs $12.50 per user month with the access of the full version of the office suite, exchange online mail, IM and conferencing via skype for business.

Google Docs –

Google Docs is a web-based platform that changes the way of edit and shares docs in the modern web. We don’t need to download software or purchase office packages because we can work on it online.

All we need to do is just log in with our Google account in any internet browser and head over to docs.google.com.
Google comes with great Third-party app integration. We can add a third-party apps CRM system and project management for merge tools and contact update plugins.
Google Drive (cloud storage ) is more popular. It gives you 30 GB for business and unlimited storage as you subscribe to a monthly business package.
Google also supports offline mode but it also requires access to an internet connection to work properly.

Google docs support both android and IOS devices and we can install it on any computer and browser. Like windows, I Mac, Linux, and chrome. But not supportable in windows phone.

Google docs is free for every user with limitations. But If you want to purchase business G suit, it costs $5 per user and $10 per user for per month for google unlimited with unlimited cloud storage and advanced features including e-discovery, retention, insight, and audit, etc.

ref:-https://codersera.com/blog/google-docs-vs-microsoft-office/
xConnect Upgrade to 9.2 – Where did the web request handlers go?
Tags: sitecore, xconnect
Published: 2019-09-05 11:48:48

---
title: xConnect Upgrade to 9.2 – Where did the web request handlers go?
published: true
tags: Sitecore,xConnect
canonical_url: https://jasonstcyr.com/2019/09/05/xconnect-upgrade-to-9-2-where-did-the-web-request-handlers-go/
---

Recently, I needed to update my xConnect Tutorial from 9.0 to 9.2 so I could start looking at the new data purge API (more on that another day). I figured it should be an easy enough upgrade, my tutorial wasn’t doing anything complicated. Just some basic Create Contact or Register Interaction stuff. So, I did the usual: Update Target … [Continue reading xConnect Upgrade to 9.2 – Where did the web request handlers go? →](https://jasonstcyr.com/2019/09/05/xconnect-upgrade-to-9-2-where-did-the-web-request-handlers-go/)
How can I plan interviews around a strict work schedule? 
Tags: career
Published: 2019-09-05 11:07:16

**Question**: *I am currently working as a software developer and I am thinking about leaving my current job - but getting time off to interview is proving difficult. My current employer is really strict about time. I can't book leave less than a month in advance, and sick days must be accounted for. What can I do?*

**Answer**: Businesses are practical and understand the constraints on people's time. You'll find many are willing to interview candidates outside 9-5. Skype and video interviews are also popular, offering more flexibility to candidates. 

The key thing is to be upfront with your recruiter about your availability and what you can and can't do. They're the middle-person between you and the employer. They'll ensure practicalities like interview times are agreed upon ahead of time. Keep them in the loop. 


*Agree? Disagree? We would love to know your thoughts*.