Skip to content

Instantly share code, notes, and snippets.

Efthymis Sarmpanis esarbanis

Block or report user

Report or block esarbanis

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
View DeferredResultSubscriber.java
import org.springframework.web.context.request.async.DeferredResult;
import rx.Observable;
import rx.Observer;
import rx.Subscription;
/**
* A {@link DeferredResult} that subscribes to an observable
*
* @see DeferredResult
*/
@esarbanis
esarbanis / NotIn.ts
Created Mar 7, 2016
Filters an array or list against a blacklist.
View NotIn.ts
import LodashStatic = _;
class NotIn {
static ID:string = 'notIn';
static filter() {
return (input:any[], blacklist:any[]) => {
return LodashStatic.difference(input, blacklist);
};
}
@esarbanis
esarbanis / Range.ts
Created Mar 7, 2016
Print a numbers within a range with a particular offset
View Range.ts
class Range {
static ID:string = 'range';
static filter() {
return (num:number, offset:number = 1) => {
var res = [];
for (var i = offset; i <= num; i = i + offset) {
res.push(i);
}
return res;
@esarbanis
esarbanis / WeblogicActivitiExtension
Last active Nov 30, 2015
Add the following class to META-INF/services/javax.enterprise.inject.spi.Extension file.
View WeblogicActivitiExtension
/**
* Weblogic ClassLoader on CDI Extension don´t localize META-INF/services necessary to load ProcessEngine.
* <p>
* This class provides an overriding extension point which uses the correct classloader, in order to instantiate
* a {@link org.activiti.cdi.spi.ProcessEngineLookup}
* </p>
*/
public class WeblogicActivitiExtension extends ActivitiExtension {
public void beforeBeanDiscovery(@Observes final BeforeBeanDiscovery event) {
View PropertiesUtis.java
public class PropertiesUtis {
public static void copyProperties(Object fromObj, Object toObj) {
Class<? extends Object> fromClass = fromObj.getClass();
Class<? extends Object> toClass = toObj.getClass();
try {
BeanInfo fromBean = Introspector.getBeanInfo(fromClass);
BeanInfo toBean = Introspector.getBeanInfo(toClass);
PropertyDescriptor[] toPd = toBean.getPropertyDescriptors();
@esarbanis
esarbanis / update.sh
Created Feb 18, 2015
Update a bunch of svn repos and install their archetypes (no tests)
View update.sh
#! /bin/bash
declare -r MULTI_PJ_HOME='<THE_MULTI_PROJECT_ROOT_PATH>'
declare -r projects="<LIST_OF_MODULES_IN_RESPECT_OF_THE_MULTI_PROJECT_ROOT_PATH>"
for project in $projects
do
echo "================================================"
echo "Updating $project"
echo "================================================"
@esarbanis
esarbanis / Vagrantfile
Last active Aug 29, 2015
Vagrantfile to create a java 1.5 maven 3.0.5 box.
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
$jdk5 = <<script
wget -nc "https://www.dropbox.com/s/rvhj797qe9uvetv/jdk-1_5_0_22-linux-amd64.bin?dl=0" \
-O jdk-1_5_0_22-linux-amd64.bin
chmod +x jdk-1_5_0_22-linux-amd64.bin
yes | sh jdk-1_5_0_22-linux-amd64.bin
script
@esarbanis
esarbanis / DateInspector.java
Created May 14, 2014
Check if today is the last working day of the month (No holidays are included)
View DateInspector.java
public class DateInspector {
public static boolean isLastWorkingDayOfMoth(Calendar date) {
// get the current date
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
// get the calendar last day of this month
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
// set the current date to the last day of the month
cal.set(Calendar.DAY_OF_MONTH, lastDay);
// if it's on a weekend, transform it accordingly
switch (cal.get(Calendar.DAY_OF_WEEK)) {
You can’t perform that action at this time.