Uno scrittoio digitale …

18 settembre 2012

Guice AssistedInject

Archiviato in: java — Tag:, , — admin @ 22:38
public class GuiceModule extends AbstractModule {
	@Override
	protected void configure() {

		bind(AuthService.class).to(RealAuthService.class);

		install(new FactoryModuleBuilder()
	    	.implement(Payment.class, RealPayment.class)
	    	.build(PaymentFactory.class));		

	}
}

public interface AuthService {
}

public class RealAuthService implements AuthService {
}

public interface Payment {
	void pay(BigDecimal amount);
}

public class RealPayment implements Payment {
	@Inject
	public RealPayment(AuthService authService, @Assisted BigDecimal amount) {
		System.err.println("create RealPayment with args");
		System.err.println("authService: " + authService);
		System.err.println("amount: " + amount);
	}

	@Override
	public void pay(BigDecimal amount) {

	}
}

public interface PaymentFactory {
	Payment create(BigDecimal amount);
}

public static void main(String[] args) {
	final Injector injector = Guice.createInjector(new GuiceModule());
	final PaymentFactory paymentFactory = injector.getInstance(PaymentFactory.class);

	System.err.println("create payment: " + paymentFactory.create(BigDecimal.TEN));
}

5 settembre 2012

Vlsub: VLC extension to search and download subtitles

Archiviato in: sapere è potere — Tag: — admin @ 20:30

Follow this step:

*) download Vlsub from here
*) run … mkdir -p ~/.local/share/vlc/lua/extensions
*) mv the downloaded lua file into this dir
*) restart vlc
*) open View > Vlsub and download your preferred language subtitles

Funziona con WordPress