Skip to content

Instantly share code, notes, and snippets.

View JohnZavyn's full-sized avatar

John A. Marsh JohnZavyn

View GitHub Profile
@JohnZavyn
JohnZavyn / oracle-drop-all-tables.sql
Created September 10, 2014 14:55
Oracle Drop All Tables, Views, Sequences, etc.
/**
* USE WITH CAUTION!
* This script attempts to drop every object it can find in the current schema.
* - Tables (including constraints)
* - Views
* - Sequences
* - More...
*
* @author John A. Marsh - ThreeLeaf.com (c) 2014
*/
@JohnZavyn
JohnZavyn / reset-oracle-sequence.sql
Last active August 29, 2015 14:09
Reset An Oracle SEQUENCE
SET DEFINE OFF;
SET SERVEROUTPUT ON;
SET FEEDBACK OFF;
--/
DECLARE
newStartNumber INTEGER;
oldStartNumber INTEGER;
difference INTEGER;
BEGIN
@JohnZavyn
JohnZavyn / Oracle-replace-temporary-tablespace.sql
Created December 11, 2014 13:48
Oracle: Replace/reset Temporary TABLESPACE
/**
* I found after running a particular performance test that Oracle started hanging,
* and I noticed that the drive space was full. I eventually noticed that the TEMP
* tablespace had expanded to fill all the avlailable drive space. I found the following
* set of commands online that allowed me to drop the bloated tablespace and recreate
* a new one.
* @author John A. Marsh (with lots of help from the Internet)
* @since 2014-08-01
*/
@JohnZavyn
JohnZavyn / pom.xml
Created August 5, 2016 16:54
Renaming a dependency JAR before buiding a WAR in Maven
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
@JohnZavyn
JohnZavyn / ApkService.java
Created August 5, 2016 17:53
Extract the icon from an APK file
import net.dongliu.apk.parser.ApkParser;
import net.dongliu.apk.parser.bean.Icon;
import org.apache.log4j.Logger;
import java.io.*;
/** Services for managing APK (Adroid Application Package) objects. */
public class ApkService
{
/** The {@link Logger}. */
@JohnZavyn
JohnZavyn / applicationContext.xml
Created August 17, 2016 15:08
Fix for "HibernateJpaDialect - JDBC Connection to reset not identical to originally prepared Connection" warning
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitName" value="pu"/>
<property name="packagesToScan">
<list>
<value>com.appia.model.beans</value>
</list>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
package com.threeleaf.util;
import java.util.Comparator;
/**
* A {@link Comparator} that allows any two objects to be sorted based on {@link Object#toString()}.
* This works best when the object's toString returns something meaningful, but can still be
* useful in cases where a object one has not control over needs to be placed in a sorted
* collection.
* <p>
@JohnZavyn
JohnZavyn / LargestModulus.java
Created August 7, 2017 13:34
Find all even divisors for a number
import java.io.*;
/** Find all the even divisors of a number. */
class LargestModulus
{
/**
* Find all the divisors for a number (a.k.a., a dividend). The number must be a positive integer. It may be provided on the command line, or entered interactively when prompted.
*
* @param args if a command line parameter is detected, the first argument is used.
/**
* <p>Workaround to allow OpenPojo version 0.8.6 to work with Java 9.</p>
* <p>TODO: Remove when OpenPojo is updated</p>
*/
@BeforeClass
public static void setSystemProperty()
{
System.setProperty("sun.boot.class.path", System.getProperty("java.class.path"));
}
@JohnZavyn
JohnZavyn / microservice.docker
Created May 1, 2018 18:36
Docker file to run an exploded Spring Boot WAR
FROM openjdk:8-alpine
ENV TZ America/New_York
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime
RUN echo "${TZ}" > /etc/timezone
# Declare the working directory
WORKDIR /microservice
# Copy and explode the WAR to the working directory