Skip to content

Instantly share code, notes, and snippets.

View dellermann's full-sized avatar

Daniel Ellermann dellermann

View GitHub Profile
@dellermann
dellermann / grails-beans.groovy
Last active November 18, 2017 11:30
Display all configured Spring beans in a Grails application.
println 'Defined beans:'
org.springframework.context.ApplicationContext ctx = grailsApplication.mainContext
ctx.beanDefinitionNames.sort().each { println "${it} (${ctx.getType(it)?.name})" }
@dellermann
dellermann / event-chain.coffee
Last active August 29, 2015 14:06
Deferreds in test cases. This gist shows how to use `Deferred` or `Promise` in QUnit test cases where a chain of actions and assertions are needed.
# This function returns a `Promise` that is resolved when a particular
# event on the given element occurs.
newEventPromise = (elem, event, action) ->
$ = jQuery
that = this
# First, we create a new `Deferred` object.
deferred = $.Deferred()
# Then, we register a handle for the given event type (e. g. "click").
.is-Transformed {
width: 50%;
margin: auto;
position: absolute;
top: 50%; left: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
@dellermann
dellermann / linear-gradients-with-color-stops.css
Created August 12, 2013 14:24
CSS linear gradients, simple and with color stops.
#foo {
background: #C5C5C5;
background: -ms-linear-gradient(
left, #F4F4F4 0, #F4F4F4 25px, #EEE 26px, #C5C5C5 43%, #C5C5C5 57%,
#EEE 974px, #F4F4F4 975px, #F4F4F4 100%
);
background: -moz-linear-gradient(
left, #F4F4F4 0, #F4F4F4 25px, #EEE 26px, #C5C5C5 43%, #C5C5C5 57%,
#EEE 974px, #F4F4F4 975px, #F4F4F4 100%
);
:-ms-input-placeholder {
color: red;
}
:-moz-placeholder { /* Firefox 18- */
color: red;
}
::-moz-placeholder { /* Firefox 19+ */
color: red;
}
::-webkit-input-placeholder {
@dellermann
dellermann / grails-logging.md
Created July 4, 2013 14:02
Shows how to enable logging for Grails database connections.

Full stack traces

To enable full stack traces just add the command line argument -Dgrails.full.stacktrace=true when calling grails, e. g.:

grails -Dgrails.full.stacktrace=true run-app

SQL logging

@dellermann
dellermann / grails-regexp.md
Last active December 18, 2015 16:39
Various regular expressions for developers.

Constraints simplification

Remove parentheses from constraints such as number(blank: false) to number blank: false:

  • Search: (\w+)\(([^)]+)\)$
  • Replace: \1 \2

Method call simplification

@dellermann
dellermann / password-less login
Created May 16, 2013 15:53
Password-less login
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh user@host 'cat >>.ssh/authorized_keys2'
@dellermann
dellermann / Maven commands
Last active December 10, 2015 08:38
These are important Maven command lines.
# compute the effective POM
mvn help:effective-pom
# same, but without the dev profile
mvn -P'!dev' help:effective-pom