Skip to content

Instantly share code, notes, and snippets.

View mwbrooks's full-sized avatar
🏠
Working from home

Michael Brooks mwbrooks

🏠
Working from home
View GitHub Profile
# Add Gem Source (Heroku addition)
source :gemcutter
# Heroku (stack bamboo 1.8.7) requires this exact bundler version
group :production do
gem 'bundler', '0.9.20'
end
# Dependencies are generated using a strict version,
# Don't forget to edit the dependency versions when upgrading.
@mwbrooks
mwbrooks / bb-xhr.html
Created July 13, 2010 07:44
PhoneGap-BlackBerry XHR
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>BlackBerry XHR Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when PhoneGap is loaded.
@mwbrooks
mwbrooks / XXX_iPhoneAppDelegate.m
Created August 5, 2010 21:30
PhoneGap-iPhone UIWebView viewport fix
/* PhoneGap-iPhone UIWebView viewport fix */
/**
Called when the webview finishes loading. This stops the activity view and closes the imageview
*/
- (void)webViewDidFinishLoad:(UIWebView *)theWebView
{
/* Fix the viewport to properly fit to the screen */
CGRect windowFrame = [ [ UIScreen mainScreen ] bounds ];
CGRect webViewFrame = [ [ UIScreen mainScreen ] applicationFrame ];
/*
The MIT License
Copyright (c) 2010 Jesse MacFadyen, Nitobi Software
jesse.macfadyen@nitobi.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
@mwbrooks
mwbrooks / kill_bb_simulator.bat
Created August 19, 2010 06:13
BB Simulator wouldn't close on Win7? Kill it!
taskkill /IM fledge.exe
@mwbrooks
mwbrooks / index.html
Created October 3, 2010 21:23
PhoneGap-Console
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<title>PhoneGap Console</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript">
@mwbrooks
mwbrooks / notification.confirm.md
Created October 22, 2010 16:48
Markdown code block within list item

iPhone Quirks

  • iPhone does not block while the confirm dialog is displayed.
  • Returns a delegate object from navigator.notification.confirm()
  • Calls delegate.onAlertDismissed(index, label) when confirm is dismissed
    • index is the 0 based index value of the button pressed
    • label is the text label of the button pressed

function showConfirm() {

@mwbrooks
mwbrooks / blackberry-webworks.md
Created January 13, 2011 17:38
Overview of PhoneGap BlackBerry WebWork - original revision by filmaj

BlackBerry WebWorks & PhoneGap

WebWorks is a BlackBerry SDK that leverages Web technologies to create applications for BlackBerry 5.0, 6.0, and QNX. An application that is built with WebWorks uses HTML, CSS, and JavaScript and is called a Web widget. The structure of the application is similar to a thick-client JavaScript Web application, where JavaScript manages the model, view, and logic.

WebWorks enhances the JavaScript API to allow any Web widget application to access any Blackberry Java API. RIM includes a small WebWorks JavaScript API that allows access to some BlackBerry device features, such as invoking third-party applications. However, more importantly, WebWorks allows developers to create an Java extension that binds JavaScript and Java. This means any Java API can be accessible to JavaScript.

The WebWorks SDK uses a command-line tool called bbwp.exe (Windows-only) to create a BlackBerry-compatible application binary (.cod). Since a WebWorks application is pa

@mwbrooks
mwbrooks / UntitledAppDelegate.m
Created January 28, 2011 18:18
Load a PhoneGap-iPhone app from a custom start page.
//
// UntitledAppDelegate.m
// Untitled
//
// Created by Michael Brooks on 11-01-28.
// Copyright __MyCompanyName__ 2011. All rights reserved.
//
#import "UntitledAppDelegate.h"
#import "PhoneGapViewController.h"
@mwbrooks
mwbrooks / battery-plugin.js
Created February 2, 2011 23:25
Plugin example
(function() {
var Battery = function() {
return {
//
// Get a battery property
//
// @param property to get. Only 'Power' is supported.
// @param successCallback is provided an argument { level: [0, 100] }
// @param errorCallback is called on any native error and provided a message
//