Skip to content

Instantly share code, notes, and snippets.

View nikolasrangel's full-sized avatar
👽

nikolas nikolasrangel

👽
View GitHub Profile
defmodule RobotSimulator do
@doc """
Create a Robot Simulator given an initial direction and position.
Valid directions are: `:north`, `:east`, `:south`, `:west`
"""
@valid_directions [:north, :south, :east, :west]
@spec create() :: {:north, {0,0}}
def create(), do: {:north, {0,0}}
@nikolasrangel
nikolasrangel / git.txt
Last active January 6, 2021 20:33
a famosa colinha de comandos git
> log in line
git log --oneline
> retrive all commits by a message
git log --all --grep="corinthians"
> retrieve all commits by an author
git log --author="Nikolas"
> get everything you did
@nikolasrangel
nikolasrangel / mapping_objects.js
Created March 6, 2019 21:47
mapping js objects
const cats = {
Puma: { age: 3 },
Ringo: { age: 4 }
};
const object = Object.keys(cats)
.map(cat => ({[cat]: `age: ${cats[cat].age}`}) )
.reduce((acc, curr) => ({...acc, ...curr}) , {});
/* object:
@nikolasrangel
nikolasrangel / async-await-map.js
Created November 8, 2018 15:10
async/await inside .map()
const asyncFunction = async (arr) => {
const arrOfPromises = arr.map(async param => {
const response = await fetch(`/api/${param}`);
return response.json();
});
const result = await Promise.all(arrOfPromises);
return result;
}
@nikolasrangel
nikolasrangel / dataframe_from_dict.py
Created August 13, 2018 12:32
Creating a Pandas DataFrame from a Python 3 dictionary
import pandas as pd
dict = {'description': 'value'}
dict_items = dict.items()
dataframe = pd.DataFrame(list(dict_items), columns=['Description', 'Values'])
@nikolasrangel
nikolasrangel / README.md
Last active January 3, 2018 01:47
Node.js and Python communication

Node.js + Python

Using the Node.js child_process module to create and use a python3 process to do a sum over an array.

Usage

node father.js