Skip to content

Instantly share code, notes, and snippets.

@saltnlight5
saltnlight5 / printvars.js
Last active October 11, 2015 05:48
JavaScript Examples
// This is for Java scripting engine.
// Print all global variables!
for (i in this) { println(i + '=' + this[i]); }
@saltnlight5
saltnlight5 / findres.py
Created October 1, 2012 15:48
Jython Scripts
import sys, java
res = sys.argv[1]
cl = java.lang.Thread.currentThread().getContextClassLoader()
url = cl.getResource(res)
print(url)
@saltnlight5
saltnlight5 / build.gradle
Created September 27, 2012 15:56
Gradle Build Exmaples
apply plugin: 'java'
repositories { mavenCentral() }
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.1'
compile group: 'com.google.guava', name: 'guava', version: '13.0.1'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'junit', name: 'junit-dep', version: '4.10'
}
@saltnlight5
saltnlight5 / Bash.sublime-build
Created September 27, 2012 00:47
Sublime Text 2
// A build script to run shell script in Windows using cygwin.
// NOTE that a selector is "source.shell", not ".sh"!
{
"cmd": ["C:/cygwin/bin/bash.exe", "--login", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.shell"
}
@saltnlight5
saltnlight5 / groovySql.groovy
Created September 20, 2012 14:22
Groovy Script Examples
// groovy -cp $HOME/.m2/repository/com/h2database/h2/1.3.166/h2-1.3.166.jar groovySql
// http://groovy.codehaus.org/Tutorial+6+-+Groovy+SQL
// Grab will not load the driver! but at least we can trigger it to download it and then use groovy -cp option to run this script.
// @Grab('com.h2database:h2:1.3.166')
import groovy.sql.Sql
sql = Sql.newInstance(
'jdbc:h2:~/test',
@saltnlight5
saltnlight5 / email.py
Last active October 10, 2015 09:07
Python Scripts
import smtplib
message = """From: [email protected]
To: [email protected]
Subject: SMTP e-mail test
This is a test e-mail message.
"""
s = smtplib.SMTP('smtp.mycompany.com')
#
# Bash Profile script
# Zemian Deng 07/03/2012
#
export EASYANT_HOME=$HOME/apps/easyant
export JAVA_HOME=$HOME/apps/jdk
export PATH=$JAVA_HOME/bin:\
$HOME/apps/maven/bin:\
@saltnlight5
saltnlight5 / snoop.jsp
Created July 22, 2012 22:30
JSP - Snoop Server Info from OpenShift
<HTML>
<HEAD>
<TITLE>JBossAS7 JSP snoop page</TITLE>
<%@ page import="javax.servlet.http.HttpUtils,java.util.Enumeration" %>
<%@ page import="java.lang.management.*" %>
<%@ page import="java.util.*" %>
</HEAD>
<BODY>
<H1>WebApp JSP Snoop page</H1>
@saltnlight5
saltnlight5 / script-console.jsp
Last active August 16, 2017 09:53
script-console.jsp
<%@ page import="java.io.*,java.util.*,javax.script.*" %>
<%
// A script console jsp for Java
// Last modified: Zemian Deng <[email protected]> 05/15/2014
ScriptEngineManager factory = new ScriptEngineManager();
// Get all the script engine names available by inspecting the classpath
List<String> scriptEngineNames = new ArrayList<String>();
for (ScriptEngineFactory fac : factory.getEngineFactories()) {
<!-- Build helper plugin adds additional classpath into test phase (test) -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<resources>