Skip to content

Instantly share code, notes, and snippets.

View esarbanis's full-sized avatar

Efthymis Sarmpanis esarbanis

View GitHub Profile
final getIt = GetIt.instance;
void configure() {
getIt
..registerSingleton(Repository())
..registerFactory(
() => Bloc(getIt<Repository>()));
}
@esarbanis
esarbanis / DeferredResultSubscriber.java
Created July 28, 2016 10:57
DeferredResultSubscriber
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 March 7, 2016 17:08
Filters an array or list against a blacklist.
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 March 7, 2016 16:58
Print a numbers within a range with a particular offset
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 November 30, 2015 12:48
Add the following class to META-INF/services/javax.enterprise.inject.spi.Extension file.
/**
* 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) {
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 February 18, 2015 16:48
Update a bunch of svn repos and install their archetypes (no tests)
#! /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 August 29, 2015 14:15
Vagrantfile to create a java 1.5 maven 3.0.5 box.
# -*- 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 12:33
Check if today is the last working day of the month (No holidays are included)
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)) {