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(); | |
} |