Load BAR file onto Playbook
To load a BAR file onto a playbook, you need to put it into development mode first, which is
- Access Settings by swiping from the top on the home screen
- Select Security
- Select Development mode
- Select User Development Mode “ON”
- Set a password (in my case “pass”)
- Note your IP address from About-> Network -> Wifi -> ipV4
If you don’t do this step, you get the error:
Error: Device is not in the Development Mode. Switch to Development Mode from Se
curity settings on the device.
Otherwise you see this:
C:\Program Files\Research In Motion\BlackBerry WebWorks SDK for TabletOS 2.2.0.5
\bbwp\blackberry-tablet-sdk\bin>blackberry-deploy.bat -installApp -password pass
-device 192.168.0.100 -package “C:\BBWP\SatNav\Build\SatNav.bar”
Info: Sending request: Install
Error: User authentication failed
Info: Sending request: Install
Info: Action: Install
Info: File size: 707501
Info: Installing …
Info: Processing 707501 bytes
Info: Progress 3%…
Info: Progress 100%…
actual_dname::SatNav92aabe52d50d9673fe56dd61f146177.gYABgCL3cXiEoxXlTshS6VdnHC0
actual_id::gYABgCL3cXiEoxXlTshS6VdnHC0
actual_version::1.0.0.0
result::success
Convert an Image to text in C#
If you want to extract text from an image, then you can use a process called OCR. If you create a new project in Visual Studio, then make a web service reference to http://free-ocr.co.uk/ocr.asmx called “ocr”
A limitation of this free service, is that the image must be at most 100 x 100 pixels
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using simpleOCR.ocr;namespace simpleOCR
{
class Program
{
static void Main(string[] args)
{var sFile = new FileStream(@”C:\hello.jpg”,FileMode.Open);
byte[] PhotoBytes = new byte[sFile.Length];
sFile.Read(PhotoBytes, 0, PhotoBytes.Length);
simpleOCR.ocr.ocr webservice = new simpleOCR.ocr.ocr();
Console.Out.Write(webservice.Analyze(“your email”, PhotoBytes));
Console.ReadLine();
}
}
}
Parsing WDDX with a Regular Expression
WDDX is an XML Serialization format native to ColdFusion, and can be parsed in .NET using WDDX.NET (http://wddxnet.codeplex.com/) – However, it is an extra assembly in your deployment, and sometimes, something more simple (but less correct) may be handy.
Take these two WDDX packets for example;
<wddxPacket version=’1.0′><header/><data><struct>
<var name=’NOMARP’><string>Madrid</string></var>
<var name=’TYPCLA’><string>TOUTES</string></var>
<var name=’DIRECT’><number>1.0</number></var>
<var name=’NOMCIE’><string>Iberia</string></var>
<var name=’DATDEP’><string>070912</string></var>
<var name=’TAXES’><number>53.0</number></var>
<var name=’CDEARP’><string>MAD</string></var>
<var name=’REDUC’><number>0.0</number></var>
<var name=’TOTALD’><number>109.0</number></var>
<var name=’IDPROP’><string>MDcwMTExMjM0OTJBUlVNQURBTENJQiBXMDMwOTMwMzE5UkVTQVhNTCAgIDEyMzQ5Mg==</string></var>
<var name=’REMMTE’><string>0</string></var>
<var name=’DATRET’><string>140912</string></var>
<var name=’CODCIE’><string>IB</string></var>
<var name=’REMMTA’><string>0</string></var>
<var name=’REMMTB’><string>0</string></var>
<var name=’TAXADT’><string>53.63</string></var>
<var name=’QBDOSS’><number>56.0</number></var>
<var name=’RECODE’><string></string></var>
<var name=’TAXBEB’><string>0</string></var>
<var name=’RELIBL’><string>-</string></var>
<var name=’TAXENF’><string>0</string></var>
<var name=’PRIXE’><number>0.0</number></var>
<var name=’REMSSE’><string></string></var>
<var name=’PRIXB’><number>0.0</number></var>
<var name=’NUMSEG’><number>2.0</number></var>
<var name=’REMSSB’><string></string></var>
<var name=’SEQPRO’><number>1.0</number></var>
<var name=’PRIXA’><number>56.0</number></var>
<var name=’REMSSA’><string></string></var>
<var name=’TYPRO’><string></string></var>
<var name=’MSGREM’><string>Nant</string></var>
<var name=’FLGCIE’><string>IB_small.gif</string></var></struct></data></wddxPacket><wddxPacket version=’1.0′><header/><data><recordset rowCount=’2′ fieldNames=’SEQPRO,IDSEG,SEQSEG,CODSEG,SEQVOL,DATDEP,HEUDEP,DATARR,HEUARR,VILDEP,VILARR,CIESEG,CIENOM,NUMVOL,DEPNOM,ARRNOM,TYPEQU,OPRCIE,NESCAL’ type=’coldfusion.sql.QueryTable’>
<field name=’SEQPRO’><string>1</string><string>1</string></field>
<field name=’IDSEG’><string>NahjbcJUNFNIRaadfeLZw</string><string>CbejbcJNIRUNFaadgbLZw</string></field>
<field name=’SEQSEG’><number>1.0</number><number>2.0</number></field>
<field name=’CODSEG’><string>A</string><string>R</string></field>
<field name=’SEQVOL’><number>1.0</number><number>2.0</number></field>
<field name=’DATDEP’><string>070912</string><string>140912</string></field>
<field name=’HEUDEP’><string>2255</string><string>2140</string></field>
<field name=’DATARR’><string>070912</string><string>140912</string></field>
<field name=’HEUARR’><string>2355</string><string>2240</string></field>
<field name=’VILDEP’><string>MAD</string><string>ALC</string></field>
<field name=’VILARR’><string>ALC</string><string>MAD</string></field>
<field name=’CIESEG’><string>IB</string><string>IB</string></field>
<field name=’CIENOM’><string>Iberia</string><string>Iberia</string></field>
<field name=’NUMVOL’><string>354</string><string>361</string></field>
<field name=’DEPNOM’><string>Madrid</string><string>Alicante</string></field>
<field name=’ARRNOM’><string>Alicante</string><string>Madrid</string></field>
<field name=’TYPEQU’><string>320</string><string>320</string></field>
<field name=’OPRCIE’><string>—</string><string>—</string></field>
<field name=’NESCAL’><string>0</string><string>0</string></field></recordset></data></wddxPacket>
So, for this format, I used the Regular expression:
const string strWddxRegex = @”name..(?<Name>\w+)..(.(string|number).(?<Value>[\w.=]*)..(string|number).)+”;
Which served the purpose!
Content Validation 5.5.2 WP7
One of the most common reason for rejection for Windows Phone 7 (Wp7) apps, is support for dark and light themes. Most developers work in the dark theme, then not realizing that the text can’t be read when the phone is switched to light theme. This is picked up by Microsoft Testers, and reported as a Content Violation 5.5.2
Requirements
Application content, such as text and visual
elements, must be visible and legible regardless of
the phone theme. For example, if the phone
theme changes from black background to white
background, the text and visual elements of your
application must be visible or legible.
Comments: STEPS TO REPRODUCE
1. Navigate to the Settings page in the app list.
2. Tap theme and change Background to ‘Light’.
3. Launch your application.
4. Verify that the text and visual elements of the application are visible and legible.
RESULT
The application UI text is not legible when viewed in the ‘Light’ theme.
Here, is a solution I have come up with for “Panorama” style apps, by creating two backgrounds, one mostly black, one mostly white, and then calling the following function on MainPage_Loaded
/// <summary>
/// Detect theme, and apply background accordingly
/// </summary>
private void DisplayState()
{
Color lightThemeBackground = Color.FromArgb(255, 255, 255, 255);
SolidColorBrush backgroundBrush =
Application.Current.Resources[“PhoneBackgroundBrush”] as SolidColorBrush;
// Assume dark theme
BitmapImage bitmapImage = new BitmapImage(new Uri(“PanoramaBackground.png”, UriKind.Relative));
if (backgroundBrush.Color == lightThemeBackground)
{
// you are in the light theme
bitmapImage = new BitmapImage(new Uri(“LightPanoramaBackground.png”, UriKind.Relative));
}
ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = bitmapImage;
this.panorama.Background = imageBrush;
}
KB2463332 – Warning: SQL server inaccessible during installation
The Microsoft Windows Update KB2463332 makes your SQL server 2005 inaccessible during installation
If, you’ve got a situation where your database needs to be online 100% of the time, then take care when installing this update, and make sure you’ve got a backup in place.
The error message reported from SQL server during installation is:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
– It works fine once the installation is complete.
Export Bing Results to CSV
Ever since Google withdrew it’s search API, a way to automate search engine queries has fallen on Bing, and it’s obliged with the bing search API. You’ll need a Bing search API key before you can use this, but the process is automatic and free.
Unlike the old Google search API, the search result set is limited to 50 results per query, however, the query can be re-run with different offsets, and the result set concatenated.
A live demo of this can be seen at http://bing.freetextuk.com – Which returns a CSV of 300 results for any Bing query. The search box is pre-filled with a sample search to find link directories in spain (ending in .es).
Serve .torrent files from IIS7
By default IIS7 will not serve files with unknown MIME types, one of these could be the .torrent file type, which simply returns a 404 error.
From a command prompt, run %windir%\system32\inetsrv\appcmd set config /section:staticContent /+”[fileExtension=’.torrent’,mimeType=’application/x-bittorrent’]”
Then IISReset
(I’m not 100% sure if IISReset is required, but it worked for me).
How to cancel any outstanding javascript on a page
If you have a webpage, and you need to stop all javascript routines from running. That is, any routine started by setTimeout, and executing in a separate thread. Even if you do not have a reference to the value returned by setTimeout, then you can just clear all timeouts as follows;
var maxTimeout = setTimeout(‘null’,1);
for(i=0;i<maxTimeout;i++)
{
clearTimeout(i);
}
(PlayBook) Code signing request failed because this file has been previously signed
If you’re working on developing for BlackBerry PlayBook TabletOS, using webworks, you’ll find the usual fun & games when trying to sign the BAR file.
Here’s a few “Gotcha’s” that I got this morning:
[INFO] Parsing command line options
[INFO] Parsing bbwp.properties
[INFO] Validating WebWorks archive
[INFO] Parsing config.xml
[INFO] Populating application source
[INFO] Compiling WebWorks application
[INFO] Packaging the bar file
[INFO] Bar packaging complete
[INFO] Starting signing tool
Error: Code signing request failed because this file has been previously signed.
[ERROR] Signing failed
The solution to this error is to increment the buildId, as follows:
C:\Program Files\Research In Motion\BlackBerry WebWorks SDK for TabletOS 2.2.0.5\bbwp>
bbwp c:\bbwp\build\APP.zip -g -gcsk pwd -gp12 pwd2 -o c:\bbwp\build -buildId 2
Another nice error was this:
[INFO] Parsing command line options
[ERROR] Cannot sign application – failed to find signing keys
This basically meant that your p12 file needs to be in this folder
C:\Program Files\Research In Motion\BlackBerry WebWorks SDK for TabletOS 2.2.0.5\bbwp\bin
and named “sigtool.p12”
Basic HTTP Authentication over XMLHttpRequest (AJAX)
Here is a simple way to perform basic HTTP Authentication with a XMLHttpRequest – Ajax request – from your webpage.
var url = 'http://someurl.com';
xml = new XMLHttpRequest();
xml.open("GET", url, false, "username", "password");
xml.onreadystatechange = function() {
if (xml.readyState != 4) { return; }
if (xml.status != 200) {
alert("error");
return;
}
alert(xml.responseText);
};
xml.send(null);
You don’t have to do the Base64 encoding yourself, unlike some examples online. – Do note that “url” needs to be on the same domain as your script.