teleren/devto huggingface dataset:
Need help with sql (*_*) !
Tags: help, database, sql, rails
Published: 2019-09-18 14:23:25

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/n4os6b57lr6yzipw5d8n.png)
hi dev's 

While working on a "hospital management system" demo project using rails.I stucked in a scenario where I need to pull "firstname" from users table. Here is detailed scenario ...

So Here are my tables : 
```
table1 : appointments has following columns 
         id|patient_id|physician_id|
```
```
table2: patients table                  table3: physicians table
         id|user_id|...                      id|user_id|...
```

table4: users (note that users table as 4 types of user admim,patient,physician and nurse )

```
      id|firstname|lastname|role|.....
```

** Here user_id refers to users table primary key 
** patient_id and physician_id refers to patients and physicians primary key

Now how can i fetch "firstname" from users table from appointments table???? 

As of now i am using following code to print appointments but this is to costly 

```ruby
# frozen_string_literal: true

module Admin
  # Appointment actions
  class AppointmentsController < ApplicationController
    before_action :new_user

    def index
      @appointments = paginate(fetch_records)
      respond_to do |format|
        format.html { @appointments }
      end
    end

   .
   .
   .

    private

    def fetch_records
      @appointments = current_user.admin? ? Appointment.all :    Appointment.current_user(current_user.physician)

      @appointments.collect do |appointment|
        [
          appointment.id, appointment.patient.user.firstname,
          appointment.physician.user.firstname, appointment.status,
          appointment.appointment_date
        ]
      end
    end
  end
end

```

rails --versin  : rails 5.2.3
ruby --version: 2.6.3
The “Natural order” misconception
Tags: sql, misconceptions
Published: 2019-09-18 09:04:49

