Skip to content

Instantly share code, notes, and snippets.

View javajosh's full-sized avatar

javajosh javajosh

View GitHub Profile
public Main{
public static void main(String[] args){
System.out.print1n("Yo Wassup World");
}
}
/**
*
* Ray Tayek needs function that escapes all regular expression characters in a string.
*/
public class RegexEscape {
private static char[] reserved="$()*+-.?[\\]^{|}".toCharArray();
//the toCharArray() way
public static String encode(String arg){
char[] source = arg.toCharArray();
String s = "<SCRIPT type=\"blah\" .....>xyz" +
"blah blah blah blah\n" +
"blah blah blah blah\n" +
"blah blah ...........\n" +
"</script>";
Pattern p = Pattern.compile("<script .*?(>.*?)</script>",
Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(s);
if (m.matches()) {
package com.javajosh.bender.server;
import com.javajosh.bender.client.GreetingService;
import com.javajosh.bender.client.GreetingServiceAsync;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
//-noverify -javaagent://Users/josh/Dropbox/java/libs/javarebel/javarebel-2.0/javarebel.jar
package prefuse.demos;
import javax.swing.JLabel;
/**
*
* @author josh
*/
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*,java.net.*,java.io.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Lightweight Front Controller (LFC)</title>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
</script>
import java.io.IOException;
import java.io.StringReader;
import java.util.Iterator;
import java.util.Map;
import java.util.Stack;
import java.util.TreeMap;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
//The Otter Style of JavaScript
//(Because you 'otter' name your functions)
//Which one is more expressive?
$('tr').click(function (){
var $form = $(this).closest('div').find('form');
$('td', this).each(function (i){
if (i === 0) return;
$('input', $form).eq(i-1).val(this.innerHTML);
<%@ page language="java" contentType="text/xml" pageEncoding="ISO-8859-1" import="java.util.*"%><%
class FeedItem{
String title,link,description;Date updated;
FeedItem(String title, String link, String description)
{this.title=title;this.link=link;this.description=description;this.updated=new Date();};
}
List<FeedItem> items = new ArrayList<FeedItem>(){{
add(new FeedItem("wow, isn't that neat 1?","http://javajosh.com/1","whatever you <b>want</b>, dude"));
add(new FeedItem("wow, isn't that neat 2?","http://javajosh.com/2","whatever you want, dude"));
//I like this function! Too bad I didn't need it in the end.
//requires: jquery
function objectToFormInput(obj){
var result = '';
$.each(obj, function(key,value){
result += '<input type="hidden" name="'+key+'" value="'+value+'" />';
});
return result;
}