teleren/devto huggingface dataset:
First steps with Elasticsearch & Laravel
Tags: laravel, elasticsearch
Published: 2018-08-11 13:42:29

---
title: First steps with Elasticsearch & Laravel
published: true
tags: laravel,elasticsearch
canonical_url: https://medium.com/@treggats/first-steps-with-elasticsearch-laravel-8883c3c0dbe5
---

![](https://cdn-images-1.medium.com/max/1024/1*VXdzDpO_KNegDIdMdO1OkA.png)

After working with Solr in past employment, I’ve alway been interested in indexing large amounts of data and processing that.

So recently I was told to look into Elasticsearch and I’ve been following the [How to integrate your Laravel app with Elasticsearch](https://blog.madewithlove.be/post/how-to-integrate-your-laravel-app-with-elasticsearch) post by [Tony Messias](https://twitter.com/tony0x01) from [Made with love](https://madewithlove.be).

As it turns out that it’s actually quite simple, the Eloquent model that needs to be indexed has a trait which contains a created and deleted event. These are actually Model observer events, which determine if a piece of data should be indexed by Elasticsearch.

```php
public function saved ($model)
{
    $this->elasticsearch->index([
        'index' => $model->getSearchIndex(),
        'type' => $model->getSearchType(),
        'id' => $model->id,
        'body' => $model->toSearchArray(),
    ]);
}

public function deleted ($model)
{
    $this->elasticsearch->delete([
        'index' => $model->getSearchIndex(),
        'type' => $model->getSearchType(),
        'id' => $model->id,
    ]);
}
```

The first part was about getting data into Elasticsearch, the second part is about getting that data from Elasticsearch and presenting it on the Laravel side. Tony’s article is using a repository to interact with Elasticsearch. In that repository the following method is present to do the searching part.

```php
private function searchOnElasticsearch (string $query): array
{
    $instance = new Article;

    $items = $this->search->search([
        'index' => $instance->getSearchIndex(),
        'type' => $instance->getSearchType(),
        'body' => [
           'query' => [
              'multi\_match' => [
              'fields' => ['title', 'body', 'tags'],
                    'query' => $query,
                ],
            ],
        ],
    ]);

return $items;
}
```

It returns an array with the data it retrieved from Elasticsearch, which in turn can be used by Laravel as a data source.

So these were my first steps with Elasticsearch, I like how easy it actually was setting this up. Next is implementing this in a personal project, and trying to learn more about Elasticsearch in the meantime.
Hi, I'm Ayrton!
Tags: introductions
Published: 2017-07-04 15:31:33

---
title: Hi, I'm Ayrton!
published: true
description: My introduction post
tags: introductions
---

I'm still a programmer in progress.

You can find me on GitHub as [amarcazzo](https://github.com/amarcazzo)

I live in Buenos Aires, Argentina.

I work for Cummins S.A.

I mostly program in these languages: C#, Javascript.

I am currently learning more about React.JS, Mean.JS, Angular.

Nice to meet you.
YAHOO password recovery CONTACT YAHOO tec-h SUPPORT CARE
Tags: techsupport
Published: 2017-07-04 15:30:02

---
title: YAHOO password recovery CONTACT YAHOO tec-h SUPPORT CARE
published: true
description: yahoo teh support yahoo customer support

tags: tech support
---

I have been coding for [number] years.

You can find me on Twitter as [@AlbertParker71](https://twitter.com/AlbertParker71)

I live in [city].

I work for [company]

I mostly program in these languages: [languages].

I am currently learning more about [topic].

Nice to meet you.
Hi, I'm Abati Adewale
Tags: introductions
Published: 2017-07-04 14:57:04

---
title: Hi, I'm Abati Adewale
published: true
description: My introduction post
tags: introductions
---

I have been coding for 5 years.

You can find me on Twitter as [@Ace_KYD](https://twitter.com/Ace_KYD)

I live in Lagos, Nigeria.

I work for Hirefreehands.tech

I mostly program in these languages: PHP and Javascript.

I am currently learning more about Front End development.

Nice to meet you.
Hi, I'm Juan Blanc
Tags: introductions
Published: 2017-07-04 14:47:37

---
title: Hi, I'm Juan Blanc
published: true
description: My introduction post
tags: introductions
---

I have been coding for 3 years.

You can find me on Twitter as [@Juanstdio](https://twitter.com/Juanstdio)

I live in Buenos Aires.

I work for Automatismo S.R.L.

I mostly program in these languages: C,C++, Python, NodeJS, Arduino.

I am currently learning more about ReactJS.

Nice to meet you!
Hi, I'm diegobaqt
Tags: introductions
Published: 2017-07-04 14:42:06

---
title: Hi, I'm diegobaqt
published: true
description: My introduction post
tags: introductions
---

I have been coding for three years.

You can find me on GitHub as [diegobaqt](https://github.com/diegobaqt)

I live in BogotÃ¡.

I work for Geekcore. 

I mostly program in these languages: C#, Javascript, and Python.

I am currently learning more about Xamarin.

Nice to meet you.
Multi-stage Dockerfile for Golang application
Tags: go, docker
Published: 2017-07-04 14:31:56

---
title: Multi-stage Dockerfile for Golang application
published: true
description: Dockerfile multi-stage builds and Golang example
tags: go, golang, docker
---

![multi-stage](http://pliutau.com/multi-stage.png)

A common workaround for building Golang application in Docker is to have 2 Dockerfiles - one to perform a build and another to ship the results of the first build without tooling in the first image. It called `Builder Pattern`.

Starting from Docker `v17.0.5` it's be possible to do it via single Dockerfile using multi-stage builds.

### Application

Let's start with "Hello world" application:
```
package main

import "fmt"

func main() {
	fmt.Println("Hello world!")
}
```

### Single Dockerfile

With multi-stage builds, a Dockerfile allows multiple FROM directives, and the image is created via the last FROM directive of the Dockerfile.

`COPY –from=0` takes the file `app` from the previous stage and copies it to the `WORKDIR`. This basically copies the compiled go binary created from the previous stage.

The `--from` flag uses a zero-based index for the stage. You either reference stages by using offsets (like `--from=0`) or by using names. To name a stage use the syntax FROM [image] as [name].

```
FROM golang:1.8.1

WORKDIR /go/src/github.com/plutov/golang-multi-stage/

COPY main.go .

RUN GOOS=linux go build -o app .

FROM alpine:latest
RUN apk --no-cache add ca-certificates

WORKDIR /root/

COPY --from=0 /go/src/github.com/plutov/golang-multi-stage/app .

CMD ["./app"]
```

### Build and check size

```
docker build .
```

Container size now is small, because it contains only binary file.
```
docker ps
REPOSITORY          TAG     IMAGE ID            CREATED           SIZE

golang-multi-stage  latest  bcbbf69a9b59        6 minutes ago     6.7MB
```

[Original article is posted on my blog](http://pliutau.com/multi-stage-dockerfile-for-golang-application/)
Hi, I'm Sai Charan
Tags: introductions
Published: 2017-07-04 12:26:14

---
title: Hi, I'm Sai Charan
published: true
description: My introduction post
tags: introductions
---

I have been coding for 1.5 years.

You can find me on Twitter as [@saiicharan](https://twitter.com/saiicharan)

I live in Bangalore.

I work for Quintype

I mostly program in these languages: JavaScript, Ruby and Clojure.

I am currently learning more about Rails and clojure.

Nice to meet you!
A First Look at Google Compute Engine
Tags: gcp, aws, exploration
Published: 2017-07-04 11:30:46

---
title: A First Look at Google Compute Engine
published: true
description: Exploring Google Compute Engine as a first time user
tags: GCP, AWS, Exploration
---
Note: This is a continuation of [my post](https://dev.to/kyle/a-first-look-at-google-cloudplatform) on exploring Google Cloud Platform. There is also a mirror of it on [my personal blog](https://kyle.io/2017/07/first-look-google-compute-engine/).
____

Compute Engine is one of the more important services for me. While I'd love to have all my stuff on managed services like Lambda/Cloud Functions, it's not possible. The fundamentals of GCE are pretty similar to EC2, but there's a few interesting features that would be interesting to see EC2 adopt (if ever).

Pros:
1. The GCE console supports SSHing to an instance within your browser. There's also automatic [auto SSH key adding](https://cloud.google.com/docs/permissions-overview#google-compute-engine-access-to-instances----using-ssh), something which had annoyed people (me) using EC2. You can still have a master SSH keypair, but you can also add keypairs for individual users.
2. Linux OSes (Debian, CentOS, etc) are natively supported, not "support for Amazon Linux, and maybe other distros". This is pretty much required for some of the stuff that GCE is offering. The auto-key pair adding? Done by a daemon waiting for instructions. Said daemon has been added to the OS for you.
3. Custom machines types (mix and match memory and CPU cores). I'd love to see EC2 adopt this, but it's not going to happen any time soon.
4. Sustained usage discounts: *No reserved instances required for discounts*
5. Premptible instances have a 24 hour limit, unlike EC2's spot block of max 6 hours. Having a fixed price means you don't have to worry about bill shock. Tradeoff is that there's no _spot instance_ equivalent, where if your bid is high enough, the instance will practically never be terminated.
6. Live migration for maintenance events! It's coming to EC2 (it's in the Xen mainline), just a question of when.


Cons:
1. No security groups equivalent
2. Firewall rules applied to [the entire VPC](https://cloud.google.com/compute/docs/vpc/firewalls#firewall_rules_in_gcp), or specific labelled instances (I suppose you could bludgeon this into security groups).
3. No comparison graphing. Are they depending on external providers (ie Datadog) like they do for sending email? (Yes, the creators of GMail recommend [using another party to send email...](https://cloud.google.com/compute/docs/tutorials/sending-mail/))
4. The bandwidth out prices. Google might have a super awesome network, with private backhaul to endpoints that are close... but that is more expensive than AWS.

Also, it's subjective, but I find that the GCE console UI is a lot cleaner than EC2's.
Hi, I'm Felipe Maza
Tags: introductions
Published: 2017-07-04 09:08:04

---
title: Hi, I'm Felipe Maza
published: true
description: My introduction post
tags: introductions
---

I have been coding for 11 years.

You can find me on GitHub as [felipem775](https://github.com/felipem775)

I live in Spain.

I work for IH Cantabria

I mostly program in these languages: [Javascript, Python, C#, Bash, etc.].

I am currently learning more about Javascript.

Nice to meet you.
Comparing error handling in Java, Go and Rust.
Tags: java, go, rust
Published: 2017-07-04 08:13:41

---
title: Comparing error handling in Java, Go and Rust.
published: true
description: Which one does it the best? Let's compare them and see!
tags: java, go, rust
---

Error checking is everywhere. Sometimes it's more complex than other time. Take file managing for example. You have to remember to close the file every time you return... If it's not automatic.

Let's see how Java does it. First, we'll look at Java 6-.
```Java
BufferedReader reader;
try {
    reader = new BufferedReader(new FileInputStream("test.txt"));
    // read file
    if (condition) {
        // closed by finally block
        return;
    }

    // closed by finally block
} catch(Exception e) {
    // do proper error handling
    // closed by finally block
} finally {
    try {
        reader.close();
    } catch(Exception e) {
        // do proper error handling
    }
}

System.out.println("File read");
```
Oh my God. OK, that is HORRIBLE. Let's see how Java 7+ does.
```Java
try(BufferedReader reader = new BufferedReader(new FileInputStream("test.txt"))) {
    // read file
    if (condition) {
        // automatically closed
        return;
    }

    // automatically closed
} catch(Exception e) {
    // do proper error handling
    // automatically closed
}

System.out.println("File read")
```
That is... very good. Congrats, Java. Let's see how Go does it.
```Go
file, err := os.Open("test.txt") // no semicolon :(
                                 // i love semicolons :(
if err != nil {
    // do proper error handling
}
defer file.Close()
// read file
if condition {
    // closed by defer
    return
}

fmt.Println("File read")
// File closed on return, so you probably wanna return ASAP
```
One thing to note with Go: Independent error handling. You can't handle all errors clumped together. This is GOOD. This let's you specify where exactly it went wrong. Errors in Go are also pretty much strings. You make a custom error with errors.New("oh no"). Good stuff
Now let's take a look at Rust.
```Rust
{ // Start a new scope. You don't *have* to do this
    let file = match File::open("test.txt") {
        Ok(file) => file,
        Err(err) => {
            // do proper error handling
            return;
        }
    };
    // read file
    if condition {
        // out of scope - automatically closed
        return;
    }

    // out of scope - automatically closed
}

println!("File read");
```
After writing this, I had to look at the code again, thinking "that's it".
Like you can see, I clearly like Rust's the most. Java 7's is also good. Go's is good, but defer statements only execute on function end, not scope based. You can of course close it manually, but that sucks too.
On the other hand, Go error types are amazing to work with. `errors.New("custom error")` is amazing. Java's is not too bad, but Rust's is "worst" for us lazy people, but also the most powerful. Plus there are macros that fix this.
Hi, I'm Aaron Liu
Tags: introductions
Published: 2017-07-04 07:37:49

---
title: Hi, I'm Aaron Liu
published: true
description: My introduction post
tags: introductions
---

I have been coding for [number] years.

You can find me on GitHub as [liujavamail](https://github.com/liujavamail)

I live in [china].

I work for [shinetech]

I mostly program in these languages: [ruby,js,node].

I am currently learning more about [js].

Nice to meet you.
Hi, I'm Critico de la RazÃ³n
Tags: introductions
Published: 2017-07-04 05:25:49

---
title: Hi, I'm Critico de la RazÃ³n
published: true
description: My introduction post
tags: introductions
---

I have been coding for 4 years.

You can find me on Twitter as [@ExtraOmnes87](https://twitter.com/ExtraOmnes87)

I live in Morelia.

I mostly program in these languages: C#, VB, Java and a little bit of PHP.

I am currently learning more about Mobile Applications.

Nice to meet you.
Hi, I'm Abhi
Tags: introductions
Published: 2017-07-04 04:10:08

---
title: Hi, I'm Abhi
published: true
description: My introduction post
tags: introductions
---

I have been coding for 5 years.

You can find me on Twitter as [@abhiondemand](https://twitter.com/abhiondemand)

I live in New York City.

I work for Teachers Pay Teachers.

I mostly program in these languages: Javascript, Elixir, Ruby.

I am currently learning more about Elixir and GraphQL.

Nice to meet you.
Hi, I'm Jesus Castro
Tags: introductions
Published: 2017-07-04 03:09:37

---
title: Hi, I'm Jesus Castro
published: true
description: My introduction post
tags: introductions
---

I have been coding for [5] years.

You can find me on GitHub as [castrojr913](https://github.com/castrojr913)

I live in [Medellin, Colombia].

I work for [Self-Employee]

I mostly program in these languages: [Java, C#, Swift, PHP, Kotlin, CSS, HTML, TypeScript, and JavaScript].

I am currently learning more about [Software Architecture].

Nice to meet you.
Hi, I'm AndrÃ©s Valle
Tags: introductions
Published: 2017-07-04 02:56:30

---
title: Hi, I'm AndrÃ©s Valle
published: true
description: My introduction post
tags: introductions
---

I have been coding for 20 years.

You can find me on Twitter as [@4v4ll3](https://twitter.com/4v4ll3)

I live in Santiago de Chile.

I work for Intellego (sort of)

I mostly program in these languages: Java, Javascript and PHP.

I am currently learning more about OHI and AngularJS.

Nice to meet you.
Hi, I'm Hofmann
Tags: introductions
Published: 2017-07-04 01:24:15

---
title: Hi, I'm Hofmann
published: true
description: My introduction post
tags: introductions
---

I have been coding for 1 years.

You can find me on Twitter as [@hraortiz](https://twitter.com/hraortiz)

I live in AlcalÃ¡.

I work for ME!!!!

I mostly program in these languages: Java, PHP, .NET.

I am currently learning more about: .NET, XAMARIN.

Nice to meet you.
Hi, I'm Israel HernÃ¡ndez
Tags: introductions
Published: 2017-07-04 01:09:05

---
title: Hi, I'm Israel HernÃ¡ndez
published: true
description: My introduction post
tags: introductions
---

I have been coding for four years.

You can find me on GitHub as [iKronyck](https://github.com/iKronyck)

I live in San Salvador.


I mostly program in these languages: Php, Java, Android and Javascript(AngularJS).

I am currently learning more about AngularJS and ASP .NET(C#).

Nice to meet you.
Hi, I'm Stephen Brown
Tags: introductions
Published: 2017-07-04 00:49:11

---
title: Hi, I'm Stephen Brown
published: true
description: My introduction post
tags: introductions
---

I have been coding for 7 years.

You can find me on GitHub as [stembro](https://github.com/stembro)

I live in Denver.

I work for Sopheon

I mostly program in these languages: JavaScript, C#.

I am currently learning more about front-end development, design, mongo, functional programming.

Nice to meet you.
Hi, I'm Xuetxi
Tags: introductions
Published: 2017-07-03 23:42:52

---
title: Hi, I'm Xuetxi
published: true
description: My introduction post
tags: introductions
---

I have been coding for [number] years.

You can find me on GitHub as [Xuetxi](https://github.com/Xuetxi)

I live in [city].

I work for [company]

I mostly program in these languages: [languages].

I am currently learning more about [topic].

Nice to meet you.
Hi, I'm matti-b-kenobi
Tags: introductions
Published: 2017-07-03 23:22:40

---
title: Hi, I'm matti-b-kenobi
published: true
description: My introduction post
tags: introductions
---

I have been coding for 3 years.

You can find me on Twitter as [@whiteanvil](https://twitter.com/whiteanvil)

I live in Melbourne.

I work for Driver Lane

I mostly program in these languages: JavaScript.

I am currently learning more about Angular 4, Auth0, Online payments.

Nice to meet you.
Hi, I'm AndrÃ©s Felipe
Tags: introductions
Published: 2017-07-03 23:12:57

---
title: Hi, I'm AndrÃ©s Felipe
published: true
description: I'm a student of computer engineering
tags: introductions
---

I have been coding for 2 years.

You can find me on Twitter as [@_AndresAlvarez2](https://twitter.com/_AndresAlvarez2)

I live in MedellÃ­n.

Study at the Colombian Polytechnic Jaime Isaza Cadavid.

I mostly program in these languages: Javascript, C#.

I am currently learning more about Web development and Mobile development.

Nice to meet you.
Hi, I'm Jaime Tapia
Tags: introductions
Published: 2017-07-03 23:00:14

---
title: Hi, I'm Jaime Tapia
published: true
description: I'm web developer in Cartagena Colombia actually learning xamarin cross platform 
tags: introductions
---

I have been coding for [3] years.

You can find me on Twitter as [@certain269](https://twitter.com/certain269)

I live in [cartagena].

I work for [mamonal]

I mostly program in these languages: [c#].

I am currently learning more about [xamarin].

Nice to meet you.
Hi, I'm Barrett Simms
Tags: introductions
Published: 2017-07-03 22:29:41

---
title: Hi, I'm Barrett Simms
published: true
description: My introduction post
tags: introductions
---

I have been coding for 27 years.

You can find me on GitHub as [wbsimms](https://github.com/wbsimms)

I live in Austin, TX.

I work for DevFoundries

I mostly program in these languages: C# and JavaScript.

I am currently learning more about NoSql.

Nice to meet you.
Hi, I'm ulises jasso
Tags: introductions
Published: 2017-07-03 21:50:11

---
title: Hi, I'm ulises jasso
published: true
description: My introduction post
tags: introductions
---

I have been coding for 2 years.

You can find me on Twitter as [@alucard1503](https://twitter.com/alucard1503)

I live in Mexico City.

I work for Business + Web 2.0

I mostly program in these languages: PHP, Java and C#.

I am currently learning more about Web Services.

Nice to meet you.
Five Minute Accessibility: Buttons
Tags: design, development, a11y, webdev
Published: 2018-08-13 18:08:21

---
title: Five Minute Accessibility: Buttons
published: true
tags: design,development,accessibility,web-development
canonical_url: https://medium.com/@kenneth_larsen/five-minute-accessibility-buttons-78338335892d
---

![](https://cdn-images-1.medium.com/max/1024/1*_4NojzFjpzBM4vGMiAoYPw.jpeg)<figcaption>Photo: Émile Perron</figcaption>

It seems that a lot of frontend developers either don’t know about coding for accessibility or they don’t care. Of course, it can be hard to implement in organizations with no focus on accessibility. But it’s always a developer’s (and designer’s) responsibility to develop an inclusive web.

In the series _Five Minute Accessibility_ I will introduce one simple thing you can do to improve accessibility in your projects. In this post you’ll learn about buttons.

### Buttons

Buttons are used for triggering actions or events such as submitting a form or closing a modal. They are so common that most developers has stopped thinking about how to properly code a button. Sadly, the result is rarely accessible.

A rule of thumb when creating buttons is that they should be able to be navigated by the tab key . This is achieved by adding tabindex=”0" . They should also have the role of a button by adding role=”button”.

Generally there are three types of buttons which are [WAI-ARIA supported](https://www.w3.org/WAI/intro/aria).

- The ordinary button
- The toggle button
- The menu button

The ordinary button is a button in its simplest form. You can press it and it triggers an action or event.

The toggle button has two states which are either on or off. To signal a assistive technology that this is a toggle button you should specify a value for the attribute [aria-pressed](https://www.w3.org/TR/wai-aria-1.1/#aria-pressed). It is very important that the label on a toggle button does not change value when pressed. In some cases the aria-pressed attribute can be avoided if by design a toggle button switches label from _mute_ to _unmute_. That way context is provided by the labels.

The menu button can display a menu that is usually hidden when the page is loaded. You can help assistive technology know that the button is a menu button by using [aria-haspopup](https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup). This attribute indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.

Be aware that a lot of assistive technology uses the keyboard to trigger button actions. The native `<button>` element automatically supports triggering actions by using enter or space but if you do not use the native element then please test that it works with enter and space.

### Examples

{% gist https://gist.github.com/kennethlarsen/72ce7f9efd2f0c610984594f0c125990 %}

To sum up: Always check if your buttons can be triggered by pressing space and enter and always make sure you can navigate your buttons using the tab key.

---

You can follow me on [Twitter](https://www.twitter.com/kennethlarsen).
Hi, I'm Daniel Golant
Tags: introductions
Published: 2017-07-03 18:18:26

---
title: Hi, I'm Daniel Golant
published: true
description: My introduction post
tags: introductions
---

I have been coding for 6 years.

You can find me on Twitter as [@dangolant](https://twitter.com/dangolant)

I am currently wandering the US on my way to the west coast.

Most recently, I worked for Salesforce, and previously I interned at USAA and UPS.

I mostly program in Javascript, Python, C#, and before that, mostly Swift.

I am currently learning more about deep learning and getting back to basics on algorithms (#InterviewLife).

Nice to meet you.