This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# von/from http://devnulled.com/content/2007/06/how-to-display-linux-vps-memory-usage/ | |
bean=`cat /proc/user_beancounters` | |
guar=`echo "$bean" | grep vmguar | awk '{ print $4;}'` | |
burst=`echo "$bean" | grep privvm | awk '{ print $5;}'` | |
priv=`echo "$bean" | grep privvm | awk '{ print $2;}'` | |
let total=guar/256 | |
let used=priv/256 | |
let burst=burst/256 | |
echo "VPS memory usage:" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl http://npmjs.org/install.sh | sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import org.springframework.batch.item.ExecutionContext; | |
import org.springframework.batch.item.ItemStream; | |
import org.springframework.batch.item.ItemStreamException; | |
import org.springframework.batch.item.ItemStreamReader; | |
import org.springframework.batch.item.NonTransientResourceException; | |
import org.springframework.batch.item.ParseException; | |
import org.springframework.batch.item.UnexpectedInputException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2012 Michael R. Lange <[email protected]>. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2012 Michael R. Lange <[email protected]>. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from http://www.techper.net/2009/06/05/how-to-acess-target-object-behind-a-spring-proxy/ | |
@SuppressWarnings({"unchecked"}) | |
protected <T> T getTargetObject(Object proxy, Class<T> targetClass) throws Exception { | |
if (AopUtils.isJdkDynamicProxy(proxy)) { | |
return (T) ((Advised)proxy).getTargetSource().getTarget(); | |
} else { | |
return (T) proxy; // expected to be cglib proxy then, which is simply a specialized class | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WrappedMrirToGetCurrentResource<T> implements ItemStreamReader<T> { | |
private MultiResourceItemReader<T> mrir; | |
@Override | |
public void open(ExecutionContext executionContext) throws ItemStreamException { | |
mrir.open(executionContext); | |
// current.resource is only available here if it's a restart | |
if (mrir.getCurrentResource() != null && mrir.getCurrentResource().getFilename() != null) { | |
System.out.println("open:" + mrir.getCurrentResource().getFilename()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implementation for {@link ItemSqlParameterSourceProvider}, | |
* creates {@link MapSqlParameterSource} from {@link FieldSet}. | |
* | |
* @author Michael R. Lange <[email protected]> | |
*/ | |
public class FieldSetSqlParameterSourceProvider implements ItemSqlParameterSourceProvider<FieldSet> { | |
/** {@inheritDoc} */ | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* CustomSqlParameterSourceProvider, constructs {@link MapSqlParameterSource} with | |
* given item. | |
* | |
* @author Michael R. Lange <[email protected]> | |
*/ | |
public class CustomSqlParameterSourceProvider implements ItemSqlParameterSourceProvider<YourItemObject> { | |
@Override | |
public SqlParameterSource createSqlParameterSource(final YourItemObject item) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JdbcPagingItemReaderTests { | |
private BasicDataSource dataSource; | |
public void setUp() throws Exception { | |
// DataSource Setup, apache commons | |
dataSource = new BasicDataSource(); | |
dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); | |
dataSource.setUrl("jdbc:hsqldb:mem:testdb"); | |
dataSource.setUsername("sa"); |
NewerOlder