Skip to content

Instantly share code, notes, and snippets.

View danilosilvadev's full-sized avatar
🎯
Focusing

Danilo Silva danilosilvadev

🎯
Focusing
View GitHub Profile
@danilosilvadev
danilosilvadev / Dagger2InThreeMinutes.java
Last active May 31, 2017 13:48
Dagger2 in 3 minutes
//SHALL WE BEGIN?
//FILE 1 - THE MODULE
@Module //MODULE IS WHAT YOU WANT TO INSTANTIATE.
public class UserLoginModule {
@Provides //@PROVIDES RELEASE THE OBJECT TO INJECTION.
@PerActivity //@PERACTIVITY IS THE SCOPE, LIKE BOUNDS WHERE YOU CAN USE THAT.
public UserModel getUser(){
@danilosilvadev
danilosilvadev / LambdaExpressionsInLessThanTwoMinute.md
Last active April 27, 2021 21:07
Lambda Expressions in less than 2 minutes

Sample:

Fact 1 - Consider the methods has 2 parts: HEAD(public void nameOfMethod(Input input)) and BODY({Everything inside the keys}).

//without lambda you still use the HEAD as always.
    public void printName() {
        System.out.println(“Print without lambda”);
 }
@danilosilvadev
danilosilvadev / RxJavaExamples.java
Created March 29, 2017 19:23 — forked from ariesmcrae/RxJavaExamples.java
RxJava examples using Java 8 Lambda. Examples include zip, map, take, filter, reduce
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import rx.Observable;
import rx.Observer;
import rx.functions.Func2;
public class RxJavaExamples {
//MODULE
@Provides
@PerActivity
public Retrofit provideRetrofit(Gson gson, OkHttpClient okHttpClient) {
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create(gson))
.baseUrl(BASE_URL)
.client(okHttpClient)
//converts Retrofit response into Observable
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
package gorick.gradesprojectandroid.MVP.Model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.text.DecimalFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
package votos;
import java.util.Scanner;
public class Votos {
Scanner e;
public static void main(String[] args) {
int idade;
//FILLE 1- MAVEN
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@danilosilvadev
danilosilvadev / ES2015In20Minutes.js
Last active June 7, 2021 15:25
A quick guide to reference the ES06
//This gist is a fast reference to ES06 to whose already knows es05.
//I'm trying to use a different approach: first the example and after the explanation.
//Lesson 1: Template literals
console.log(`hello ${firstname},
how are you?`);
//Template literals are string literals with support for interpolation(using ${variable}) and multiple lines.
import React, { Component } from 'react'
const List = props => {
let list = props.list;
const itensList = props.list.map((list) => {
return <li key={list.id}>
<span>{list.id} - {list.item}</span><br />
<button onClick={() => this.handleReplace(list.id)}>Replace</button>
<button onClick={() => this.handleDelete(list.id)}>Delete</button>
</li>;
{
"presets": [
"react",
"es2015"
],
"plugins": [
"react-hot-loader/babel"
]
}