Skip to content

Instantly share code, notes, and snippets.

package easy.datastructures.linkedlist;
public interface DoublyLinkedListBehaviors<T> extends LinkedListBehaviors<T> {
}
@francbreno
francbreno / Array.java
Created August 8, 2019 18:09
Array & DynamicArray in Java
package easy.datastructures.array;
import java.util.Arrays;
import java.util.Iterator;
@SuppressWarnings("unchecked")
public class Array<T> implements Iterable<T>, ArrayBehaviors<T> {
protected T[] array; // Internal structure. FIXED length
protected int len; // the number of elements added to the array
package playground
import scala.annotation.tailrec
import scala.io.StdIn
import scala.util.Random
trait Action {
def actionType(): String
}
package playground.java.covariance;
import java.util.ArrayList;
public class CovarianceOnMethodInvocation {
public static void main(String[] args) {
new CovarianceOnMethodInvocation().run();
}
public void run() {

Scala - OO

Classes and Constructors

class declaration (with a primary constructor):

class MongoClient(val host: String, val port: Int)
@francbreno
francbreno / example.js
Last active May 18, 2018 13:19
A super simple generic crud with knex
const db = require('./connect')();
const crudServices = require('./knexCrud')(db);
const serviceFactory = require('./serviceFactory')(crudServices);
const App = function(serviceFactory) {
const accountsService = serviceFactory('accounts');
const usersService = serviceFactory('users');
return {
getAllAccounts: () => accountsService.getAll(),
alter table entries add column transaction_id integer references transactions(id) not null;
select * from accounts
insert into transactions(value, description, destiny_account_id, origin_account_id)
values(5800.00, '05/2018 Salary', 19, 17);
insert into entries(value, account_id, transaction_id)
values(-5800.00, 17, 7);
@francbreno
francbreno / PrivateRoute.js
Last active September 12, 2018 15:31
Um componente para rotas privadas em React utilizando render props no lucar de um HoC
const logado = false;
const PrivateRoute = ({ render, ...rest }) => (
<Route
{...rest}
render={props =>
logado ? (
render(props)
) : (
<Redirect
import { createStore, combineReducers, applyMiddleware } from 'redux';
import { Provider, connect } from 'react-redux';
import thunk from 'redux-thunk';
import { v4 } from 'uuid';
// Users -------------------------------------------------------------------------------
const ADD_USER = 'ADD_USER';
const addUserAction = (user) => ({
@francbreno
francbreno / App.js
Last active October 26, 2017 15:51
Um HoC para controle de autenticação com Firebase. Testando umas ideias
import React, { Component } from 'react';
import './App.css';
import LoginForm from './loginForm';
import RegistrationForm from './registrationForm';
import ConsumptionForm from './consumptionForm';
const PrivateContent = ({ user, children }) => (
<div>
<img alt="user avatar" src={ user.photoURL }/> { user.name } | { user.email } |