teleren/devto huggingface dataset:
Method Reference
Tags: java
Published: 2021-01-09 15:36:43

Java8 has a function named "Method Reference" that points to a method.

# Before Java8

It needed to create an object, which implements an interface, to refer a method.

```java
public class Main {
    interface IGreeter {
        void greet(String name);
    }

    static void delegate(IGreeter iGreeter, String name){
        iGreeter.greet(name);
    }

    public static void main(String[] args) throws Exception {
        // need to put an object implemented the interface 'IGreeter'
        delegate(new IGreeter(){
            public void greet(String name){
                System.out.println("Hello, " + name + "."); // => Hello, Taro.
            }
        }, "Taro");
    }
}
```

# From Java8

Programmers can use 'ClassName(ObjectVariableName)::MethodName' to refer it.

```java
public class Main {
    
    @FunctionalInterface // This annotation can be omitted
    interface IGreeter {
        void greet(String name);
    }
    
    // This method can work instead of the above greet method.
    static void referredGreet(String name){
        System.out.println("Hello, " + name + ".");
    }
    
    static void delegate(IGreeter iGreeter, String name){
        iGreeter.greet(name);
    }
    
    public static void main(String[] args) throws Exception {
        // can put a method reference as 'ClassName::MethodName'
        delegate(Main::referredGreet, "Taro"); // => Hello, Taro.
    }
}

```

The most notable point is the name of the referred method "referredGreet" can be different from the one "greet" in the interface.

There are two rules.
1. The interface must have only one method.
2. The method of the interface must match the referred one in terms of 'type' of arguments and return value.

The referred method can use the parent type.
For example,

