Skip to content

Instantly share code, notes, and snippets.

@aaronmccall
aaronmccall / placeholder.js
Created January 4, 2011 22:45
shim for browsers that don't support the html5 placeholder attribute
setup_placeholders = (function() {
$.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) {
$.support.placeholder = true;
return function() {}
} else {
return function(){
@aolshevskiy
aolshevskiy / build.gradle
Created January 16, 2012 03:14
Multiple webapp resource dirs with Gradle-embed Jetty
import org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext
apply plugin: "jetty"
def newResourceCollection(File... resources) {
shell = new GroovyShell(JettyPluginWebAppContext.class.classLoader)
shell.setProperty("resources", resources as String[])
return shell.evaluate(file("resource_collection.groovy"))
}
@inancsevinc
inancsevinc / BooleanTypeHandler.java
Created April 12, 2012 13:29
BooleanTypeHandler for MyBatis
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
def wait_to_done(progress, wait_time=120, mesg=""):
import time
for i in range(wait_time):
if mesg != "":
print "%s" % mesg, progress.getState()
if "failed" == progress.getState():
return 0
if i > 7:
# a work around for stuck wlst script
edit()
@char1st
char1st / jetty-env.xml
Created December 11, 2012 01:19
jetty jndi
<?xml version="1.0" encoding="UTF-8"?>
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<New class="org.eclipse.jetty.plus.jndi.Resource" id="DSTestll">
<Arg />
<Arg>jdbc/mysqlDScall</Arg>
<Arg>
<Call id="dsbyfact" class="com.alibaba.druid.pool.DruidDataSourceFactory"
name="createDataSource">
<Arg>
<Map>
@jgeraerts
jgeraerts / SpringThucydidesJUnitStories
Created January 11, 2013 08:21
Load Spring Application with Thucydides JBehave.
public class SpringThucydidesJUnitStories extends ThucydidesJUnitStories {
@Override
public InjectableStepsFactory stepsFactory() {
return SpringAutowiringThucydidesStepFactory.withStepsFromPackage(getRootPackage(), configuration()).andClassLoader(getClassLoader());
}
public static class SpringAutowiringThucydidesStepFactory extends ThucydidesStepFactory {
private static volatile ConfigurableApplicationContext ctx;
@matsev
matsev / CustomResponseEntityExceptionHandler.java
Last active January 16, 2023 06:04
Generic response error handling using @ControllerAdvice
@ControllerAdvice
public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
List<ObjectError> globalErrors = ex.getBindingResult().getGlobalErrors();
List<String> errors = new ArrayList<>(fieldErrors.size() + globalErrors.size());
String error;
for (FieldError fieldError : fieldErrors) {
package spullara.util.concurrent;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
@chbaranowski
chbaranowski / beans-context.groovy
Last active August 29, 2015 13:57
Spring groovy beans context
package beans
import org.springframework.core.io.ClassPathResource
// load configuration from the classpath
def url = new ClassPathResource('beans/simple.config').URL;
def config = new ConfigSlurper().parse(url);
beans {
@darekkay
darekkay / intellij-monokai-theme.xml
Last active March 5, 2021 09:47
Monokai Theme for JetBrains IDEs (IntelliJ IDEA, Webstorm, PhpStorm, PyCharm etc.)
<scheme name="Eclectide Monokai" version="142" parent_scheme="Default">
<colors>
<option name="ADDED_LINES_COLOR" value="295622" />
<option name="ANNOTATIONS_COLOR" value="b2c0c6" />
<option name="CARET_COLOR" value="bbbbbb" />
<option name="CARET_ROW_COLOR" value="" />
<option name="CONSOLE_BACKGROUND_KEY" value="1c1c1c" />
<option name="FILESTATUS_ADDED" value="629755" />
<option name="FILESTATUS_DELETED" value="6c6c6c" />
<option name="FILESTATUS_IDEA_FILESTATUS_DELETED_FROM_FILE_SYSTEM" value="6c6c6c" />