This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Identificaci%C3%B3n_Tributaria | |
// Expects the digits of the cuit except the last one (verifiying digit). | |
const getVerifiyingCUITDigit = (incompleteCUIT) => { | |
const coefficients = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2]; | |
if (incompleteCUIT.length !== coefficients.length) { | |
return -1; | |
} | |
let totalSum = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [Mock a class] | |
// (when calling myFile.myMethod(), ClassIWantToMockInMyFie will be replaced by MyMockClass) | |
const myFile = rewire("../src/myFile"); | |
myFile.__set__( { | |
'ClassIWantToMockInMyFie': MyMockClass | |
} ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.http.converter.StringHttpMessageConverter; | |
import org.springframework.web.bind.annotation.PostMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.web.client.RestTemplate; | |
public class SimplePostRequestInSpringBoot { | |
public void simplePost() { | |
RestTemplate client = new RestTemplate(); | |
client.getMessageConverters().add(new StringHttpMessageConverter()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator, FormatStrFormatter) | |
import math | |
import numpy as np | |
# Funciton that returns the next differential. | |
# In the case of the example: | |
# dy/dt = cos(t) | |
def f(t, y): | |
return math.cos(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.core.type.TypeReference; | |
import com.fasterxml.jackson.databind.*; | |
import org.springframework.util.ResourceUtils; | |
import java.io.IOException; | |
public class FileLoaderExample { | |
public static <DTO> DTO getDto(String path, Class<DTO> clazz) { | |
DTO dto = null; | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctime> | |
#include <bits/stdc++.h> | |
std::string getTimestamp(char* format) { | |
std::time_t epoch_time = std::time(nullptr); | |
std::stringstream stream; | |
stream << std::put_time( std::localtime(&epoch_time), format ); | |
return stream.str(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A lambda function (or expression) is a 'portable' anonymous function, which | |
* can be assigned to a variable. In Java, they are available since JDK 8. | |
*/ | |
public class LambdaTest { | |
public static void main(String[] args) { | |
/* The lambda function itself is the expression after the equals sign. | |
* | |
* The return type of the lambda corresponds to the return type of the | |
* abstract method in the functional interface, while the value in |