Skip to content

Instantly share code, notes, and snippets.

View renato04's full-sized avatar

Renato Ramos Nascimento renato04

  • Globant
  • São Paulo - Brazil
View GitHub Profile
@renato04
renato04 / FixedLengthStringToObject.cs
Created June 17, 2021 15:33
How to transform a fixed length string file structure to any object
public class LineDefinitionAttribute : Attribute
{
public LineDefinitionAttribute(int size, int startIndex, string format = "")
{
Size = size;
StartIndex = startIndex;
}
public int Size { get; set; }
public int StartIndex { get; set; }
package example;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.Option;
import com.jayway.jsonpath.internal.DefaultsImpl;
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
import com.jayway.jsonpath.spi.json.JsonProvider;
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
@RunWith(SpringRunner.class)
@WebMvcTest(ExampleController.class)
public class ExampleControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void should_get_metadata_when_video_processed() throws Exception {
this.mockMvc.perform(get("/test"))
package example;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
@renato04
renato04 / assertExampleMockMvc.java
Last active March 9, 2021 11:42
Assert Example MockMvc
this.mockMvc.perform(get("/test"))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.value", is("Olá!")));
@renato04
renato04 / CoinChangeProblemSolver.cs
Last active November 6, 2020 13:29
Class to resolve coin change problem using recursion
public class CoinChangeProblemSolver
{
public int Solve(int[] coins, int ammount)
{
int count(int[] c, int m, int n)
{
// If n is 0 then there is -1 solution
// (do not include any coin)
if (n == 0)
return 1;
@renato04
renato04 / sensorDeSomArduino.c
Created April 13, 2020 14:44
Como identificar palmas usando arduino
const int pino_microfone = A0; // pino onde o potenciometro está conectado
int leitura = 0; // variável para armazenar o valor lido pelo ADC
const int pino_rele = 10; // pino onde o rele está conectado
bool estado_rele = false; // variável para armazenar o estado do rele
float amplitude = 0.0; // armazenará o valor de pico a pico da onda
unsigned int valor_max = 0; // armazenará o valor máximo lido pelo sensor
unsigned int valor_min = 1024; // armazenará o valor mínimo lido pelo sensor
float valor_limite = 4.5; // valor mínimo para considerar uma palma (0.0 - 5.0)
@renato04
renato04 / script.sql
Created January 30, 2020 01:32
SQL Server Spacial Statements
CREATE TABLE Districts
( DistrictId int IDENTITY (1,1),
DistrictName nvarchar(20),
DistrictGeo geometry);
GO
CREATE TABLE Streets
( StreetId int IDENTITY (1,1),
StreetName nvarchar(20),
StreetGeo geometry);
@renato04
renato04 / OptionConverter.fs
Created August 23, 2019 14:16
Convert string list option to an empty list in Json
open System
open Microsoft.FSharp.Reflection
open Newtonsoft.Json
open Newtonsoft.Json.Converters
type OptionConverter() =
inherit JsonConverter()
override x.CanConvert(t) =
t.IsGenericType && t.GetGenericTypeDefinition() = typedefof<option<_>>
@renato04
renato04 / baltimore_cams.R
Created June 6, 2019 00:10
Northest, Southest baltimore cameras
install.packages("openxlsx")
library(openxlsx)
fileX = "https://github.com/elthonf/fiap-mba-r/raw/master/data/cameras.baltimore.xlsx"
directory = 'data'
file.name = basename(fileX)
download = function(f, d){
if(!file.exists(d)){
dir.create(d)
}