Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Aarsh Talati aarshtalati

🎯
Focusing
View GitHub Profile
@aarshtalati
aarshtalati / black_pixel_ratio.py
Last active Oct 16, 2017
different ways to calculate black pixel ratio in a binray image
View black_pixel_ratio.py
>>> 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 Oct 16, 2017
An alternative to numpy.argmin()
View np_argmin_alternative.py
>>> 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()
View IsClose.py
def IsClose(value, target, threshold=0.02):
result = (value / target)
result = ((1 - threshold) <= result) and (result <= (1 + threshold))
return result
View pom.xml
<?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 Mar 26, 2018
Clean up docker environment
View docker_cleanup.sh
# 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 Mar 27, 2018
docker application.properties prfile settings
View 3 in one application.properties
>> application.properties <<
spring.profiles.active=container
>> application-local.properties <<
# Local
#MySQL configuration
@aarshtalati
aarshtalati / pom.xml
Created Mar 27, 2018
java springboot dependency to read configurations stored in application.properties file
View pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
@aarshtalati
aarshtalati / AppConfigBean.java
Last active Mar 27, 2018
Read configurations from application.properties file
View AppConfigBean.java
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 Mar 27, 2018
SpringBootApplication java class
View EpidemicsApplication.java
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 Mar 27, 2018
JPA and MySQL dependencies for SpringBoot RESTful Application in docker
View pom.xml
<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>