Skip to content

Instantly share code, notes, and snippets.

View hseritt's full-sized avatar
🏠
Working from home

Harlin Seritt hseritt

🏠
Working from home
View GitHub Profile
@hseritt
hseritt / getlinescount.sh
Created February 25, 2017 12:39
Get line count of all .py code - Can be changed for any file extension
echo "Lines of code written so far: "
( find ./ -name '*.py' -print0 | xargs -0 cat ) | wc -l
@hseritt
hseritt / gendocs.sh
Created February 25, 2017 12:38
Generate epydocs (documentation)
#!/usr/bin/env bash
outputdir="docs/code"
export DJANGO_SETTINGS_MODULE='myproject.settings'
epydoc --html --parse-only --name myprojectname --inheritance grouped apps myprojectname scripts -o $outputdir/
cp static/admin/css/base.css $outputdir/epydoc.css
@hseritt
hseritt / clear-pyc.sh
Created February 25, 2017 12:37
Clear all .pyc files from project
#!/usr/bin/env bash
find . -name '*.pyc' -delete
@hseritt
hseritt / eclipse.ini
Last active December 24, 2016 21:28
Fast Eclipse settings for Ubuntu 14.04
-startup
plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar
--launcher.library
../../../../../../../home/hseritt/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.400.v20160518-1444
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
--launcher.GTK_version 2
openFile
-showsplash
@hseritt
hseritt / AgentHandler.java
Created June 29, 2016 14:46
Dynamic creation of class with parameters in the constructor
// See http://stackoverflow.com/questions/9886266/is-there-a-way-to-instantiate-a-class-by-name-in-java
Class<?> agent = Class.forName(agentModel.getClassName());
Constructor<?> constructor = agent.getConstructor(AgentModel.class);
Object runningAgent = constructor.newInstance(agentModel);
Thread agentThread = new Thread((Runnable) runningAgent);
agentThread.start();
@hseritt
hseritt / AlfmonitorApplication.java
Created June 28, 2016 12:15
Calling a bean that uses JPA Repository
import java.io.IOException;
import java.sql.SQLException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
public class AlfmonitorApplication {
@hseritt
hseritt / log4j.properties
Created June 27, 2016 13:42
Log4j 1.2.17 - simple print debug to console
# Root logger option
log4j.rootLogger=DEBUG, stdout
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.logger.org.prodigius.jdbobj.Db=debug
@hseritt
hseritt / AgentQueue.java
Created June 27, 2016 02:16
How to handle opening and closing Hibernate sessions
Session session = HibernateUtil.getSessionFactory().openSession();
session.setFlushMode(FlushMode.MANUAL);
ManagedSessionContext.bind(session);
session.beginTransaction();
Query getAgentsQuery = session.createQuery(" from AgentModel where active=true");
@SuppressWarnings("unchecked")
List<AgentModel> agentList = getAgentsQuery.list();
for (AgentModel agentModel : agentList) {
@hseritt
hseritt / HibernateUtil.java
Created June 27, 2016 02:04
HibernateUtil.java
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
@hseritt
hseritt / application.properties
Created June 27, 2016 01:57
Spring boot application.properties file
# Security
security.basic.enabled=false
management.security.enabled=false
# Database settings
spring.datasource.url=jdbc:mysql://localhost/alfmonitor
spring.datasource.username=admin
spring.datasource.password=admin
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#spring.jpa.hibernate.ddl-auto=update