Skip to content

Instantly share code, notes, and snippets.

@timyates
timyates / iterators.groovy
Created October 30, 2013 14:56
Composable Iterators with Guava and Groovy
@Grab( 'com.google.guava:guava:15.0' )
import com.google.common.collect.Iterators
Iterator.metaClass {
leftShift = { Iterator b ->
Iterators.concat( delegate, b )
}
leftShift = { Iterable b ->
Iterators.concat( delegate, b.iterator() )
}
@melix
melix / convert.groovy
Created July 17, 2013 12:57
Convert Confluence HTML export into asciidoc
@Grab('net.sourceforge.htmlcleaner:htmlcleaner:2.4')
import org.htmlcleaner.*
def src = new File('html').toPath()
def dst = new File('asciidoc').toPath()
def cleaner = new HtmlCleaner()
def props = cleaner.properties
props.translateSpecialEntities = false
def serializer = new SimpleHtmlSerializer(props)
@martinlippert
martinlippert / install-addons.sh
Created March 13, 2013 19:12
A simple script to batch install a bunch of additional features into an existing Eclipse or STS installation. Customize to your needs in the "installFeatures()" part. First parameter there is list of feature IDs, second is the list of update sites to install those features from. Run this via: ./install-addons.sh <relative-path-to-your-sts/eclips…
#!/bin/bash
#set -x
doInstall() {
ECLIPSELOCATION=`ls $LOCATION/plugins/org.eclipse.equinox.launcher_*`
$JAVA_HOME/bin/java -jar $ECLIPSELOCATION -nosplash -application org.eclipse.equinox.p2.director \
-metadataRepository "$2" \
-artifactRepository "$2" \
-destination $LOCATION \
-installIU "$1"
@jfarcand
jfarcand / gist:4125590
Created November 21, 2012 15:52
Adding WebSocket Support to Jersey
diff --git a/modules/concepts-service-distribution/src/main/webapp/WEB-INF/web.xml b/modules/concepts-service-distribution/src/main/webapp/WEB-INF/web.xml
index 4a18daf..a62eb97 100644
--- a/modules/concepts-service-distribution/src/main/webapp/WEB-INF/web.xml
+++ b/modules/concepts-service-distribution/src/main/webapp/WEB-INF/web.xml
@@ -21,7 +21,7 @@
<servlet>
<servlet-name>jersey</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
@sgergely
sgergely / gist:3793166
Created September 27, 2012 09:43
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@odrotbohm
odrotbohm / gist:3497047
Created August 28, 2012 10:36
JPQL / SQL riddle
JPQL: select p from Person p
left outer join p.address address
order by address.city
SQL: select person0_ from Person person0_
left outer join Address address1_ on person0_.id=address1_.person_id
order by address1_.city
JPQL: select p from Person p
left outer join p.address address
order by p.address.city
@odrotbohm
odrotbohm / gist:3215345
Created July 31, 2012 09:08
Git aliases to ease cherry picking

When fixing bugs on a software project I repeatedly faced the situation where I'd like to apply the commit I just did to a branch to another. Think of fixing a bug in the master branch and immediately back-porting it to the maintenance branch. This usually needed the following steps:

  1. Looking up the SHA1 of the original commit
  2. Checking out the destination branch
  3. git cherry-pick $sha1

The very first step can be eased a bit by creating a git alias to lookup the SHA1 of the last commit of a given branch.

[alias]
@anjackson
anjackson / SwingFXWebView.java
Created January 19, 2012 15:41
Embedding a JavaFX WebView in a Swing panel.
import com.sun.javafx.application.PlatformImpl;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Node;
#!/bin/bash
# NOTE: this is an OSX launchd wrapper shell script for Tomcat (to be placed in $CATALINA_HOME/bin)
CATALINA_HOME=/Users/username/tomcat
function shutdown() {
date
echo "Shutting down Tomcat"
$CATALINA_HOME/bin/catalina.sh stop