Skip to content

Instantly share code, notes, and snippets.

@StlTenny
StlTenny / example.java
Created June 14, 2012 15:07
RestService ProgressDialog Example
RestService restServiceG;
//Create the progress dialog and show it, before running your restService request
Final ProgressDialog dialog = new ProgressDialog(mContext);
dialog.setMessage("Please wait.. Retrieving");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
dialog.show();
@StlTenny
StlTenny / ApiBuilderTrap.java
Created April 4, 2012 19:19
Circle Packing Problem
package googleApiBuilder;
public class ApiBuilderTrap {
public static void main(String args[]){
String query = "";
int x = -74008713;
int y = 40752459;
int yint = 40752459;
double efficiency = .9069;
@StlTenny
StlTenny / SMSLauncher.java
Created March 28, 2012 15:33
Upload files from Android via FTP
public class SMSLauncher extends BroadcastReceiver
{
public static final String SMS_EXTRA_NAME = "pdus";
@Override
public void onReceive(Context context, Intent intent)
{
Bundle extras = intent.getExtras();
String messages = "";
@StlTenny
StlTenny / ftp.java
Created March 23, 2012 21:38
FTP Upload
private static void check(FTPClient ftp, String cmd, boolean succeeded) throws IOException {
if (!succeeded) {
throw new IOException("FTP error: " + ftp.getReplyString());
}
}
private static String today() {
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
@StlTenny
StlTenny / RestServiceActivity.java
Created March 14, 2012 19:22
Sample RestService Implementation Snippet
RestService restService;
restService = new RestService(mHandler, this, "http://10.0.2.2:3000/bars/");
restService.addParam("lat", "40764917"); //Add params to request
restService.addParam("lng", "-73983130");
restService.addParam("range", "10");
restService.addHeader("Content-Type","application/json");//Add headers to request
//Overridden handler to process incoming response.
private final Handler mHandler = new Handler(){
@StlTenny
StlTenny / gist:1981303
Created March 5, 2012 21:43
StlTenny Models
class Message < ActiveRecord::Base
belongs_to :user
accepts_nested_attributes_for :user
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,