Skip to content

Instantly share code, notes, and snippets.

View edjeordjian's full-sized avatar

Esteban Djeordjian edjeordjian

  • Ciudad de Buenos Aires
View GitHub Profile
@edjeordjian
edjeordjian / checkCUIT.js
Created February 26, 2024 00:25
Código para comprobar un número de CUIT
// 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;
@edjeordjian
edjeordjian / RewireMockLibraryExamples.js
Created March 13, 2022 16:29
Examples for mocking in Node with Rewire Library
// [Mock a class]
// (when calling myFile.myMethod(), ClassIWantToMockInMyFie will be replaced by MyMockClass)
const myFile = rewire("../src/myFile");
myFile.__set__( {
'ClassIWantToMockInMyFie': MyMockClass
} );
@edjeordjian
edjeordjian / SimplePostRequestInSpringBoot.java
Created September 4, 2021 00:47
Quick way to send a post message in Spring Boot.
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());
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)
@edjeordjian
edjeordjian / SpringBootFileToObjectMapper.java
Last active September 4, 2021 00:42
Map a file (for example, a JSON) into an object with a few lines of code in Spring Boot.
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 {
@edjeordjian
edjeordjian / simple_custom_timestamp.cpp
Last active March 20, 2020 21:13
A simple way to create a customized timestamp in C++.
#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();
}
@edjeordjian
edjeordjian / LambdaExample.java
Last active March 13, 2022 16:23
Easy and simple example of lambda functions in Java.
/* 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