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 / georgia_tech_bootstrap3.css
Last active March 31, 2018 20:56
CSS customizations for Georgia Institute of Technology like navbar
.navbar-default {
background-color: #eaaa00;
border-color: #e5e5e5;
}
.navbar-default .navbar-brand {
color: #545454;
}
.navbar-default .navbar-brand:hover,
package edu.gatech.epidemics.api;
import edu.gatech.epidemics.model.User;
import edu.gatech.epidemics.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
FROM openjdk:8
ADD epidemics-web.jar app.jar
ADD wrapper.sh wrapper.sh
RUN bash -c 'touch /app.war'
RUN bash -c 'chmod +x /wrapper.sh'
ENTRYPOINT ["/bin/bash", "/wrapper.sh"]
@aarshtalati
aarshtalati / wrapper.sh
Last active March 28, 2018 02:28
makes sure that database docker container is up and spinning before starting Java SpringBoot application
#!/bin/bash
while ! exec 6<>/dev/tcp/${DATABASE_HOST}/${DATABASE_PORT}; do
echo "Trying to connect to MySQL at ${DATABASE_HOST}:${DATABASE_PORT}..."
sleep 10
done
echo ">> connected to MySQL database! <<"
java -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=container -jar /app.jar
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_151]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_151]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_151]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.45.jar:5.1.45]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990) ~[mysql-connector-java-5.1.45.jar:5.1.45]
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341) ~[mysql-connector-java-5.1.45.jar:5.1.45]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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
package edu.gatech.epidemics.service;
import edu.gatech.epidemics.dao.UserRepository;
import edu.gatech.epidemics.model.User;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
package edu.gatech.epidemics.dao;
import edu.gatech.epidemics.model.User;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
/**
* @author atalati
*/
@Repository
@aarshtalati
aarshtalati / mysql_schema.sql
Last active March 27, 2018 12:09
Epidemics table sample schema
# MySQL Setup
SET default_storage_engine=InnoDB;
USE epidemics;
DROP TABLE IF EXISTS user;
CREATE TABLE user (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(25) NOT NULL,
`password` VARCHAR(50) ,
package edu.gatech.epidemics.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
* @author atalati
*/