**static void referredGreet(String name){**

can be

**static void referredGreet(Object name){**

In other words, interface method can use sub type of the one of the referred method.

The method reference helps developers to write code simpler
For example,
```java
List<String> list = Arrays.asList("aaa", "bbb", "ccc");
list.forEach(System.out::println); // => aaa
//bbb
//ccc
```

This the spec of 'forEach' method.
https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html#forEach-java.util.function.Consumer-

The referred method (Consumer) must have one argument and void-return.
https://docs.oracle.com/javase/8/docs/api/java/util/function/Consumer.html
System.out::println meets the condition. That's why it can be set to 'forEach'.

# Reference
改訂2版　パーフェクトJava
https://gihyo.jp/book/2014/978-4-7741-6685-8
File format decision tree
Tags: webdev, images, watercooler, jokes
Published: 2021-01-09 15:32:10

---
title: File format decision tree
published: true
description: What picture format should you use? With this decision tree, choosing will be easy :P
tags: webdev,images,watercooler,jokes
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/hdlu5dyutthou2hho3hk.png
---

This is a small decision tree to help with the best file format for each occasion. It is **half serious and half tongue-in-cheek**, and it minimizes the importance of SVG, but it's a good approach on how the decision should be:

<figure>
![Flow chart with different questions and decisions to determine which file format you should use (simplified explanation below)](https://dev-to-uploads.s3.amazonaws.com/i/iwoebf8d9892qi859ze2.png)
<figcaption>Only use BMP when playing with MS Paint</figcaption>
</figure>

Here is a description of when to use each format (as promised in the alt text):

- **BMP**: when your kids are playing with MS Paint.
- **TIFF**: for large professional designs and photographs.
- **GIF**: if it moves.
- **SVG**: if it moves and/or if it is vectorial.
- **AVIF**: if having a small file size is key.
- **WEBP**: if having a small file size is key... and you care about support.
- **PNG**: any other case when transparency is needed.
- **JPG**: any other case.

----

And here it is the same decision tree, edited (with MSPaint maybe?) to show how the file format process goes in reality:

<figure>
![Same flowchart as above, but all the formats are scratched except for GIF, JPG, and PNG. There's a line from BMP to JPG/PNG saying "I love you MSPaint, but who am I kidding?". The question "does it move?" was replaced by "is it a cat video?" and all the paths except that one direct to PNG/JPG](https://dev-to-uploads.s3.amazonaws.com/i/g36trazvcoe1momr1lq8.png)
<figcaption>...or just use PNG for everything...</figcaption>
</figure>

----

On a more serious note, AVIF looks like a promising format. Here, an [interesting article where Jake Archibald compared AVIF with other formats: SVG, PNG, JPG, and WEBP](https://jakearchibald.com/2020/avif-has-landed/).
Mise en place React
Tags: react, typescript, graphql, fauna
Published: 2021-01-09 15:25:55

I _really_ love what React development can _feel_ like nowadays. I wrote (a lot) about how to up the positive feels and momentum of feature development. It builds on the culinary idea of _mise en place_, where you prepare all your ingredients before composing them together to make a dish. I spent a lot of time on this, I'd love to hear your feedback!

I leaned into a lot of [Notion](https://www.notion.so/product) features like toggles and nested pages, so all the content is there but I wanted to share with the dev.to community all the same.

[Full tutorial here](https://www.notion.so/Mise-en-place-React-36806ea5434f4d3eb7c4d49e41af9a30).

Happy ~~cooking~~ coding!

---

Photo by [Icons8](https://unsplash.com/@icons8?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText) Team on [Unsplash](https://unsplash.com/s/photos/cooking?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText).
Redirecionamento automático de página HTML
Tags: html, codepen, braziliandevs, webdev
Published: 2021-01-09 15:09:49

Olá pessoal, hoje irei deixar uma dica rápida de como realizar o _redirect_ (redirecionamento) automático de uma página **HTML** para outra página, pode ser até mesmo para uma página em outro domínio.

Vamos utilizar a _tag meta_ com o atributo _http-equiv_ com valor _refresh_ e também o atributo _content_ com valor em segundos para aguardar e a _URL_ de destino.

```html
<meta http-equiv="refresh" content="10;url=https://franciscochaves.com.br" />
```

Crie uma página HTML e adicione o código acima e observe a página redirecionar sozinha após 10 segundos, se o valor estiver definido como 0 (zero) o redirecionamento é realizado logo após o carregamento da página.

{% codepen https://codepen.io/franciscochaves/pen/oNzMwZp default-tab=html,result %}

Valeu pessoal 😎✌️!
Nuttakit-website-portfolio
Tags: dohackathon, blockchain, flutter, dart
Published: 2021-01-09 15:05:38

## What I built
Personal Site/Portfolio
My website portfolio

### Category Submission: ![desktop-screenshot](https://dev-to-uploads.s3.amazonaws.com/i/ojqdz252kojdelpkbyos.png)
 
Personal Site/Portfolio

### App Link
https://nuttakit-portfolio.web.app/#/

### Screenshots
Desktop Screenshot
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nl8c6pvah4zegx8rge6w.png)

Mobile Screenshot
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d7jl1puijvaxfevcap1s.png)

### Description
Sawasdee Krub everyone!! (Hello from Thailand). Thank you for visiting my site, like I have mentioned before my name is Nuttakit Kundum. I love to meet new people and talk about the idea so feel free to chat with me and talk about yours.
 
### Link to Source Code
https://github.com/NuttakitDW/nuttakit_website


## Background
(What made you decide to build this particular app? What inspired you?)

### How I built it 
I use flutter web to make it and host my web at firebase LoL.
[Série do Instagram - Primeiros passos como backend] Lógica de Programação
Tags: beginners, codenewbie, java, javascript
Published: 2021-01-09 15:05:13

---
title: [Série do Instagram - Primeiros passos como backend] Lógica de Programação 
published: true
description: 
tags: #beginners #codenewbie #java #javascript
//cover_image: https://direct_url_to_image.jpg
---
Olar, recentemente iniciei uma série de posts no instagram com conteúdos e dicas de estudos para quem quer começar a carreira de backend, focando principalmente em Java e Spring (mais detalhes nesse [post](https://www.instagram.com/p/CJGUVXigWuR/?utm_source=ig_web_copy_link)), semanalmente estarei escrevendo um artigo para centralizar os posts da semana e indicar alguns links complementares de estudo, a primeira semana foi sobre lógica de programação e tivemos quatros posts sobre esse assunto:


### [Primeiros passos como backend #1 -  Lógica de programação parte 1](https://www.instagram.com/p/CJn09rwAdwi/)

Nesse post expliquei o que é lógica de programação, o que são algoritmos e como podemos representar um algoritmo.

### [Primeiros passos como backend #2 -  Lógica de programação parte 2](https://www.instagram.com/p/CJn09rwAdwi/)

Nesse post expliquei o que é uma variável, o que é uma constante e como funcionam os desvios condicionais

### [Primeiros passos como backend #3 -  Lógica de programação parte 3](https://www.instagram.com/p/CJs7OW6gdvN/)

Nesse post falei sobre o "escolha-caso" e sobre laços de repetição


### [Primeiros passos como backend #4 -  Lógica de programação parte 4](https://www.instagram.com/p/CJviQy7AtrQ/)

Nesse post indiquei alguns canais no youtube para aprender mais sobre lógica de programação:

[Curso em vídeo] (https://www.youtube.com/playlist?list=PLHz_AreHm4dmSj0MHol_aoNYCSGFqvfXV)

[Bóson Treinamentos] (https://www.youtube.com/watch?v=41ubXTEPFO0&list=PLucm8g_ezqNpYL-z-lutCuBplhx9aqkdd)

[Dev Dojo] (https://www.youtube.com/watch?v=ycyL5CqZoUo&list=PL62G310vn6nH-uBTKREcUWDkOi2Q9n4OZ)

[Stanford algorithms] (https://www.youtube.com/channel/UCH4s4ek5zqNvct5oy9_jd_g)

### Algumas recomendações para aprender mais sobre lógica de programação:


[Lógica de Programação - school of net](https://www.schoolofnet.com/curso/frontend/logica-de-programacao/logica-de-programacao/)

[Lógica de programação -  softblue] (https://www.softblue.com.br/site/curso/id/6/CURSO+LOGICA+DE+PROGRAMACAO+BASICO+ON+LINE+LO06)

[ Lógica de programacao com java - algaworks] (https://s3.amazonaws.com/algaworks-assets/ebooks/algaworks-livro-programacao-para-iniciantes-v1.1.pdf)

[Lógica de Programação com JS] (https://www.youtube.com/watch?v=lxb567HEn8k&list=PL1dUY2RYa2RidB3B134ywckDyf-FOwbv7)

Se conhecer mais algum material gratuito sobre lógica de programação deixa aqui nos comentários :)


Segunda-feira iremos começar a falar de orientação a objetos, já segue o perfil lá no [instagram](https://www.instagram.com/kamila_code/) para não perder nenhum conteúdo :)

Até o próximo post :)
slice( ) and splice( ) array methods in JavaScript
Tags: javascript, beginners, computerscience, codenewbie
Published: 2021-01-09 14:50:02

###**The array slice( ) method**
This method returns a shallow copy or a new array object of a portion of an array. It does not modify (immutable) the original array on which it is called upon. It selects the elements starting at the given start argument, and ends at the given optional end argument without including the last element.
By default, the starting index will be 0 and the last index will be array.length but we can specify what index we want.

**Example:**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ti0s28ger0sm6wn65v46.png)

We observe from the above example that the 'numbers' array is not modified which means we still have the original array.

Now, consider an example where we do not provide any index.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ukzxhyuzrty7rpl6w82a.png)

This simply generates a shallow copy of the original array

What output would we obtain if we passed a negative index. Let's take a look.

**Example:**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/484ilc35fjwxagw94ih0.png)

This prints the last three elements of the array.

Notice that in this array method, the value provided at the last index is not included.

**Remember:** Slice method does not mutate the original array but it returns the subset as a new array, so you can use this method inside a function which receives an array as a parameter, while being sure that you still have the original array.

###**The array splice( ) method**
This array method modifies an array by removing or replacing existing elements in it. It takes the starting index, the count(number of elements you want to remove) and it also optionally takes new elements which are placed at the end of the array.
This method changes the array on which it is called upon and returns an array with the removed or replaced items.

**Example:**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ks0zealex43v95j33gtq.png)

From the above example, we observe that our original array has been manipulated.

Now, consider an example where you want to add additional elements at the end of your array using the splice method.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gz1kpx2uptq5qma49bdy.png)

What if you don't want to delete any element from your array, rather you want to add few elements at a specified position in your original array? Let's take a look at how this can be done:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b7391fipe7lrcpxl3h5l.png)

**Remember:** The splice method mutates your original array on which it is called upon.

Until next time...
Take Care!
Tic Tac Toe Game- #doHackathon
Tags: dohackathon
Published: 2021-01-09 14:41:42

## Tic Tac Toe Game - multiplayer online game

### Category Submission: Random Roulette


### https://tic-tac-toe-build-7s68d.ondigitalocean.app/#/


### Screenshots:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2rvobmcnoyw0ozwi9yj9.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/roqhz4vknw84dnkug95h.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/inj0qa6ojzc4936t7i8u.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zgdmhr3vny817xi4npfu.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8wl5h70xtaues5ys1vav.png)




### Tic tac toe game built with angular and firebase, with realtime multiplayer functionality
 

### https://github.com/peter2796b/tic-tac-toe-online


## Background
I couldn't find any tic tac toe game online that someone could quickly play with their friends online without downloading any app, this a quick way someone could play by sharing the game link.

### How I built it 
This is the first angular app, I wanted to learn angular for a while now.

I used cloud firestore for real-time user response.



### Additional Resources/Info
Day 16 of 100DaysofCode: A Simple Program To Do Bubble Sort
Tags: 100daysofcode, codenewbie, beginners, python
Published: 2021-01-09 14:38:25

Today is my 16th day of #100Daysofcode. I learned more about python code to access web data including retrieving web page using urllib in python, parsing web page, web scraping on. Learned about BeautifulSoup and its important on [coursera.](https://www.coursera.org/learn/python-network-data/gradedLti/lJS5r/assignment-following-links-in-html-using-beautifulsoup)

Learning sorting algorithms little at a time. First one is bubble sort. Attempt one challenge on [Advent of Code 2020](https://adventofcode.com/2020/day/1)

#Program To Do Bubble Sort
Bubble sort is a simple sorting algorithm that repeatedly step through the list, compare adjacent elements and swaps them if they are in a wrong order.

The pass through the list is repeated until the list is sorted. I tried to do one simple program on bubble sort which is given below.
```python
# bubble sort
l1 = [2, 1, 4, 3, 5, 0]

def sort(l1):
    for i in range(len(l1)-1):
        for j in range(len(l1)-i-1):
            if l1[j]>l1[j+1]:
                l1[j], l1[j+1] = l1[j+1], l1[j]
    return l1
sort(l1)

```
Full-Stack with Nullstack
Tags: javascript, webdev, node
Published: 2021-01-09 14:37:53

The first 2 video tutorials of Nullstack are available already!

Nullstack is a full-stack framework for building progressive web applications.

It connects a stateful UI layer to specialized microservices in the same component using vanilla javascript.

Server functions with Nullstack:

{% youtube l23z00GEar8 %}

Routable Components with Nullstack:

{% youtube _i5kKXkhBaM %}

The documentation is available at https://nullstack.app/ for those who prefer text over video.
Software Testers, interested in a browser specially designed for you, with JIRA integration built in?
Tags: testing, discuss
Published: 2021-01-09 14:28:26

Imagine while conducting exploratory testing, you identify  bug. With push of a button, you automatically create JIRA ticket with a repayable user session attached (user session has last page with login form auto chosen as starting step). Developer can then replay same session repeatedly while fixing bug (features exist to make it easy for developer to use their local URL while fixing bug). Once bug is fixed, you can replay the same user session to verify, and close the ticket automatically.

Other features planned: auto-detect forms and fill in with auto-generated data appropriate to the field; easily create variants of steps recorded instead of having to record separate user sessions.

User sessions will be JSON files containing intelligently chosen DOM selectors, and  event information (i.e. for a form field there's usually no good reason to record click x,y). The intent here is to make the user sessions as robust as feasible so if, for ex. an input field is moved somewhere else on the page but retains its 'id', the user session replay is unaffected. If elements can't be located during a replay, instead of session failing it will pause and prompt for tester to perform replacement action, and then continue with rest of replay.

A companion tool is also planned to read these user session files and execute them using selenium, webdriverio, etc. for cross-browser headless testing.

I'm a software developer in the initial stages of developing such a tool and looking to gauge interest.
Notes on Proxies
Published: 2021-01-09 14:27:01


**Reverse Proxy**

* [TCP Proxy](https://cloud.google.com/load-balancing/docs/tcp)
*https://cloud.google.com/load-balancing/docs/tcp*
* [SSL Proxy](https://cloud.google.com/load-balancing/docs/ssl)
*https://cloud.google.com/load-balancing/docs/ssl*
* [Load Balancing] (https://cloud.google.com/load-balancing/docs)
*https://cloud.google.com/load-balancing/docs*
* [Types of Load Balancing] (https://blog.envoyproxy.io/introduction-to-modern-network-load-balancing-and-proxying-a57f6ff80236)
*https://blog.envoyproxy.io/introduction-to-modern-network-load-balancing-and-proxying-a57f6ff80236*
* [AWS Thoughts and Understanding on Load Balancing] (https://aws.amazon.com/elasticloadbalancing/?elb-whats-new.sort-by=item.additionalFields.postDateTime&elb-whats-new.sort-order=desc)
*https://aws.amazon.com/elasticloadbalancing/?elb-whats-new.sort-by=item.additionalFields.postDateTime&elb-whats-new.sort-order=desc*


** Some Good Quotes **

* Not all proxies are load balancers, but the vast majority of proxies perform load balancing as a primary function.
The Idea 💡
Tags: dohackathon
Published: 2021-01-09 14:21:30

Any hackathon needs an idea. So this is where we will start.

In the past year, the world had to face the most difficult challenge in recent history. The pandemic affected millions and millions of people who either lost their job or a loved one.

However, like in any dark event, the best way to overcome it is to look on the bright side of things. Last year showed us some great things: the Human will achieve anything; Nature is always willing to come back in full glory.

 <img src="https://media.giphy.com/media/dSY9GgU0fWS8o/giphy.gif" alt="always look on the bright side of life"> 

This second point is the one that strikes me the most. To see just how quickly Nature can change and adapt. From all around the world we saw drops in carbon emissions, an increase in the air quality in cities, increased water quality of rivers and lakes. Nature is just around the corner trying to restore the balance in our planet. For me, it's time we help it achieve it.

For this hackathon, the idea is to develop a platform that tries to make people a little more environmentally conscious and enable actions to improve our world.

## MVP requirements 📓

- _Users_ can _Report_ 
    - e.g Beach in Bad conditions, Park with trash all over etc..
- _Users_ can create _Events_ that tackle the _Reports_
    - e.g. organizing a Beach or park cleanup, a educational activity to spread awareness
- _Users_ can use _Reputation_ to vote on _Reports_
- _Users_ receive _Reputation_ by supporting _Reports_ that turn into _Events_
- _Reports_ and _Events_ presented must be geographically relevant to the _User_ and _Visitor_


 <img src="https://dev-to-uploads.s3.amazonaws.com/i/sec6kpqz55q4vlyiavhz.png" alt="BeSustainable Logo" width="200"> 

#### Until next time...
How strong do passwords should practically be? And reuse of PIN?
Tags: discuss, security, password, pin
Published: 2021-01-09 14:06:58

I believe even a PIN is strong enough, if you don't name it yourself.

And, if 4-digit or 6-digit PINs are sufficiently practically safe; how could 8-digit password be weak?

Can dictionary attack be done on a PIN, or are hash leakages very rare?

Even if brute force or dictionary attack be done on a password, aren't real world attempt limited (and get locked out of account)?
Need help with React App
Tags: help, react
Published: 2021-01-09 14:05:52

My React app only loads the navbar on localhost:3000/my-profile and on GH pages (https://jenskat88.github.io/my-profile/). Only when 'Home' is clicked does it render the actual homepage as well. I can't figure out why.

https://www.loom.com/share/cd759f10e38b4b02ba590adbc876f8ee

Thoughts as to why?