Skip to content

Instantly share code, notes, and snippets.

jelies

Block or report user

Report or block jelies

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jelies
jelies / upload_progress.rb
Created Sep 19, 2014
Capistrano function to upload files displaying a progress percentage.
View upload_progress.rb
desc "Uploads a file displaying the progress"
def upload_progress(source, target)
upload(source, target, :via => :sftp) do |event, options, *others|
if event.to_s == "put"
print ("\r * " + (("#{others[1]}".to_f / "#{others[0].size}".to_f) * 100).round(2).to_s + "%").ljust(10, ' ')
elsif event.to_s == "close"
print "\r"
end
end
end
@jelies
jelies / CustomSchemaValidationConfiguration.java
Created Feb 12, 2014
Custom Hibernate schema validator that collects all the validation errors to display them all together instead of crashing one by one. Using Hibernate 3.6.4.
View CustomSchemaValidationConfiguration.java
package com.jelies.hibernate.validation;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
@jelies
jelies / MyRepositoryImpl.java
Last active Jan 3, 2019
A Spring FactoryBean to create a Hibernate's StatelessSession to be injected in your custom repository implementation when using Spring Data JPA.
View MyRepositoryImpl.java
package com.jelies.spring3tomcat7.repository;
import org.hibernate.Criteria;
import org.hibernate.ScrollableResults;
import org.hibernate.StatelessSession;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
@jelies
jelies / AutowiringSpringBeanJobFactory.java
Last active Aug 11, 2019
Quartz (2.1.6) java config with spring (3.2.1). Using a SpringBeanJobFactory to automatically autowire quartz classes.
View AutowiringSpringBeanJobFactory.java
package com.jelies.spring3tomcat7.config.quartz;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
/**
* This JobFactory autowires automatically the created quartz bean with spring @Autowired dependencies.
You can’t perform that action at this time.