Skip to content

Instantly share code, notes, and snippets.

View agoston's full-sized avatar
💤
Sleeping

Agoston Horvath agoston

💤
Sleeping
  • bol.com
  • Amsterdam
View GitHub Profile
@agoston
agoston / vaadin hotkey + iterate over components.java
Last active October 30, 2015 12:44
Installs a global hotkey in Vaadin. Then, when triggered, it would iterate through the component tree and some buttons. Nice example of rarely used operations/hacks :)
public void installHotkey() {
LOG.info("Sprinkling magic all over");
UI.getCurrent().addActionHandler(new Action.Handler() {
@Override
public Action[] getActions(Object target, Object sender) {
return new Action[]{new ShortcutAction("Ctrl-Alt-F12", ShortcutAction.KeyCode.F12, new int[]{ShortcutAction.ModifierKey.ALT, ShortcutAction.ModifierKey.CTRL})};
}
@Override
public void handleAction(Action action, Object sender, Object target) {
/ ==UserScript==
// @name Sysstate refresh disable
// @namespace horvath.agoston@gmail.com
// @include http*://sysstate.dev.bol.com/
// @version 1
// @grant none
// ==/UserScript==
window.addEventListener ("load", Greasemonkey_main, false);
// ==UserScript==
// @name Remove JIRA announcement
// @namespace horvath.agoston@gmail.com
// @include /^https?://jira\.tools\.bol\.com//
// @version 1
// @grant none
// ==/UserScript==
$('#announcement-banner').remove();
authenticatedCall: function() {
var args = [].slice.call( arguments );
args.splice( 1, 0, this.blogId, this.username, this.password );
this.call.apply( this, args );
}
@agoston
agoston / private.xml
Created September 23, 2014 11:39
Karabiner global hotkey definition to switch between applications (place in ~/Library/Application Support/Karabiner/private.xml)
<?xml version="1.0"?>
<root>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_APP_Karabiner_Term</name>
<url type="file">/Users/agoston/Applications/iTerm.app</url>
</vkopenurldef>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_APP_Karabiner_Firefox</name>
<url type="file">/Applications/Firefox.app</url>
</vkopenurldef>
@agoston
agoston / TransactionTemplate.java
Last active July 27, 2023 18:18
JdbcTemplate manual transaction example, using TransactionTemplate
//[... initialize ...]
final SimpleDataSourceFactory simpleDataSourceFactory = new SimpleDataSourceFactory("com.mysql.jdbc.Driver");
final DataSource dataSource = simpleDataSourceFactory.createDataSource(jdbcUrl, user, pass);
jdbcTemplate = new JdbcTemplate(dataSource);
final DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
transactionTemplate = new TransactionTemplate(transactionManager);
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
@agoston
agoston / ReinitContextTestExecutionListener.java
Created March 18, 2014 22:07
TestExecutionListener for Spring + JUnit tests, similar to @DirtiesContext, but reinitializes context _before_ test class is run. The upside is that you can influence context creating from the @BeforeClass this way.
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.AbstractTestExecutionListener;
public class ReinitContextTestExecutionListener extends AbstractTestExecutionListener {
@Override
public void beforeTestClass(final TestContext testContext) throws Exception {
testContext.markApplicationContextDirty(DirtiesContext.HierarchyMode.EXHAUSTIVE);
}
}