Skip to content

Instantly share code, notes, and snippets.

@naaman
naaman / gist:1053217
Created June 29, 2011 05:33
Hot Swapping With Maven, Jetty and IntelliJ

Hot Swapping With Maven, Jetty and IntelliJ

Based on Configuring Jetty, Maven, and Eclipse together with Hot Swap

I've always been a bit jealous when it comes to the Play! framework and the great dev mode they have for hot swapping classes at runtime. Jetty has a configuration setting, scanIntervalSeconds, that mimics this when working with a more traditional WAR, but does so by looking for changes to a file and restarting the server.

Fortunately, Jetty also provides the ability to rapidly test code with hot swapping. No more server restarts. The trick to getting hot swapping to work is to attach a remote debugger to your Jetty process. The following instructions outline how to do this in IntelliJ (tested with IDEA 10.5 CE).

Modify your jetty-maven-plugin to ignore the scan interval

  1. Open your pom and locate the plugins section
@naaman
naaman / vim-on-heroku.sh
Last active July 6, 2023 13:50
vim on heroku
#!/usr/bin/env bash
mkdir vim
curl https://s3.amazonaws.com/heroku-vim/vim-7.3.tar.gz --location --silent | tar xz -C vim
export PATH=$PATH:/app/vim/bin
@naaman
naaman / delete-heroku-apps.sh
Last active March 5, 2021 20:57
[WARNING THIS WILL HARD DELETE YOUR APPS. YOU COULD LOSE DATA. MAKE SURE YOU KNOW WHAT YOURE DOING!!!!!!!!!!] Delete all heroku apps from bash terminal -- no script file required
for app in $(heroku apps); do heroku apps:destroy --app $app --confirm $app; done
@naaman
naaman / tab.sh
Created May 11, 2012 22:52
Open iTerm2 Pane and Execute a Command
pane() {
local currentDir=$(pwd)
osascript <<EOD
tell application "iTerm"
tell application "System Events" to keystroke "d" using command down
tell current session of current terminal
write text "cd $currentDir"
write text "$@"
end tell
end tell
@naaman
naaman / network-interface-patch-notes
Last active December 15, 2015 17:38
Notes on patching NetworkInterface.c
$ cd $ICEDTEA_PATH
$ find . -name NetworkInterface.c
./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c
...
$ cp ./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c ./NetworkInterface.c
$ vi NetworkInterface.c
/fscanf
note: fscanf should only match one line
replace first 02x with 08x
:wq
@naaman
naaman / 8009591-network_interface.patch
Last active December 15, 2015 17:38
JDK NetworkInterface Linux Patch
--- ./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c 2013-03-04 21:51:01.000000000 +0000
+++ ./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c 2013-04-02 22:35:56.000000000 +0000
@@ -1127,7 +1127,7 @@
uint8_t ipv6addr[16];
if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) {
- while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n",
+ while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n",
addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[4], addr6p[5], addr6p[6], addr6p[7],
&if_idx, &plen, &scope, &dad_status, devname) != EOF) {
@naaman
naaman / fucking-java.sh
Created March 13, 2013 22:32
java -version
java -version 2>&1 | head -1 | sed "s/[^0-9\.\_\-]*//g"
@naaman
naaman / gist:5095220
Created March 5, 2013 23:09
anorm hack to use row cursors
// hack to get a Stream with a cursor-backed query because anorm doesn't combine the two
private def resultSetToStream(sql: SimpleSql[Row])(implicit c: Connection): Stream[SqlRow] = {
val stmt = sql.getFilledStatement(c, getGeneratedKeys = false)
stmt.setFetchSize(1000)
val rs = stmt.executeQuery()
val rsMetaData = Sql.metaData(rs)
val columns = List.range(1, rsMetaData.columnCount + 1)
def data(rs: java.sql.ResultSet) = columns.map(nb => rs.getObject(nb))
Useful.unfold(rs)(rs => if (!rs.next()) { rs.getStatement.close(); None } else Some((new SqlRow(rsMetaData, data(rs)), rs)))
}
@naaman
naaman / gist:4993390
Created February 20, 2013 06:22
jdk dyno scratch
1 ls -lah
2 curl -O http://icedtea.wildebeest.org/download/source/icedtea-2.1.5.tar.gz
3 tar xvzf icedtea-2.1.5.tar.gz
4 cd icedtea-2.1.5
5 ./configure --with-parallel-jobs=2 --disable-docs --disable-bootstrap --with-jdk-home=/usr/lib/jvm/java-6-openjdk
6 cd ..
7 curl -O http://mirror.olnevhost.net/pub/apache//ant/binaries/apache-ant-1.8.4-bin.tar.gz
8 tar xf apache-ant-1.8.4-bin.tar.gz
9 ls -lah
10 ls -lah apache-ant-1.8.4
@naaman
naaman / SecurityListings.java
Created September 12, 2012 22:26
List JCE Algorithms
import java.security.Provider;
import java.security.Security;
public class SecurityListings {
public static void main(String[] args) {
for (Provider provider : Security.getProviders()) {
System.out.println("Provider: " + provider.getName());
for (Provider.Service service : provider.getServices()) {
System.out.println(" Algorithm: " + service.getAlgorithm());
}