Install a COD file on a Blackberry
Often, if a blackberry app fails to install correctly via Blackberry AppWorld, then you can contact the app developer and ask them for the COD file for a manual installation. If you use the Blackberry Desktop software, it isn’t difficult to install it manually. But here’s a video showing the procedure:
Make iPhone App available for iPad
Ok, If you have an iPhone App, and want it to be available for iPad also, then selecti Edit Project Settings from the Project menu and then navigate to the Build tab.
Once there, search for “Targeted” in the search box, and change the value from iPhone to iPhone/iPad.
*Simples*
Porting a Palm Pre WebOs App to Touchpad
Without making any changes to a Palm Pre WebOs app, if you try to run it in a Hp Touchpad, then it appears like a little mobile phone in the middle of the screen, not making full use of the screen size available.
Easy fix is to add “uiRevision” : “2” to the appinfo.json file, thus making full use of the screen size.
And, it appears full screen as follows:
Transfer contacts from Palm to Blackberry
There does appear to be a number of ways to transfer contacts from Palm pre to Blackberry, most involving Outlook. But this way does not use outlook.
First press phone icon and type #*66623#, and then wait as a VCF file is created (PMMigration.vcf).
Connect the USB cable, and upload the VCF file to Google Contacts (Google.com/contacts). Then go to your blackberry, and download Google Sync from (m.google.com/sync). With this app, you can select either a manual or automatic sync.
Et viola!
2011 in review
The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.
Here’s an excerpt:
The concert hall at the Syndey Opera House holds 2,700 people. This blog was viewed about 36,000 times in 2011. If it were a concert at Sydney Opera House, it would take about 13 sold-out performances for that many people to see it.
Lucene example, free text search on .NET DataSet
If you don’t have Free Text Search for your SQL server database, then you can use Lucene.NET to run free text searches on DataSets.
First you have to build up a Full text index (on disk), based on an SQL statement:
var strIndexRoot = Server.MapPath("FT");
if (System.IO.File.Exists(strIndexRoot + @"\write.lock"))
{
System.IO.File.Delete(strIndexRoot + @"\write.lock");
}
Directory directory = FSDirectory.GetDirectory(strIndexRoot);
Analyzer analyzer = new StandardAnalyzer();
IndexWriter writer = new IndexWriter(directory, analyzer);
var strSQL = "select id,text from yourTable";
System.Data.DataSet ds = ExecuteDataSet(strSQL);
foreach (DataRow dr in ds.Tables["sql"].Rows)
{
Document doc = new Document();
doc.Add(new Field("id", dr["id"].ToString() , Field.Store.YES, Field.Index.NO));
doc.Add(new Field("postBody", dr["text"].ToString(), Field.Store.YES, Field.Index.ANALYZED));
writer.AddDocument(doc);
}
writer.Optimize();
writer.Flush();
writer.Close();
You need to have a folder called “FT” (Free text) as a subfolder of your ASP.NET root folder.
I’ve omitted the code for “ExecuteDataSet”, it’s just a call to the database with an SQL command.
The FT folder will have the files:
segments.gen
segments_2
_0.cfs
Once the Free Text Index is generated.
Then to Query the free Text Index, I used the code:
var strIndexRoot = Server.MapPath("FT");
if (IO.File.Exists(strIndexRoot + @"\write.lock"))
{
IO.File.Delete(strIndexRoot + @"\write.lock");
}
Directory directory = FSDirectory.GetDirectory(strIndexRoot);
Analyzer analyzer = new StandardAnalyzer();
IndexWriter writer = new IndexWriter(directory, analyzer);
QueryParser parser = new QueryParser("postBody", analyzer);
Query query = parser.Parse("User Query goes here");
//Setup searcher
IndexSearcher searcher = new IndexSearcher(directory);
//Do the search
Hits hits = searcher.Search(query);
int hitNumber = hits.Length();
for (int i = 0; i < hitNumber; i++)
{
Document doc = hits.Doc(i);
var id = doc.Get("id");
var text = doc.Get("postBody");
}
searcher.Close();
directory.Close();
Getting a numeric value for the similarity of two text values in SQL Server
If you don’t have the luxury of a full text index on your free SQL server express database, or can’t set it up, because someone else manages or hosts, it, then a work around is this function that returns a numeric value for the similarity of two text values (which can be used as an order-by clause later)
create function func_similarity (@TextBody varchar(8000), @SearchTerm varchar(4000)) returns int as BEGIN if ( @SearchTerm = @TextBody ) return 2 if ( @Textbody like '%' + @SearchTerm + '%') return 1 if ( @SearchTerm like '%' + @Textbody + '%') return 1 return 0 END
In my case, I was looking for a ‘kind of’ free text lookup on a table of US zip codes:
create proc FindUSPostcode @city varchar(100) as select top 10 * from postcodeus order by dbo.func_similarity(Town,@city) + dbo.func_similarity(City,@city) +dbo.func_similarity(state,@city) desc
This meant that a lookup for
FindUSPostcode('Detroit')
Returns a top result for Detroit, Maine (Somerset county). But ‘Detroit, MI’ returns a top result for Detroit Michigan.
An API will come soon! (postcodefinder.org.uk)
Single Image from Flikr using API in AJAX
Here is a code example of how to get one single image out of Flikr, and place it into a html page using AJAX.
Just call getImageFromFlikr with the search text, and an output element. It works asynchronously, so it will return as soon as Flikr is contacted.
function getImageFromFlikr(searchText, output)
{
try
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState!=4) return;
if (xmlhttp.status != 200)
{
output.innerHTML = “Error”;
}
if (xmlhttp.status == 200)
{
output.innerHTML = eval(xmlhttp.responseText); //retrieve result as an JavaScript object
}
}
var strUrl = “http://api.flickr.com/services/rest/?”;
strUrl += “method=flickr.photos.search”;
strUrl += “&api_key=cabbc1b68c18461ca0627991833d8f97”;
strUrl += “&text=” + encodeURIComponent(searchText);
strUrl += “&per_page=1”;
strUrl += “&format=json”;
strUrl += “&sort=relevance”;
xmlhttp.open(“GET”,strUrl,true);
xmlhttp.open(“GET”,strUrl,true);
xmlhttp.send();
}
catch (err)
{
output.innerHTML = err.message;
}
}function jsonFlickrApi(flikrObj)
{
var fmt=”http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_m.jpg”;
fmt = fmt.replace(“{farm-id}”,flikrObj.photos.photo[0].farm);
fmt = fmt.replace(“{server-id}”,flikrObj.photos.photo[0].server);
fmt = fmt.replace(“{id}”,flikrObj.photos.photo[0].id);
fmt = fmt.replace(“{secret}”,flikrObj.photos.photo[0].secret);
var html = “<img src='” + fmt + “‘>”;
return html;
}
Find Backlinks to a website using AJAX
One of the most basic SEO tools is a backlink checker, and if you need to fine tune this, then automating the check will save you lots of time, so this is my experience with the SEOMOZ links API using AJAX.
The basis of the API, is a call to the URL: http://lsapi.seomoz.com/linkscape/links/<URL>?Scope=page_to_page&Sort=page_authority where <URL> is the site in question. This throws up the basic HTTP authentication challenge, so I’ve included the username and password:
Your Access ID: member-2dd03f462e
Your Secret Key: 018a47ae0940f6342577b24dfce80a5f
This code requires the Base64.js code library from www.webtoolkit.info, to base64 encode the HTTP authentication. Note that this code will only work when run locally from Internet Explorer, it won’t work hosted online due to cross-domain restrictions.
<input type="text" name="input" id="input" value="www.xyz.com">
<input type="button" onclick="BacklinkCheck()" value="Check">
<br>
<div id="output"></div>
<script language="javascript">
function BacklinkCheck()
{
var auth = authenticate('member-2dd03f462e','018a47ae0940f6342577b24dfce80a5f');
var input = document.getElementById("input");
var output = document.getElementById("output");
output.innerHTML = "working...";
var http=new XMLHttpRequest();
var url = "http://lsapi.seomoz.com/linkscape/links/"
url += input.value + "?Scope=page_to_page&Sort=page_authority";
http.open("GET", url, true);
http.setRequestHeader('Authorization', auth);
http.setRequestHeader('Content-type', 'text/html; charset=unicode');
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
var html = "<table>"
var jsondata=eval("("+http.responseText+")");
jsondata = jsondata.sort(
function(a, b){
if (a.upl < b.upl) //sort string ascending
return -1
if (a.upl > b.upl)
return 1
return 0 //default return value (no sorting)
});
for (i in jsondata )
{
var backlink = jsondata[i];
if (i % 2 == 0)
{
html += "<tr>"
}
else
{
html += "<tr>"
}
html += "<td width=50%><a onclick=\"this.innerHTML='" + backlink.uu.replace('\'','') + "'\">"+ backlink.upl + "</a></td>";
html += "<td width=50%>" + backlink.ut + "</td>";
html += "</tr>";
}
html += "</table>";
output.innerHTML = html;
}
if(http.readyState == 4 && http.status != 200)
{
alert("Something went wrong");
}
}
http.send(null);
}
function authenticate(user, password) {
var tok = user + ':' + password;
var hash = Base64.encode(tok);
return "Basic " + hash;
}
</script>
Convert text to a HTML table
Here is a handy litte script that converts tabulated text into a HTML table. Apply a CSS stylesheet to it, and it’ll look nice too …
<textarea id="input" cols=100 rows=10>
</textarea><br>
<input type="button" id="Tabelize" onclick="tabilize()" value="tabilize">
<div id="output"></div>
<script language="javascript">
function tabilize()
{
var input = document.getElementById("input");
var output = document.getElementById("output");
var splitInput = input.value.split("\n");
var html = "<table>";
for(i in splitInput)
{
if (i % 2 == 0)
{
html += "<tr>";
}
else
{
html += "<tr>";
}
var splitRow = splitInput[i].split("\t");
for(j in splitRow)
{
html += "<td>" + splitRow[j] + "</td>";
}
html += "</tr>";
}
html += "</table>";
html = html.replace(/</g,"<");
html = html.replace(/>/g,">");
output.innerHTML = html;
}
</script>

