Skip to content

Instantly share code, notes, and snippets.

View aarshtalati's full-sized avatar
🎯
Focusing

Aarsh Talati aarshtalati

🎯
Focusing
View GitHub Profile
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.RELEASE)
2018-03-27 07:24:43.032 INFO 7696 --- [ main] e.gatech.epidemics.EpidemicsApplication : Starting EpidemicsApplication on atalati-devhost with PID 7696 (/home/atalati/Documents/epidemicsweb/target/classes started by atalati in /home/atalati/Documents/epidemicsweb)
2018-03-27 07:24:43.077 INFO 7696 --- [ main] e.gatech.epidemics.EpidemicsApplication : The following profiles are active: local
@aarshtalati
aarshtalati / pom.xml
Created March 27, 2018 11:23
JPA and MySQL dependencies for SpringBoot RESTful Application in docker
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
@aarshtalati
aarshtalati / EpidemicsApplication.java
Last active March 27, 2018 12:05
SpringBootApplication java class
package edu.gatech.epidemics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author atalati
*/
@aarshtalati
aarshtalati / AppConfigBean.java
Last active March 27, 2018 12:05
Read configurations from application.properties file
package edu.gatech.epidemics;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @author atalati
*/
@aarshtalati
aarshtalati / pom.xml
Created March 27, 2018 00:05
java springboot dependency to read configurations stored in application.properties file
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
@aarshtalati
aarshtalati / 3 in one application.properties
Last active March 27, 2018 11:17
docker application.properties prfile settings
>> application.properties <<
spring.profiles.active=container
>> application-local.properties <<
# Local
#MySQL configuration
@aarshtalati
aarshtalati / docker_cleanup.sh
Created March 26, 2018 23:39
Clean up docker environment
# deletes all docker containers
docker rm $(docker ps --no-trunc -aq)
# deletes dangling docker images (older version of the images)
docker images -q -f "dangling=true"
# deletes all docker images
docker rmi $(docker images -q)
# list all docker images
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.gatech</groupId>
<artifactId>epidemics-web</artifactId>
<version>1.0</version>
<name>epidemics</name>
def IsClose(value, target, threshold=0.02):
result = (value / target)
result = ((1 - threshold) <= result) and (result <= (1 + threshold))
return result
@aarshtalati
aarshtalati / np_argmin_alternative.py
Created October 16, 2017 00:27
An alternative to numpy.argmin()
>>> import numpy as np
>>> x = np.arange(127, 255, 50)
>>> x
array([127, 177, 227])
>>> x.argmin()
0
>>> x = x[::-1]
>>> x
array([227, 177, 127])
>>> x.argmin()