Skip to content

Instantly share code, notes, and snippets.

@anthavio
anthavio / ConnectTimeoutTest.java
Created March 5, 2013 17:56
How to simulate connect timeout error and test it
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.URL;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
{ "f1" : "hello",
"f2" : [1, "2", 3],
"f3" : { "n" : 5.5 }
}
*/
String json = new SimpleJsonBuilder()
.object() //switch to object context 1
.field("f1", "hello")
.array("f2") //switch to array context
@anthavio
anthavio / Openshift pom.xml
Last active January 3, 2016 09:19
Changes to pom.xml that makes webapp Openshift's Jenkins buildable and deployable
<profiles>
<profile>
<id>openshift</id>
<build>
<pluginManagement>
<plugins>
<!--
Git repo is checked out into /var/lib/openshift/52d5741450044610e8000284/app-root/runtime/repo
and Maven is started in this directory.
--
-- In your Quartz properties file, you'll need to set
-- org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
--
--
-- By: Ron Cordell - roncordell
-- I didn't see this anywhere, so I thought I'd post it here. This is the script from Quartz to create the tables in a MySQL database, modified to use INNODB instead of MYISAM.
-- anthavio - Replaced VARCHAR(1) with BOOLEAN
@anthavio
anthavio / logback.xml
Created February 28, 2014 17:56
Logback with SyslogAppender
<configuration debug="true" scan="true" scanPeriod="10 seconds">
<!--
Put into your rsyslog server's /etc/rsyslog.conf
if $programname == 'mycoolapp' then /var/log/mycoolapp/mycoolapp.log
-->
<!-- http://logback.qos.ch/manual/appenders.html#SyslogAppender -->
<appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">
<syslogHost>logs.mycompany.com</syslogHost>
<facility>LOCAL0</facility>
<suffixPattern> mycoolapp:%-10t|%-5p|%c{40}: %m</suffixPattern>
@anthavio
anthavio / merge-branch.sh
Last active August 29, 2015 13:56
git-cheat-sheet
# Assume I'm working inside feature-branch and I want to sync changes from sprint-branch
# which is already ahead and future merge back might become difficult due to ammount of changes
# I'm inside my feature-branch
git checkout feature-branch
# commit and push branch changes...
git commit
git push
@anthavio
anthavio / WebappSpringConfig.java
Last active July 13, 2018 14:15
spring-security java exploded configuration
@Configuration
@PropertySource(CoreSpringConfig.PROPERTIES)
public class WebappSpringConfig {
@Autowired
private Environment environment;
/**
* 'springSecurityFilterChain' is Magic ID and it is required by Spring Security DelegatingFilterProxy in web.xml
*
@anthavio
anthavio / spring-security-3.0.xml
Last active December 8, 2015 11:22
spring-security xml exploded configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
@anthavio
anthavio / SeleniumWaitBuilder.java
Last active August 29, 2015 13:59
SeleniumWaitBuilder
package com.nature.quickstep.test;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
@anthavio
anthavio / Cloudbees
Last active August 29, 2015 14:00
Releasing Maven Project
http://developer-blog.cloudbees.com/2014/02/how-to-do-maven-release-builds-from.html
http://wiki.cloudbees.com/bin/view/DEV/Sharing+Files+with+Build+Executors