Full version first published on [my blog](https://zoharpeled.wordpress.com/2019/09/08/the-natural-order-misconception/).


A common misconception is that rows in a relational database table has some inherent order. This is not true.

So many developers falls victim of this misconception, even though it’s being repeatedly refuted in multiple professional blogs and forums that I figured it can’t hurt to write about that in one more place.

I want to make this absolutely clear: 

# Relational database tables are unsorted by nature.

In the relational model published by E.F. Codd, relation are defined as an unsorted set of tuples. 
In relational databases, relations are implemented as tables, and tuples are implemented as rows, and while it is true that rows are stored inside the database in a specific order, 

**there is no relational database that guarantees the order of the rows returned from a `select` statement without an `order by` clause.**

Even if you do specify an `order by` clause, if the values of the column(s) listed in the `order by` clause are not unique, there order of the rows where such duplicate values exists is also arbitrary.

A quick example (T-SQL):

```sql

CREATE TABLE Demo
(
    Id int NOT NULL,
    Val char(1) NOT NULL
);

INSERT INTO Demo(Id, Val) VALUES 
(1, 'A'), 
(2, 'A'),
(3, 'B'),
(4, 'C');

-- 1: -- No order by clause at all
SELECT Id, Val
FROM Demo;

-- 2: -- Order by a constant
SELECT Id, Val
FROM Demo
ORDER BY @@SPID
 -- In SQL Server, @@SPID Returns the session ID of the current user process. 
 -- This order the rows using a constant value.

-- 3: -- Order by a non-unique value
SELECT Id, Val
FROM Demo
ORDER BY Val;
```

In examples 1 and 2 above, (no order by and order by a constant) are completely equivalent - the database is free to return the rows at any order.

In example 3 there's a column with duplicate values (at least for some of the rows) in the `order by` clause - so the rows that contains the duplicate value are arbitrarily ordered - there are two legitimate results for this query:

Both 
```
Id	Val
1	A
2	A
3	B
4	C
```
and
```
Id	Val
2	A
1	A
3	B
4	C
```

can be returned by the database.

Please note that this rule also holds true for window functions such as `row_number()` and `rank`.
Weekly Picks #93 — Development Posts
Tags: webdev, javascript, career, css
Published: 2019-09-18 13:41:05

* [Top Five Programming Languages For Jobs and for the Future](https://app.dailynow.co/r/10da689a0a8d50f5259cc6265c5c47ea)
* [Tips from a Junior Front-End Developer](https://app.dailynow.co/r/41fb06e2464769a0724881974ff60f39)
* [Must-Know Algorithms for Coding Interviews](https://app.dailynow.co/r/4e7d6c9c03931694a18b0b0f48e9c283)
* [Create Cool Nebula Background Effect with Three.js](https://app.dailynow.co/r/b90d00f69f2e6038c58bc2b6ac62e0aa)
* [Add dark mode to your site with this short CSS trick](https://app.dailynow.co/r/5c6809c39d2b3c1aa0c3b557cc1bd291)
* [The State of REST in 2019](https://app.dailynow.co/r/993d07ab1f029aa319fb989b4617efee)
* [Dadroit API Studio — A designer for HTTP APIs](https://app.dailynow.co/r/4487de5435e98afcdfd0064751efe0fc)
* [How we wrote the Fastest JavaScript UI Frameworks](https://app.dailynow.co/r/b342950114d113e7579f276e725a0300)
* [Mockadillo — Mock your entire API in minutes.](https://app.dailynow.co/r/977e51d392b055d9f4a205b7172a8460)
* [Must Know Data Structures for Coding Interviews](https://app.dailynow.co/r/fba1ad2bfacbe62125b06d3ceea6fd09)

* * *

[_Thanks to Daily_](https://www.dailynow.co/) _developers can focus on code instead of searching for news. Get immediate access to all these posts and much more just by opening a new tab._

[![Daily promotion cover](https://cdn-images-1.medium.com/max/1024/1*7bwIhcH467BKX5Ni8XWpQg.jpeg)](https://www.dailynow.co/)
Geocod.me - Looking for beta testers
Tags: showdev, help, geocoder
Published: 2019-09-18 13:40:47


During our internal hackathon at [Armada](https://www.getarmada.app/?ref=geocod.me&join=1), I created a [Geocod.me](https://geocod.me) which allows any developer to <mark>extract geolocation</mark> data from various inputs like <mark>text, image and IP</mark>. This service can also be used to <mark>forward and reverse geocode</mark>.

This idea came from frustration of not finding decent service in the Geocoding space. There are several services in the market which provide geocoding solutions, but most of them are <mark>either too pricey or lack precision</mark>.

###Current Features###

* Get latitude and longitude from placename and address (Forward Geocoding)
* Get placename/address from latitude and longitude (Reverse Geocoding)
* Get locations from text (Geoparsing)
* Extract GPS and EXIF data from images
* Lookup your visitor/users's geolocation from IP
* Upload CSV with your location data and convert them to addresses (Bulk Geocoding)


##Looking for beta testers##

Currently, I am looking for beta testers to try out [Geocod.me](https://geocod.me) and provide feedback. 

If you think this service could help <mark>you or your company/organisation</mark>, and you want to try out beta while we refine offerings then please head over to [Geocod.me](https://geocod.me) and register for beta invites.
Geocod is <mark>free during beta period</mark> and there will be generous discounts when we launch for beta testers.

<mark> Please reach out to me via comment if you need more info, happy to talk.</mark>
Trying to Nail Jelly to the Tree
Tags: powerbi, discuss
Published: 2019-09-18 13:37:45

Does a **moving** target in IT make you nuts?

When a developer tool changes **every month**, do you get lost?

When is too much progress too much?

Let me tell you about my user experiences with Power BI in the last six months.

I call it **churn**.

Every month Microsoft releases a new version of Power BI.

Great I say.

But **wait...**

I cannot rely on my old knowledge about how the tool works, I have to relearn it each month.

They make real nice videos and release notes about all the changes.

But changes that move features, menus, and user clickable area around, it feels like I **start all over again** learning every month. Kind of a "Groundhogs Day" repeating itself.

Lets **inspect** this situation a little more closely.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/hzgev0ec325qx6fj072h.jpg)

I agree with making **progress** by creating new features for a tool or enhancing the functionality, fixing bugs.

But at what cost?


All of this **came to a head** when I went to a SQL Saturday in Redmond and one of the tracks I picked was about advanced features in Power BI.

The presenter was a well known **expert**, book author, blogger, and lecturer about Power BI.

He gave a quick introduction with PowerPoint and then it was no more slides.

**Demo** time!

So the presenter proceeded to **try** to demo live how to make some very nice graphs and dashboards.

I say try.

Every time he tried to find a particular control or button or what ever, **he failed.**

He was getting REAL frustrated.

What are power users at your client's office suppose to do? They cannot take time every month to relearn the tool, they have **real** work to do.

So much for **self service BI**.

The last time the presenter had practiced the demo was a **few weeks** before the SQL Saturday meeting.

In that middle time, Microsoft had released a **new version** of Power BI.

What chance do us mere mortals have if the expert struggles.

A few people in the audience had just used the newest version and **shouted out** some help every time the presenter got stuck.

The churn got him.

It was like he had goggles on.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/yv5g5qpp65busoje6hl6.jpg)

Rebuttals I have heard

I mentioned this whole subject of my **frustration** with the churn to another developer, and his reaction was, oh well.

That is not an answer.


What do you think about the churn?

What should Microsoft do **to help** developers get up to speed each month?

How can we as developers pass on this new monthly knowledge to our clients?




I will leave you with this:

They say, "The early bird gets the worm". I say look what happened to the worm when he got up early :}
What made your internship worthwhile?
Tags: career, beginners, help, discuss
Published: 2019-09-18 13:32:20

Our company loves interns. With so many local colleges encouraging co-ops, we are able to keep a healthy supply of interns year-round. In my opinion, interning at our small company provides awesome exposure to lots of different facets of web development, but while they get to do a lot of coding, the internship doesn't offer too much career development. What were some of your favorite or most helpful experiences your internship provided?
Let's upload images from ReactJS app to Firebase Storage easily... 😉
Tags: react, javascript, redux, webdev
Published: 2019-09-18 13:10:43

For a while I have been searching for a good article on uploading images to the `Firebase Storage` via a `ReactJS` app with `Redux`. Unfortunate me, I have not found any understandable reference with clear, sure shot, straightforward answers. All of them wee pointing somewhere else. Therefore, I created my own tutorial just going through the Firebase documents. Hope you will find it helpful. 

The basic idea is that we first upload the image to the Firebase storage and then we save the URL of the image to a Firestore collection for later retrieval. It as simple as that.

The tutorial I wrote is on my GitHub repo's readme file.

Please find it from [here](https://github.com/Niweera/fsuptutorial)

If you find it helpful, please don't forget to share it with others and hit a star and it will just makes me happy... 🙃🙃🙃

If you find any issues or have any questions please send me a message and I'll try my best to answer it. 

Until next time, Peace... 
😁😁😁
Navigating Boundless Data Streams With The Swim Kernel - Episode 98
Published: 2019-09-18 13:05:15

<p>The conventional approach to analytics involves collecting large amounts of data that can be cleaned, followed by a separate step for analysis and interpretation. Unfortunately this strategy is not viable for handling real-time, real-world use cases such as traffic management or supply chain logistics. In this episode Simon Crosby, CTO of Swim Inc., explains how the SwimOS kernel and the enterprise data fabric built on top of it enable brand new use cases for instant insights. This was an eye opening conversation about how stateful computation of data streams from edge devices can reduce cost and complexity as compared to batch oriented workflows.</p><p><a href='https://www.dataengineeringpodcast.com/swimos-data-streams-episode-98/'>Listen Now!</a></p>
Cultivating The Python Community In Argentina
Published: 2019-09-18 13:04:19

<p>The Python community in Argentina is large and active, thanks largely to the motivated individuals who manage and organize it. In this episode Facundo Batista explains how he helped to found the Python user group for Argentina and the work that he does to make it accessible and welcoming. He discusses the challenges of encompassing such a large and distributed group, the types of events, resources, and projects that they build, and his own efforts to make information free and available. He is an impressive individual with a substantial list of accomplishments, as well as exhibiting the best of what the global Python community has to offer.</p><p><a href='https://www.pythonpodcast.com/facundo-batista-python-community-argentina-episode-229/'>Listen Now!</a></p>
What Can an IT Guy Blog About?
Tags: programming, softwareengineering, technology, startup
Published: 2020-02-12 21:35:28

---
title: What Can an IT Guy Blog About?
published: true
date: 2019-09-18 13:03:59 UTC
tags: programming,software-engineering,technology,startup
canonical_url: 
---

[![](https://cdn-images-1.medium.com/max/2600/0*7ApzatcQpRmtdTPQ)](https://medium.com/@ali.dev/what-can-an-it-guy-blog-about-aef69123c8a9?source=rss-3a534b5053e6------2)

There are lots of things to blog about in IT.

[Continue reading on Medium »](https://medium.com/@ali.dev/what-can-an-it-guy-blog-about-aef69123c8a9?source=rss-3a534b5053e6------2)
Episode 5 - Adding resources to your Client
Tags: showdev, tutorial, go
Published: 2019-09-18 12:34:06

> So after being at the Alps for some days, here we go again.

## What is a resource?

According to [https://restful-api-design.readthedocs.io](https://restful-api-design) a resource is described as follows:

> The fundamental concept in any RESTful API is the resource. A resource is an object with a type, associated data, relationships to other resources, and a set of methods that operate on it. It is similar to an object instance in an object-oriented programming language, with the important difference that only a few standard methods are defined for the resource (corresponding to the standard HTTP GET, POST, PUT and DELETE methods), while an object instance typically has many methods.

This means that when adding a resource this will allow us to perform operations with our client on specific and well defined types.

## How to add a resource to a client?

1. We create a resource type to hold the methods to interact with articles, this will contain a pointer to our `devto.Client` implementation, 

```go
// articles.go

type ArticleResource struct{
    API *Client // this will receive a pointer to your client instance
}
```

And then we attach this using the client constructor

you can see a working example in the repository

{% github VictorAvelar/devto-api-go %}

From now on, we are up for the wtfutil part.
How I installed Oracle JDK 8 in Ubuntu 18.04.1 LTS
Tags: java8, oraclejdk, ubuntu
Published: 2019-09-18 12:08:47

---
title: How I installed Oracle JDK 8 in Ubuntu 18.04.1 LTS
published: true
description: Oracle Java (JDK) 8 Installer PPA (DISCONTINUED)

tags: java 8, oracle jdk, ubuntu 
---

<p>
Today I tried installing JAVA in my new Ubuntu system and followed the conventional method of downloading it through ppa:webupd8team/java oracle-java8-installer following <a href="https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04" target="_blank">this link</a>.

Even though I successfully installed the default JDK and JRE, I was not able to install Oracle JDK which was needed for Android Studio.

After some research, I found out through <a href="https://launchpad.net/~webupd8team/+archive/ubuntu/java" target="_blank">this link</a> that as of April 16, 2019, you won't be able to download Oracle JDK without signing in to an Oracle account. <a href="https://stackoverflow.com/questions/55920389/e-package-oracle-java8-installer-has-no-installation-candidate" target="__blank">This</a> stackoverflow answer too helped me.

With all these help these are steps I followed to install Oracle JDK.


- Download the latest JAVA 8 SE development kit from <a href="https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html" target="_blank">here</a> after creating or signing in to the Oracle account.

- Open your terminal and type 
    ```
    $mkdir /opt/jdk
    ```
- Untar Java in your new folder 
    ```
    $tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk
    ```
- I installed using these commands (don't forget to replace <YourVersion> with the one you installed.)

    ```
    $update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_<YourVersion>/bin/java 100
    $update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_<YourVersion>/bin/javac 100
    ```
- To set oracle JDK as the default JVM, run 
    ```
    $sudo update-alternatives --config java
    ```
    and select the Oracle JDK that you installed. And also do the same for java compiler, 
    ```
     $sudo update-alternatives --config javac
    ```

- Set the JAVA_HOME Environment Variable using the following commands.
     ```    
      $sudo nano /etc/environment
    ```
    add this line
    ```
    JAVA_HOME="/opt/jdk/jdk1.8.0_<YourVersion>/bin/java" 
    ```
    and save the file, exit. Now reload and check using,

    ```
    $source /etc/environment

    $echo $JAVA_HOME
    ```

- Check if the java version is right 
    ```
    $java -version
    ```

Hope this helped you.
CodeTips first Open Source Project
Tags: showdev, go, twitter
Published: 2019-09-18 11:57:22

CodeTips are proud to announce our first Open Source project, RSS-Twitter.

Take one or more RSS feeds and automatically tweet new articles. 

There is still a way to go (e.g. improving the README), but it's officially "live".

https://github.com/RealCodeTips/RSS-Twitter
How Do You Get In The "Coding Zone"?
Tags: agile, discuss
Published: 2019-09-18 11:55:15

*It's a beginning of a new sprint, and you're hungry to get started on knocking your stories/tickets out. You've got a fresh new development story that you're eager to get started on. You've already got the solution all figured out and you know your implementation will be fool-proof.*  


You grab your beverage of choice, tune your headphones to your "Code Rush" playlist, and code away. 

Then it hit's you: You've magically entered "The Zone" where your thoughts are clear and your code is swift(no pun intended). You suddenly become a 10x Developer, and have no doubt in your mind that your code will be bug free.



Even when you run into minor set backs in your code - a variable spelled incorrectly (who needs intellisense?) - you still press on.

Some would argue this feeling is caffeine induced; But I have experienced it without any stimulants plenty of times. 

So the question is: how do you get yourself into this unique mode of productivity? 

Is there anything you do to force yourself into this state?

When you're in it, what do you feel when it comes to your thinking?
The Swift Programming Language Companion: Introduction
Tags: ios, swift, beginners
Published: 2019-09-18 11:27:29

This is part of a series that will help guide you through reading [The Swift Programming Language](https://docs.swift.org/swift-book/) from Apple.

The intended audience for this guide are people that don't know Swift and possibly don't know any other programming language.

I wrote previously that [the best way to get into iOS App development](https://dev.to/loufranco/do-you-know-enough-swift-to-jump-into-an-app-tutorial-96i) was to start with Swift, not an app tutorial. Apple's book is good enough to get started—this companion is meant to help you read it actively. By the time you are done with the book, you should have _written_ a lot of Swift, not just read it.

### Step 1: Set up a reading environment

You need to be able to see the book and an Xcode playground at the same time. That could be side-by-side on your Mac or you could read the book on an iPad.

### Step 2: Set up an Xcode Playground

1. Open Xcode
2. Choose **File > New Playground ...**
3. Choose **Blank**
4. Call it **SwiftBook.playground**
5. Use CMD-1 to open the left sidebar to the Project Navigator. CMD-0 will hide/show this sidebar.
6. Choose **File > New Playground Page** twice (so you have three pages)
7. Name the pages "01-The Basics", "02-Basic Operators", and "03-Strings and Characters". _Note: Playgrounds auto-sort the pages by their name, so using the 00-Title format keeps the pages in the same order as the book._
8. Choose "01-The Basics" in the Project Navigator

It should look like this:

![Xcode sidebar showing playground pages](https://thepracticaldev.s3.amazonaws.com/i/1dzkl6h0dpobhecewse7.png)

### Step 3: Setup

I have a 13" MacBook Pro, so this is kind of tight. Here's what it looks like for me.

![Side by side Xcode and Swift Book](https://thepracticaldev.s3.amazonaws.com/i/b6fj2qkj0pb8d0gip037.png)

### Step 4: Test your Playground

There should be a line of code that looks like this

```swift
var str = "Hello, playground"
```

Put your cursor at the end of that line and type SHIFT-ENTER. This will run the playground up until that line of code (note the playhead on the left -- you could also use the mouse and tap that)

### Step 5: Read and Code

Read the book. Do not copy any code from the book into the playground—type it in yourself. Make sure you understand it before moving on.

After typing a line of code, you can type SHIFT-ENTER to run that line of code. The right side will show you the result.

### What's next

The next post will be a companion to the "The Basics". If you need any help setting up, comment below.