Skip to content

Instantly share code, notes, and snippets.

View shannah's full-sized avatar

Steve Hannah shannah

View GitHub Profile
@shannah
shannah / AppBundlerTask.diff
Created January 23, 2013 16:57
A patch for appbundler to set the LC_CTYPE environment variable to UTF-8. This is a workaround for the bug http://java.net/jira/browse/MACOSX_PORT-165
diff -r 563fcd766efe appbundler/src/com/oracle/appbundler/AppBundlerTask.java
--- a/appbundler/src/com/oracle/appbundler/AppBundlerTask.java Wed Sep 19 17:54:08 2012 +0100
+++ b/appbundler/src/com/oracle/appbundler/AppBundlerTask.java Tue Jan 22 13:31:11 2013 -0800
@@ -577,7 +577,16 @@
xout.writeEndElement();
xout.writeCharacters("\n");
-
+
+ // Write Environment
@shannah
shannah / gist:4610833
Created January 23, 2013 17:42
CameraExample.html
<!DOCTYPE html>
<html>
<head>
<title>Camera Example</title>
</head>
<body>
<div>
<button id="capture">Capture</button>
</div>
<div id="results">
@shannah
shannah / CameraExample.java
Created January 23, 2013 17:53
CodenameOne CameraExample
final Form hi = new Form("Hi World");
final WebBrowser b = new WebBrowser(){
@Override
public void onLoad(String url) {
final BrowserComponent c = (BrowserComponent)this.getInternal();
// Create a Javascript context for this BrowserComponent
final JavascriptContext ctx = new JavascriptContext(c);]
// Create a new Javascript object "camera"
public void testLoadJSONViaWebBrowserWJSONParse(){
final WebBrowser b = new WebBrowser(){
@Override
public void onLoad(String url) {
BrowserComponent c = (BrowserComponent)this.getInternal();
JavascriptContext ctx = new JavascriptContext(c);
JSObject response = (JSObject)ctx.get("JSON.parse(document.body.textContent)");
String version = response.getString("version");
String title = response.getString("feed.title.$t");
public void testLoadJSONUsingJSONParser(){
ConnectionRequest req = new ConnectionRequest(){
@Override
protected void readResponse(InputStream input) throws IOException {
//super.readResponse(input);
InputStreamReader reader = new InputStreamReader(input);
JSONParser parser = new JSONParser();
public void testLoadJSONUsingConnectionRequestAndJS(){
ConnectionRequest req = new ConnectionRequest(){
@Override
protected void readResponse(InputStream input) throws IOException {
//super.readResponse(input);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Util.copy(input, bos);
final String jsonContentStr = new String(bos.toByteArray());
public void testLoadJSONViaWebBrowserWJSONParser(){
final WebBrowser b = new WebBrowser(){
@Override
public void onLoad(String url) {
BrowserComponent c = (BrowserComponent)this.getInternal();
JavascriptContext ctx = new JavascriptContext(c);
String responseString = (String)ctx.get("document.body.textContent");
byte[] responseBytes = responseString.getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(responseBytes);
@shannah
shannah / GoogleMapsCodenameOneTest.java
Created February 21, 2013 16:53
Google Map inside CodenameOne WebView component.
public void start(){
Form hi = new Form("Google Direction Service");
final GoogleMap map = new GoogleMap();
hi.setLayout(new BorderLayout());
final TextField start = new TextField();
start.setHint("Start location");
public function beforeHandleRequest(){
Dataface_Application::getInstance()
->addHeadContent(
sprintf('<link rel="stylesheet" type="text/css" href="%s"/>',
htmlspecialchars(DATAFACE_SITE_URL.'/style.css')
)
);
}
#xf-logo {
background-image: url(images/custom-logo.png);
height: 75px;
}