Skip to content

Instantly share code, notes, and snippets.

View aarshtalati's full-sized avatar
🎯
Focusing

Aarsh Talati aarshtalati

🎯
Focusing
View GitHub Profile
@aarshtalati
aarshtalati / black_pixel_ratio.py
Last active October 16, 2017 00:04
different ways to calculate black pixel ratio in a binray image
>>> image
array([[1, 0, 0, 1, 0],
[0, 1, 0, 0, 1],
[0, 0, 1, 0, 0],
[1, 0, 0, 1, 0]])
>>> black_pixel_count = (image == 0).sum()
>>> total_pixel_count
20
>>> total_pixel_count = image.shape[0] * image.shape[1]
>>> total_pixel_count
@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()
def IsClose(value, target, threshold=0.02):
result = (value / target)
result = ((1 - threshold) <= result) and (result <= (1 + threshold))
return result
<?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>
@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
@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 / 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 / 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 / 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 / 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>