This file contains 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
# Massage your data into a data frame that provides access by Hour and URI | |
traffic.df <- parse.log("access.log") #parse.log is left as an exercise for the reader | |
# Aggregate | |
uri.hits <- ddply(traffic.df, .(Hour, URI), summarise, Hits=length(URI), .parallel = TRUE) | |
uri.stats <- ddply(uri.hits, .(URI), summarise, Mean=mean(Hits), Variance=sd(Hits), Total=sum(Hits), .parallel = TRUE) | |
uri.stats <- join(uri.hits, uri.stats, c("URI")) | |
# Find two std dev away from mean | |
uri.bad <- subset(uri.stats, Variance > 0) |
This file contains 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
queueStatsToDataframe <- function(uri, username, password) { | |
uri <- paste(uri, "api/queues", sep="/") | |
credentials = paste(username, password, sep=":") | |
doc <- getURL(uri, userpwd=credentials, httpauth=1L) | |
src <- fromJSON(doc) | |
items.df <- data.frame() | |
if(length(src) > 0) { | |
for(i in 1:length(src)) { | |
if(length(src[[i]]$messages_details) == 3) { |
This file contains 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
getContents <- function(uri, username, password) { | |
credentials = paste(username, password, sep=":") | |
doc <- getURL(uri, userpwd=credentials, httpauth=1L, ssl.verifypeer = FALSE) | |
} |
This file contains 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
rssToDataframe <- function(uri) { | |
doc <- getURL(uri) | |
doc <- xmlParse(doc) | |
src <- xpathApply(doc, "/rss/channel/item") | |
items.df <- data.frame() | |
if(length(src) > 0) { | |
for(i in 1:length(src)) { | |
item <- xmlSApply(src[[i]], xmlValue) | |
record.df <- data.frame(t(item), stringsAsFactors=FALSE) |
This file contains 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
atomToDataframe <- function(uri) { | |
doc <- getURL(uri) | |
doc <- xmlParse(doc) | |
src <- getNodeSet(doc, "/d:feed/d:entry", c(d = "http://www.w3.org/2005/Atom")) | |
items.df <- data.frame() | |
if(length(src) > 0) { | |
for(i in 1:length(src)) { | |
item <- xmlSApply(src[[i]], xmlValue) | |
record.df <- data.frame(t(item), stringsAsFactors=FALSE) |
This file contains 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
private static IDatabaseTester databaseTester; | |
@Resource | |
protected ComboPooledDataSource dataSource; | |
@Before //You can use @BeforeClass if dataSource isn't loaded by dependency injection | |
public void setupDatabase() throws Exception { | |
if(databaseTester == null) { //Only load once, this can be removed if using @BeforeClass | |
databaseTester = new DataSourceDatabaseTester(dataSource); | |
IDataSet dataSet = new XlsDataFileLoader().load("TestDAO-data.xls"); | |
databaseTester.setDataSet(dataSet); |
This file contains 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
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration() | |
public class TestServlet { | |
private HttpServlet servlet; | |
@Resource | |
protected ApplicationContext applicationContext; | |
@Before | |
public void initServlet() throws Exception { | |
StaticWebApplicationContext webContext = new StaticWebApplicationContext(); |
This file contains 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
@Override | |
public int hashCode() { | |
int hash = 0, buffer = 0; | |
int modulo, logicalShiftLeft; | |
for(int index = 0, max = this.stringProperty.length(); index < max; ++index) { | |
modulo = index % 4; | |
logicalShiftLeft = 8 * modulo; | |
buffer += this.stringProperty.charAt(index) << logicalShiftLeft; | |
if(modulo == 3) { |
This file contains 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
monitorRole readOnlyPassword | |
controlRole adminPassword |
This file contains 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
LookupCache getLookupCache(String host, Class template) { | |
if (System.getSecurityManager() == null) | |
System.setSecurityManager(new RMISecurityManager()); | |
LookupLocator primaryRegistrar = new LookupLocator(host); | |
LookupDiscoveryManager discoveryManager = | |
new LookupDiscoveryManager(null, new LookupLocator[] {primaryRegistrar}, null); | |
ServiceDiscoveryManager serviceDiscoveryManager = | |
new ServiceDiscoveryManager(discoveryManager, new LeaseRenewalManager()); | |
ServiceTemplate serviceTemplate = new ServiceTemplate(null, new Class[] {template}, null); |
OlderNewer