Skip to content

Instantly share code, notes, and snippets.

View darbyluv2code's full-sized avatar

Chad Darby darbyluv2code

View GitHub Profile
@darbyluv2code
darbyluv2code / gist:c5394b87a3153124f1d59ca8cd3a4bda
Created February 26, 2019 00:33
CreateStudentDemo (no xml ... file somewhere else on computer ... not on classpath)
package com.luv2code.hibernate.demo;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
@darbyluv2code
darbyluv2code / CreateStudentDemo
Created February 26, 2019 00:31
CreateStudentDemo (no xml ... custom file name)
package com.luv2code.hibernate.demo;
import java.io.IOException;
import java.util.Properties;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.luv2code.hibernate.demo.entity.Student;
@darbyluv2code
darbyluv2code / CreateStudentDemo.java
Created February 26, 2019 00:30
CreateStudentDemo (no xml ... default props file name)
package com.luv2code.hibernate.demo;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.luv2code.hibernate.demo.entity.Student;
public class CreateStudentDemo {
@darbyluv2code
darbyluv2code / web.xml
Created February 24, 2019 20:23
web.xml for servlet 4 (requires Tomcat 9)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
</web-app>
@darbyluv2code
darbyluv2code / web.xml
Created February 24, 2019 20:22
web.xml for servlet 3.1
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
</web-app>
@darbyluv2code
darbyluv2code / MultiHttpSecurityConfig
Created February 18, 2019 04:12
Security for MVC and REST in the same app
package com.luv2code.springboot.thymeleafdemo.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
@darbyluv2code
darbyluv2code / setup-spring-security-demo-database-plaintext.sql
Created February 12, 2019 19:19
setup-spring-security-demo-database-plaintext.sql
DROP DATABASE IF EXISTS `spring_security_demo_plaintext`;
CREATE DATABASE IF NOT EXISTS `spring_security_demo_plaintext`;
USE `spring_security_demo_plaintext`;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
@darbyluv2code
darbyluv2code / 500.txt
Created January 24, 2019 20:30
ondes - 500 error
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Servlet.init() for servlet [dispatcher] threw exception
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
@darbyluv2code
darbyluv2code / more-employees.sql
Last active January 5, 2019 04:40
more-employees.sql
#
# Adds 1000 employees
#
# Sample script generated @ https://www.mockaroo.com/
#
use employee_directory;
insert into employee (first_name, last_name, email) values ('Ebony', 'Maeer', '[email protected]');
insert into employee (first_name, last_name, email) values ('Judi', 'Worboys', '[email protected]');
@darbyluv2code
darbyluv2code / pom.xml
Created October 30, 2018 16:00
Maven pom file for Spring + Hibernate
<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>com.luv2code.springdemo</groupId>
<artifactId>spring-crm-rest</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<properties>