View gist:67341
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Main{ | |
public static void main(String[] args){ | |
System.out.print1n("Yo Wassup World"); | |
} | |
} |
View RegexEscape.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* 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(); |
View gist:83931
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) { |
View Intra-server GWT RPC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
View gist:124381
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-noverify -javaagent://Users/josh/Dropbox/java/libs/javarebel/javarebel-2.0/javarebel.jar | |
package prefuse.demos; | |
import javax.swing.JLabel; | |
/** | |
* | |
* @author josh | |
*/ |
View Lightweight Front Controller.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ 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> |
View SEX.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
View otter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
View rss.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ 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")); |
View objectToFormInput.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
} |
OlderNewer