teleren/devto huggingface dataset:
Loading your local files in TerminusDB
Tags: database, data, developer
Published: 2020-03-16 18:24:59

---
title: Loading your local files in TerminusDB
published: true
date: 2020-01-21 00:00:00 UTC
tags: Data Science,Database,Data,Developer
canonical_url: http://blog.terminusdb.com/2020/01/21/loading-your-local-files-in-terminusdb/
cover_image: http://blog.terminusdb.com/assets/images/cowduck_banner.jpeg
---

We have got lot’s of feedback since we have posted our tutorial — [My First TerminusDB Graph Visualisation](https://medium.com/terminusdb/my-first-terminusdb-graph-visualisation-bike-share-data-39c59a1ab86a?source=friends_link&sk=2f877df5dcb2f00b9e4e85d5088f015e). One of the most common questions is how to load a local CSV in the hard drive into your TerminusDB running in a local docker container. So here is how to do it.

* * *

If your container is running stop it with:

```
./terminus-container stop

```

> Extra tip: you may want to run `./terminus-container rm-config` now before you mount the volume. This remove old settings to advoid version conflits that may comes in later if there’s a newer version of Docker image avaliable.

set the `TERMINUS_LOCAL` environment variable to the path to the parent directory of your csv:

```
export TERMINUS_LOCAL=/home/me/somewhere

```

> for Windows users:
> 
> ```
> export TERMINUS_LOCAL=c:/Users/you/somewhere
> 
> ```
> 
> Go to Docker Desktop Settings and make sure that the Drive (i.e. ‘C’) your file on is enabled in Shared Drives

![Windows setup](https://miro.medium.com/max/2474/1*YYgIRufPKRw724nIuWRHzw.png)Make sure the ‘C’ is clicked and ‘Apply’

then start your container again:

```
./terminus-container run

```

now, `TERMINUS_LOCAL` will be mounted as `/app/local_files`so, in your WOQL query, you can use:`.file(/app/local_files/myfilename.csv)` instead of `.remote()`

* * *

Hope it helps with lot’s of you who want to load csv locally.Thanks [Dmytri Kleiner](https://twitter.com/dmytri/status/1219391128287555586) for figuring it out!
If you lost the use of your hands, how would you code?
Tags: discuss
Published: 2020-01-20 22:55:27

Seriously, So this has been a question on my mind for some time, if for some reason you couldn't use your hands anymore, would you want to carry on coding and how might you do it, similarly if you went blind.

I wonder what the employment rates are and how these sorts of life changes could be overcome for a professional programmer.
Using Emoji on Linux
Tags: linux, emoji, usage, keyboard
Published: 2020-01-20 22:45:36

In this post, i will show you how to using emoji on your Linux system.

###Step.1

Install emoji-keyboard:

**Arch Linux based;**
`yay --noconfirm --noeditmenu -S --aur aur/emoji-keyboard-git`
or pamac or octopi `emoji-keyboard-git`

**Debian Based;**
`sudo add-apt-repository ppa:atareao/atareao`
`sudo apt update`
`sudo apt install emoji-keyboard`

It's easy way to using emojis on Linux systems.

Now commands for this package

```
emoji-keyboard -h //for help
-k //toggle visibility for emoji window
-s //toggle search emoji window
-p // for preferences window
-q // for quit
-v // for version
```

Also you can add this command to shortcuts.

Eg.
`emoji-keyboard -k` to Meta + . (dot key)

###Screenshot
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/0bgphzeqbta6wg5m9zz2.png)
the DEVTO community has let me down for the first time - i am gutted 
Tags: webdev, quickstart, howto
Published: 2020-01-20 22:34:18

ive just stepped through 6 different howto / quickstart / to  "create an X app in N minutes" postings total spending a total of over 60 mins 

all of you know who you are (i think i have posted bug reports in a comment to your post) please fix your posts and restore my faith in the up until now PERFECT devto :(

UPDATED 24 jan 20
to be fair it seems the official vendor docs are  also broken
Golang MIME type handling
Tags: go, todayilearned
Published: 2020-01-20 22:30:57

Media types, also known as MIME types, are a standard that indicates the nature and format of some data. You most likely met media types in HTTP requests, send to and received from the webserver as HTTP headers, ex: `Content-Type: application/javascript`.

Golang standard library provides support for MIME types through two APIs:
 - the `mime` package, which has functions for retrieving the MIME type given a file extension:
    ```
    fmt.Println(mime.TypeByExtension(".txt"))
    // Output: text/plain; charset=utf-8
    ```
 - the `http.DetectContentType` function which, given a fragment of a file, returns its MIME type:
    ```
    fmt.Println(http.DetectContentType([]byte("some text content of a file")))
    // Output: text/plain; charset=utf-8
    ```

Even if they work as intended, these two approaches have their limitations. `mime` can be easily tricked: anyone can change the extension of a file from .exe to .jpg. `http.DetectContentType` on the other hand is  a more careful option, as it looks at the actual data in a file. However it suffers from a limited number of detected MIME types, with notable missing entries for office documents, audio files and some archives.

Beyond the standard library is the land of user libraries where Go has three candidates for MIME types libraries:
 - [github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype)
 - [github.com/rakyll/magicmime](https://github.com/rakyll/magicmime)
 - [github.com/h2non/filetype](https://github.com/h2non/filetype)

Out of the three, magicmime is the most accurate, but it requires C cross compilation and libmagic-dev installed. The other two implemented the detection algorithms in pure Go, so they can just be imported. Out of them, mimetype features a bigger list of supported MIME types, but most importantly the identification is deterministic, unlike filetype which [returns different results when testing the same data](https://github.com/h2non/filetype/issues/38#issuecomment-515245746).

Reference experiment: [https://github.com/ppai-plivo/go-mime-lib-compare](https://github.com/ppai-plivo/go-mime-lib-compare)
Steps to auto Firebase deployment using GITHUB Actions (CI/CD)
Tags: firebase, github, cicd, webdev
Published: 2020-01-20 22:27:17

### Step #1

Create a GITHUB repository

###Step #2

Create a Firebase Project on the Firebase console

### Step #3

```
$ firebase init
```


And choose your project and select Hosting from the CLI tool

### Step #4
Create package.json using

```
$ npm init
```

Once the package.json created add the following component on the JSON under scripts

```
"build:production": "node --version",
"build:prod": "node --version",
```
The final package.json will look like this

package.json
```
{
  "name": "cicd",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build:production": "node --version",
    "build:prod": "node --version",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/muthugit/cicd.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/muthugit/cicd/issues"
  },
  "homepage": "https://github.com/muthugit/cicd#readme"
}
```

### Step #5
Create the workflow file (main.yml) on the following directory

```
$ <root directory>/.github/workflows
```

main.yml

```
name: FIREBASE-DEPLOY

on:
  push:
    branches:
    - master
    - release/*


jobs:
  firebase-deploy:


    runs-on: ubuntu-latest


    steps:
    - uses: actions/checkout@master
    - uses: actions/setup-node@master
      with:
        node-version: '10.x'
    - run: npm install
    - run: npm run build:prod
    - uses: w9jds/firebase-action@master
      with:
        args: deploy --only hosting
      env:
        
        FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
```        
        
### Step #6
Get the Firebase token by running this

```
$ firebase login:ci
```

### Step #7
1. Goto `GITHUB.com` and navigate to your repository
2. Goto Settings -> Secrets
3. Create new secret
4. Copy the secret generated on the previous step and name the secret as FIREBASE_TOKEN

### Step #8
Thats it! Just push your code. This will deploy the PUBLIC folder to firebase hosting
How to localize f.label by i18n in Rails (日本語化)
Tags: rails
Published: 2020-01-20 22:19:54


### 1. add two lines to config/application.rb
```ruby
    config.i18n.default_locale = :ja
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]

```

### 2. create new file on config/locales/

I named the file `models.ja.yml`.

```ruby
ja:
  activerecord:
    models:
      user: ユーザー
      admin: 管理者
      medium: メディア
    attributes:
      user:
        id: ID
        email: メールアドレス
        password: パスワード
        password_confirmation: パスワードの確認
        current_password: 現在のパスワード
        remember_me: ログイン状態を記憶する
      admin:
        id: ID
      medium:
        media: メディア
```
Cloud Animation (Pure CSS)
Published: 2020-01-20 22:08:29

Hello, Devs!

This is my first post
Should any of you have the need for a cloud animation in your projects,
I've got just the thing!

::before & ::after elements can save you tons of headache

Let's reverse-engineer a better world together!



{% codepen https://codepen.io/zemposPen/pen/bGNQmgX %}
[Go] for-select with timer
Tags: go
Published: 2020-01-20 22:07:21

"for-select" is very important in golang for non-blocking operation. "Timer" is a good partner with for-select to handle timeout and performance issue.

In this post, I show some use cases, how for-select with timer work together.

## Timeout

Listen to 2 channels, if no receive from any channel in 1s, it goes to the timeout case
```go
	for {
	    select {
		case a := <-ch1:
			fmt.Println(a)
		case b := <-ch2:
			fmt.Println(b)
		case <-time.After(time.Second):
                // timeout, do something
		}
      }

```

## Interval
Sometimes we can see new gophers write the following code:
```go
	for {
	    select {
		case a := <-ch1:
			fmt.Println(a)
		case b := <-ch2:
			fmt.Println(b)
		default:
                // always non-block here, 
		}
             // no interval, run this for-loop intensively
      }
```
Then most of usage CPU maybe occupied because of intensive non-blocking infinite loop.  We could use timeout case to avoid it, or add interval to entire for loop like this.
```go
	for {
	    select {
		case a := <-ch1:
			fmt.Println(a)
		case b := <-ch2:
			fmt.Println(b)
		default:                     
		}
        <-time.After(time.Second) // or time.sleep(time.Second)
      }
```
The for loop now has 1s interval.

## Timer
Sometimes we would like to set timer to break for-loop.
You may implement like following code:
```go
    t := time.NewTimer(time.Second * 5)
	loop:
		for {
			select {
			case a := <-ch1:
				fmt.Println(a)
			case b := <-ch2:
				fmt.Println(b)
            case <-time.After(time.Millisecond *500):
            case <-t.C:
				break loop
			}
        }
```
The code works, but there's a potential issue in this implementation. Be careful, "select" statement chooses any non-blocked case randomly, for example, even if  the timer is fired, select can pick up another cases when they're non-blocked.
So we can improve it by adding another select statement.
```go
    t := time.NewTimer(time.Second * 5)
	loop:
		for {                        
			select {
			case <-t.C:  // if timer is fired, break the loop 
				break loop
			default:    // timer is not fired, non-blocked 
			}

			select {
			case a := <-ch1:
				fmt.Println(a)
			case b := <-ch2:
				fmt.Println(b)
			case <-time.After(time.Millisecond *500):			
			}

	}
```

I think these are common use cases for for-select with Timer.
If any mistake and question, please feel free to write comments.
Randomising Flex Order of Items
Tags: codepen, flex, flexorder, javascript
Published: 2020-01-20 21:21:20

This all stems from a random conversation this week, where a colleague was fiddling with the layout of our new website. She essentially wanted a row of vendor logos to display, but in the era of responsive web design, not cram 8 of them onto a mobile screen, and not use 3 of them to fill up a laptop, so our initial idea was to simply use media queries to hide/show certain ones.

Not bad, but not brilliant, it just seems a bit static and there's too much chopping and changing, we could do with it being a bit more fluid. That's when she came up with these 2 brilliant lines of code that got rid of the need for any media queries at all!:

```css
.logos-container {
  /* other styles such as display: flex; and flex-flow: row wrap; */
  height: same-as-logos-height; /* They're all png files set to the same height */
  overflow: hidden;
}
```

So that's the cramming issue sorted, and all these logos can now be displayed on a large screen, with only 2 or 3 of them on a mobile. But now there's another problem:

A mobile user will only ever see the first 2 or 3 logos that are in the markup, and may never see the rest of the vendors we work with!

Kate: "It would be good to be able to randomise these."

Me: "Well there's flex-order that can change the order of how things appear no matter where they are in the markup, so I reckon that would be the answer. Randomising though? I'm not sure CSS can do that."

Enter JavaScript.

Me: "I promise you, there is a way to do this and I will find that way."

Me a few days later: "Here it is!":

{% codepen https://codepen.io/gavinsykesuk/pen/VwYEzXQ %}

This was also my first step into using either a CSS or HTML preprocessor. I'd always viewed these tools in the past with a "well, what's the point?" attitude, but have started slowly warming to them. Certainly, HAML's ability to do for loops and create a lot of divs without having to change x lines of code to tweak them all slightly I found very helpful. Plus, change one number and you get more or fewer items, no mass deletion and no copying and pasting multiple times! SCSS is also another string to the bow, and I believe its ability to manage large-scale projects may well come in useful in the future.
New Found Passion pt.2
Tags: html, css, coding, learning
Published: 2020-01-20 21:14:43

Recap:

"The problem was that the exhaustion seemed to kill this new found passion for coding, and I did not open my laptop for weeks. Why couldn't we just stick to the beautiful HTML & CSS like any healthy human being? Why did we have to dive into JS when life was so much easier without it?

After a few weeks of rest I kept thinking about coding, but what's coding without coding?"
----

That's how my 2019 ended.
The year is now 2020 and I am back at coding class!!!
We went back to the beginning, but this time we knew the basics so we started diving deeper, and I am loving it.

I have heard the phrase "let it marinate" many times, and it seems like it finally worked for me. Apparently, staying away from coding for a few weeks did it's trick. My brain feels refreshed and coding has become one of my favourites daily activities.

I do rest when I need to, but I keep feeling like everything is possible if I just sit for a few minutes to play with VS Code, so I do it and I am having fun.

What's next? JavaScript. There's no way around it, but I have a new found confidence, and I am ready for the challenge. 

Off to read "Eloquent JavaScript, chapter 1" - Chao!
CKAD - Service Types
Tags: kubernetes, devops, linux, docker
Published: 2020-01-20 20:49:02

Services can be one of the following four types:

* **ClusterIP**
* **NodePort**
* **LoadBalancer**
* **ExternalName**

**ClusterIP** is the default and only provides access **internally**

**NodePort** is great for when static IP addresses are necessary, such as opening a specific IP through a firewall. It is a simple connection from a high-port routed to a **ClusterIP** using iptables or ipvs. **The creation of a *NodePort* generates a *ClusterIP* by default**. The traffic is routed from the *NodePort* to the *ClusterIP*.

**LoadBalancer** was created to pass requests to cloud provider like AWS. The address is made available to public traffic and packers are spread among the Pods in the deployment automatically.

**ExternalName** allows the return of an alias to an external service. It is used for **services not yet brought into the Kubernetes cluster** (a bit like a placeholder). Once those services are *ready* we can then change the type and traffic would flow to the internal objects.

```
kubectl proxy creates a local service to access a ClusterIP which can be useful for troubleshooting
```

## Exposing an application with a Service

We can use `kubectl expose` command which exposes a resource as a new Kubernetes service.

## Ingress

An ingress is an API object that manages external access to the services in a cluster, typically HTTP.

Ingress can provide:
* load balancing
* SSL termination
* name-based virtual hosting

## Service Mesh

We can implement a service mesh for more complex connections or resources, such as service discovery, rate limiting, traffic management and advanced metrics. 

A service mesh consists of edge and embedded proxies communicating with each other and handling traffic based on rules from the a control plane.

Typically we use [Envoy](https://www.envoyproxy.io/) and [Istio](https://istio.io/)
How to animate or transition multiple linear-gradient backgrounds from a single element
Tags: help, css
Published: 2020-01-20 20:46:01

Trying to emulate this Codepen but with a single link element and the animated underline wraps with the text. [https://codepen.io/dragontheory/pen/JjorrKL](https://codepen.io/dragontheory/pen/JjorrKL)

![Text with animated underline](https://thepracticaldev.s3.amazonaws.com/i/r6znybmoeihtnc6mfroi.gif)

One way to have an underline wrap with the text is to use background linear gradients. Like this solid line at this Codepen...

[https://codepen.io/dragontheory/pen/XWJydQE](https://codepen.io/dragontheory/pen/XWJydQE)

![Underline that wraps with text.](https://thepracticaldev.s3.amazonaws.com/i/96v9ymfa8xfcgfwno28l.JPG)

Then add **three** identical background linear-gradients colored the same as the background. 

_Not sure if `backgroundColor` or `currentBackgroundColor` (like `currentColor`) - is a valid property..._

Three identical 6x1 background linear gradient shapes:

```
linear-gradient(backgroundColor, backgroundColor) left bottom / 6px 1px no-repeat,
linear-gradient(backgroundColor, backgroundColor) left bottom / 6px 1px no-repeat,
linear-gradient(backgroundColor, backgroundColor) left bottom / 6px 1px no-repeat;
```
Then animate or transition them on top of the solid underline (from **left bottom** to **right bottom**), giving the illusion of broken lines. 
And then stagger them (see first Codepen above). 
```
  /* Staggered delay */
  animation: break01 2s infinite,
             break02 2s 0.5s infinite,
             break03 2s 1s infinite;
  
}
@-webkit-keyframes "break01" {
  from { background-position: left bottom; }
  to { background-position: right bottom; }
}
@-webkit-keyframes "break02" {
  from { background-position: left bottom; }
  to { background-position: right bottom; }
}
@-webkit-keyframes "break03" {
  from { background-position: left bottom; }
  to { background-position: right bottom; }
}
```
So the question is **how to animate or transition multiple linear-gradient backgrounds from a single element**?

Hope that makes sense. 

No idea if this is the best way. Open to ideas. 

Anyone?
chromium browser screenshot extension
Tags: browser, screenshots, extensions
Published: 2020-01-20 20:20:40

do you even need a chromium browser screenshot extension ? 

firebox now has screenshots "built in" and i read somewhere that chromium devtools can take screenshots ! see below (its DEVTOOLS | RUN CMD | CAPTURE SCREENSHOT )

the chromium extension store lists dozens so for 'end users' - but many seem fake 

here are a few that i need to add to my "need to take a look at" todo list unless you can point me to the best of the bunch for a webdev
* https://nimbusweb.me/note.php
* https://www.getcloudapp.com/pricing
* https://www.uploadme.me/
* https://freeimage.host/

geek hack to get a chromium screenshot
* open MENU | DEVTOOLS | DEVTOOLS MENU | RUN CMD | SCREENSHOT 

![dev tools run cmd screenshot](https://thepracticaldev.s3.amazonaws.com/i/qa5pbokmmql788v46dz5.png)
Improving microservices reliability with Two Phase Commit
Tags: microservices, architecture
Published: 2020-01-20 20:11:21

Hi everyone! Today I would like to talk a bit about how we can improve reliability between microservices. This is the first article of a series and we'll be focusing on the Two-Phase-Commit technique.

It has been a while since [my last article](https://www.davideguida.com/its-dangerous-to-go-alone-take-this/), this is the first one I write from Montreal. I moved here last November to work with a local Fintech Company, [Fiska](https://www.fiska.com).

So, let's suppose you're working on a microservices architecture and you need to have them talk each other in some way. An isolated service is not that useful, we have to share some data with the rest of our system. Maybe you're working on the next Amazon or Neflix, who knows!

![just a bunch of microservices talkin'.](https://i1.wp.com/www.davideguida.com/wp-content/uploads/2020/01/amazon-netflix-microservices-1.png?resize=788%2C412&ssl=1)


Let's make a simple example. Imagine a user placing an order on an ecommerce. The Orders microservice receives the command, stores the data in its persistence layer and then needs to inform all the interested parties. For example a Notifications service that will send emails to the customer and the admins.

#### Of course we don't want emails to be sent if the Orders microservice fails to process the command.

One possible approach is the famous [Two-Phase-Commit](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) (aka 2PC):

![Two Phase Commit](https://i2.wp.com/www.davideguida.com/wp-content/uploads/2020/01/20200104_172203-scaled.jpg?resize=788%2C266&ssl=1)

As you can easily guess, it's a two-step process:

 The Coordinator service asks all the participants if they are ready to commit the transaction. They can reply with a yes or no. Note that if a single service replies with a no ( or a timeout or any other error), the full transaction is automatically canceled. 
If all the participants have answered yes, the Coordinator sends the Commit command to them and waits for the final ack.

Although functional, there are few drawbacks with this approach. First of all, it comes with an intrinsic performance penalty as we're putting the all the actors on hold multiple times awaiting for an answer.

Secondly, in some cases it may be possible that other transactions triggered in between are paused till the whole process completes.

#### Moreover, if the Coordinator fails for some reason at the beginning of Phase 2, all the other services are left hanging in a limbo-state.

Don't get me wrong, 2PC is a good approach, but as all the other tools in our belt we need to know when we it can be used. For example it's extremely useful when replicating data among a cluster of db replica nodes.

So, going back to our ecommerce microservices, [in another article](https://www.davideguida.com/improving-microservices-reliability-part-2-outbox-pattern/) we'll see how can we can leverage the Outbox Pattern to safely notify our services when an order has been placed. 

Au-revoir!
Channel to share knowledge
Tags: productivity, webdev, carrer
Published: 2020-01-20 20:05:17

Hey Everyone,

After a while working with programming Stuff and get stuck many times I have decided to 'build' a discord channel for everyone who wants to join, beginner, junior, senior, expert, everyone!

# What's the purpose?

I just want to open a space where all of us can share knowledge with other people, help with side projects and collabs every member.

## What I need to join?

Nothing!!! Just an account with discord and join via this link below

[Discord Channel](https://discord.gg/htPynH)

## What can I do in the channel?

You can chat with other members(write or talk) and get experience for members with a tons of experience. Other side If you are skilled, you can discuss with another expert members and make change of ideas.

### Probably here you can discuss some career advices from expert members!

Hope to see everyone there!