Skip to content

Instantly share code, notes, and snippets.

View dhavaln's full-sized avatar
💭
I may be slow to respond.

Dhaval Nagar dhavaln

💭
I may be slow to respond.
View GitHub Profile
@dhavaln
dhavaln / jquery-differed-test.js
Created December 6, 2011 09:35
jQuery Differed Example
function showData() {
console.log("final value :" +newArray.length);
console.log(newArray);
}
var newArray = [];
function method1() {
return $.Deferred(function( dfd ){
self.setTimeout(function(){
newArray.push("hello");
@dhavaln
dhavaln / Vaadin_layout_testApplication.java
Created December 6, 2011 09:57
Vaadin Sample application to set layout based on the Screen height and width
package com.example.vaadin_layout_test;
import com.vaadin.Application;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
@dhavaln
dhavaln / Application.java
Created December 12, 2011 16:18
Facebook JS SDK integration with Play Framework
public static void facebookLogin() {
try {
JsonObject profile = FbGraph.getObject("me"); // fetch the logged in user
String email = profile.get("email").getAsString(); // retrieve the email
System.out.println("facebook user " + email);
// do useful things
Session.current().put("username", email); // put the email into the session (for the Secure module)
} catch (FbGraphException fbge) {
flash.error(fbge.getMessage());
package com.dhavaln.mobile.android.plugin;
import java.util.Date;
import org.json.JSONArray;
import android.util.Log;
import com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin;
@dhavaln
dhavaln / AppComm.h
Created January 25, 2012 09:21
PhoneGap iOS Plugin Sample
#import <Foundation/Foundation.h>
#ifdef PHONEGAP_FRAMEWORK
#import <PhoneGap/PGPlugin.h>
#else
#import "PGPlugin.h"
#endif
@interface AppComm : PGPlugin {
NSString* callbackID;
}
@dhavaln
dhavaln / home.html
Created March 9, 2012 11:05
Phonegap Backbutton Test
<!DOCTYPE HTML>
<html>
<head>
<title>Home</title>
</head>
<body>
<div id="homePage" data-role="page">
<div data-role="header" data-position="inline">
@dhavaln
dhavaln / cordova-1.5.0.js
Created March 12, 2012 06:41
Phonegap Cordova JS changes to resolve backbutton issue
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
@dhavaln
dhavaln / index.html
Created March 12, 2012 09:13
Phonegap 1.5/Cordova Lazy Load Test
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="https://raw.github.com/jbrantly/yabble/master/lib/yabble.js"></script>
<script src="js/jquery.js"></script>
</head>
<body>
<button id="loadPhonegap">Load Phonegap</button>
@dhavaln
dhavaln / TestService.java
Created March 14, 2012 20:32
Phonegap v1.5 Network Test
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@dhavaln
dhavaln / camera.html
Created March 29, 2012 14:33
Phonegap Camera Capture Example
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo</title>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"/>
<script type="text/javascript" charset="utf-8" src="js/phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value