Skip to content

Instantly share code, notes, and snippets.

View jmesnil's full-sized avatar

Jeff Mesnil jmesnil

View GitHub Profile
@jmesnil
jmesnil / ScriptTest.java
Created July 25, 2008 12:07
How to execute JavaScript code from a Java class
public class JavaScriptTest {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.eval("print('hello, world!')");
}
}
public class AppleScriptTest {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("AppleScript");
engine.eval("tell application \"Finder\"\n display dialog \"Who cares?\"\n end tell");
}
}
cd ~/Work
# retrieve the latest version of git
git clone git://git.kernel.org/pub/scm/git/git.git
cd git/
make GITWEB_PROJECTROOT="/Users/jmesnil/Work/" \
GITWEB_CSS="/gitweb/gitweb.css" \
GITWEB_LOGO="/gitweb/git-logo.png" \
GITWEB_FAVICON="/gitweb/git-favicon.png" \
bindir=/opt/local/bin
gitweb/gitweb.cgi
#!/usr/bin/env jruby
require 'rubygems'
require 'jmx4r'
runtime = JMX::MBean.find_by_name "java.lang:type=Runtime"
# runtime.system_properties is a TabularData
runtime.system_properties.each do | sysprop |
puts "#{sysprop["key"]} = #{sysprop["value"]}"
end
#!/usr/bin/env jruby
require 'rubygems'
require 'jmx4r'
require 'jconsole'
mem_pools = JMX::MBean.find_all_by_name "java.lang:type=MemoryPool,*"
mem_pools.each do |pool|
# print the 'name' property of the pool's ObjectName
puts pool.object_name["name"]
end
for i in {1..100}
do
echo $i
ant -Dtest-mask=JMSServerControl2Test integration-tests
if [ $? != 0 ] ; then
break
fi
done
(defn verify-challenge
[callback mode topic challenge]
(let [url (build-callback-url callback mode topic challenge)]
(try
(= challenge (.trim (apply str (:body-seq (request url))))) 204
(catch Exception ex (failed-challenge callback (.getMessage ex))))))
RESP_FILE=/tmp/gist.tmp
rm -f $RESP_FILE
USER=`git config --global github.user`
USERAVAIL=$?
TOKEN=`git config --global github.token`
TOKENAVAIL=$?
if [ $USERAVAIL -eq 0 -a $TOKENAVAIL -eq 0 ]; then
AUTH="--data-urlencode login=$USER --data-urlencode token=$TOKEN"
fi
(defn verify-subscriber [callback sync mode topic challenge]
(debug callback sync mode topic challenge)
(if sync
(verify-challenge callback mode topic challenge)
202))
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.