Back from USA trip
So I’ve just come back from our trip to USA, where we visited a lot of IT companies – big ones like Microsoft, Oracle, IBM, etc. and some startups, like Zemanta, Trumpet, SkyGrid, Noovo, etc. It was awesome visiting all of you guys and most of all, we’ve learned a lot! I cannot summarize the whole trip in one post, but let me just say, Silicon Valley’s spirit is just great, it’s hard to describe it only in words. Let me just show you our “crash-in” to TechCrunch office:
Read the whole article here: Roving Slovenian Hackers Turned Away By Facebook & Google, But Welcomed At TechCrunch
That was cool experience, we had a great chat and it was very nice to meet guys who writes a great blog every day! Thank you! And about that challenge we were mentioning in video – stay tuned, that’s all I can say for now :)
After that, we were also interviewed in San Francisco by Slovenian journalist Matej Praprotnik and featured on Slovene national radio. You can read and listen to our story here (in Slovene language): Evrotip.
author: Aleš Rosina | No Comments | Tags: trip, techcrunch, usa, radio
May
2010
USA tour 2010
I’m traveling (almost) for two months to USA, so I won’t be able to blog that much. Even though we are going to visit a lot of Silicon Valley companies and Universities, we are also going to drive a lot (you can check our trip on my Dopplr account) so I’ll be lucky to just catch some wi-fi for checking email, facebook and all that stuff.
But since there is a lot of going on this spring, and we will be in the center of all geeky events, I guess I’ll just have to write a few short blog posts. For example, next week we have new iPhone OS 4 event and more importantly, Visual Studio 2010 launch event from Microsoft.
See you in San Francisco and New York area, now let me pack my bags :)
And if you are Slovenian reader, check also our travel blog on http://zda2010.fri.uni-lj.si (or try out translated version by Google translate).
For the end, I have to say a big thanks to all of our sponsors (check them on our travel blog), who made it possible to go to USA for so long!
author: Aleš Rosina | No Comments | Tags: travel
April
2010
Windows Phone 7 for developers
This Saturday I had a presentation at MobileCamp Ljubljana about upcoming Windows Phone 7. Since I like minimalistic presentations let me add a few words besides slides:
As you can see in a lot of videos around web, UI is structured a little differently as we are used to (eg. iPhone, Android, Maemo, Sybian, …). On home screen (or start screen) are tiles, which are “active” – they are animating and shows a lot of information as it can be best seen on videos. Microsft also invented something called hubs – actually these are apps, which are scrollable left and right.
I did a very simple demo at my lecture, you can download it here. It’s very basic app, which uses WiFi-tocke.si service and shows a list of spots in my area. There is no advanced code, just basic list and one subpage for showing details of each hotspot. Try it out and if you have any questions, leave a comment.
And just to refresh – for development you need a free developer tools and you can grab them here: http://developer.windowsphone.com/. If you are interested in more step-by-step guide, check out first and second lecture from MIX10 conference.
Ok, now let me just write a few words how to distribute your apps. As you probably know, you will have to use Marketplace (similar to iPhone AppStore). There are also a lot of countries, where you cannot apply for developer account due to restrictions of payments. Check my slides for full map. A lot is yet unknown, since Microsoft is promising more details about Marketplace in May. Check out this video of a session from MIX10 for more details.
I’ll also publish video of my lecture from MobileCamp Ljubljana when it will be online. Stay tuned :) Until than you can check what folks are tweeting about #mobilecamplj.
UPDATE: I just found out, that videos are finally online, so here’s mine lecture. Video is pretty poor quality, but I think you’ll get the point.
author: Aleš Rosina | 1 Comment | Tags: wp7, windows-phone
March
2010
jQuery Project Template for Visual Studio
Recently I wanted to create a couple of websites, more precisely, AJAX websites with a lot of animation and calls to (external) web services. So basically, I needed an HTML page with included jQuery library and support for IntelliSense. No need for ASP.NET or any other server side stuff, like data access, MVC etc.
Since I wanted to reuse this project template, I created my own Visual Studio template – jQuery Project. Creating a template is very simple, if you’re interested in it, here you can find very well written article about it by Rick Strahl.
In this template you have one HTML file with a jQuery script tag included and a MyScript.js file with a little trick to enable IntelliSense in an external javascript file:
/// <reference path="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1-vsdoc.js"/>
We are referencing to Microsoft’s host servers, thus decreasing latency, increasing parallelism and enabling better caching. Read more on the subject in this great article on Encosia.
That’s all you need to develop with jQuery in Visual Studio. Download this template here.
author: Aleš Rosina | 3 Comments |
March
2010
jQuery vs. ScriptManager in ASP.NET
There are a lot of discussions around web, why using one and why not the other one. My reason was pretty simple: I wanted a lot of cool UI effects, that are already part of jQuery. At first I thought, OK, no problem, I’ll just include both of them on my site. But … there are some cases, where jQuery and ScriptManager just don’t get along and why including two different libraries with the same functionalities?
So I did run a very simple test – wrote the same functionality for both cases. Since the test is very simple, it’s hard to make any conclusions, but the jQuery version was more than half size than ScriptManager version. The problem is, that for jQuery version you need to write more code by hand, but sometimes that’s good, because you have more control over what’s going on.
Let’s take a look at both cases (download code here) – ScriptManager is very simple, just drag on website ScriptManager, UpdatePanel with one Button and Label and UpdateProgress with one label. On Button_click event just change text in Label, and you’re done. No big deal, your AJAX enabled site is done!
jQuery version is on the other hand a little bit more tricky, so let’s go step by step. First, add new html site and let’s add a jquery script reference:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
It’s recommended to include jQuery from Google servers, for 3 major reasons: decreased latency, increased parallelism, and better caching. Why, read here. Anyway, now we need to manually add a few divs, spans and a button. Like this:
<div id="UpdatePanel1"> <input type="button" name="Button1" value="Button" id="Button1" /> <span id="Label1">Label</span> </div> <div id="UpdateProgress1" style="display:none;">loading.....</div>
Names are the same as in first example. OK, so here comes the tricky part – how the hell can we create server side code? Easy, with web services. So create new WebService1.asmx file and create new method Test().
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class WebService1 : System.Web.Services.WebService { [WebMethod] public string Test() { return "testing testing."; } }Let’s stop here for a moment - [System.Web.Script.Services.ScriptService] signature is very important, since this will tell service, that it’s supposed to return JSON and not XML. With [WebMethod] we expose method to web service. What about client side? Simple, just use jQuery’s .ajax() method like this:
$(document).ready(function () { $("#Button1").click(function () { $("#UpdateProgress1").show(); $.ajax({ type: "POST", url: "WebService1.asmx/Test", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { $("#Label1").html(msg.d); $("#UpdateProgress1").hide(); } }); }); });
So when we click on button, first let’s show “loading” sign and than call web service. When the service returns result, success function will be triggered. This is where we show up result in a <span> and hide loading bar.
As you can see, it’s a little bit more work than normal, but you will gain a lot – even in this simple example was the jQuery version (upper picture) more than twice smaller than ScriptManager version (lower picture). Not to mention, that you’ll get much nicer code and a very popular JavaScript library with a lot of other useful functions, like manipulating with elements, CSS properties and much more.
If you have a small project, where you don’t care about size, use ScriptManager, since it’s much faster to develop with. But if you need some cool effects and better performance, than use jQuery.
You can download source code for those two examples here.
Have any thoughts? Leave a comment!
author: Aleš Rosina | 6 Comments | Tags: c-sharp, asp-net, jquery
February
2010
Windows Phone 7 and developers
Today Microsoft reviled their new OS for phones called Windows 7 phone at Mobile World Congress in Barcelona. There was a lot of rumors about it, how it will look like, what features will it have, when it’s available and so on. After this press conference, there are even more questions raised, at least for me. Let me just summarize a few key points of this new OS:
- It will be available at the end of this (2010) year
- It features completely new UI, with a lot of Zune look and functionalities
- The way we organized stuff is also much more efficient and nice
- It features Xbox Live, which means access to already very popular Xbox community
- Bing is also very nicely integrated
- Adobe Flash is not yet on device, but probably will be before launch – as Steve Balmer put it “we don’t have anything against it”
You can watch keynote (or newsroom) here, read a lot about it on Gizmodo, see a lot of pictures (and live coverage) on Engadget or see what are people twitting about it.
But that’s about it. No words about developer’s platform, any other third party applications etc. So, what can we developers expect? Where will we develop? How? So here are some basic information what I think will happen:
- We will develop using Visual Studio 2010 in C#, probably XNA and Silverlight – there are rumors, that this will be presented at MIX10 by Charlie Kindel and others
- We will sell apps strictly in Marketplace (this is not confirmed, yet not denied)
- Applications written for older Windows Mobile platforms will NOT work
- We have let’s say 6 months for creating new stuff, so at launch there will be plenty of apps
- It’s rumored, that you will not be able to develop in C++, C#/XNA will be exclusive
Let me just conclude with my though, that this was really necessary, since WM platform was already dying and Microsoft really needed to drastic move to survive on mobile platform. So decision to remove old apps support is one of the best, it is very similar to Palm’s move to WebOS from their old platform. And there will sooner or later be emulator for old applications, I’m pretty sure about that.
Disturbing is the rumor, that there will be no bypass from Marketplace, which can lead to another Apple AppStore like ridiculous rejections of completely legit applications. We will see about that.
I think Microsoft is back alive in mobile world. It’s a little bit early to compare it with competitors (Android, iPhone, Maemo, Palm), but it will surly be a bigger player than Palm. And for us, developers, that is a good thing.
author: Aleš Rosina | No Comments | Tags: windows-mobile
February
2010
WebKit vs. IE browser control in C#
Recently I needed to include a web browser control (in Windows Forms project), so the logical choice would be WebControl, which is actually only .NET wrapper around Internet Explorer’s ActiveX control.
Well, I wanted to try some other engines, like WebKit (which is core of Apple Safari, Google Chrome, Adobe AIR, etc.), since IE engine (called Trident) scores on Acid3 very low (13 out of 100) and WebKit engine scores almost perfect (99 out of 100). For most cases this is not important, since most of web pages are done with optimizations for all browsers, but sometimes it is.
So for this test I’ve created very simple application, where you can compare those two rendering engines (you can download this app here, if you’re not interested in code).
I have run this app on a different sites and found out, that WebKit renders pages faster, if there is a lot of JavaScript behind, where simple plain HTML pages is rendered faster by Internet Explorer engine. So based on that, you have to decide which control to use in your application.
For WebKit implementation I’ve used WebKit.NET, which is using Cairo derivate of WebKit (how to build it on your own, read here) and already includes binaries, so all you need to do, is to include WebKitBrowser in your toolbox in Visual Studio (right click on Toolbox > Choose items > .NET Framework Components > Browse… and select WebKitBrowser.dll from previously downloaded zip file) and drag it into your Form. Using this component is basically the same as using WebBrowser control, so you start navigation with
webBrowser1.Navigate(textBox1.Text);
and do something when document is loaded on event:
private void webBrowser1_DocumentCompleted(And that’s it, you just created a very simple web browser.
object sender, WebBrowserDocumentCompletedEventArgs e) { //... }
You can download project (with source code) here, so you can play with code or if you want only app, download it here.
author: Aleš Rosina | 5 Comments | Tags: c-sharp, webkit, trident, internet-explorer
February
2010
Stop using IE6, please!
I was just checking statistics for my site and I was shocked by one particular information: nearly 8% of visitors are still using Internet Explorer 6. This graph represents only users of Internet Explorer, so the biggest part (66.63%) is the latest version of IE, which was expected.
And why was I shocked? Well, I’m writing about latest technologies, about programming, about web … so I thought, that visitors are mostly “geeks” like myself, who always wants the newest technologies, especially if the new one is better and much easier to use. And specially for us programmers is easier to develop stuff.
So I stumbled upon this particular website, called ie6update.com. It’s meant for us, developers, to somehow “force” users of sites to upgrade their old browser. In fact, if you go to this website with IE6, you can see it in action. What it does, it shows IE’s Information bar, with a little help of Java Script, with notice to upgrade your browser. I think it’s cool way of notifying users, but still not forcing them to switch, if they are really (I mean really, really, really) used to that old piece of software.
Join the “fight” and add this to your site, you and million of other developers will appreciate it :)
author: Aleš Rosina | No Comments | Tags: ie6, web
February
2010
Using Flickr in .NET applications
Currently I’m working on a cool project, where I need to show some nice photos, just for visual effects. And the first thing I thought, where could I get cool photos? Easy, somewhere on the internet, right? Well, that can be tricky, since finding images on web is not that simple, there are license problems, images can be in poor quality, etc.
Since I’m also using Flickr for my own photos, it was obvious to choose this database. And it’s supposed to be the largest (public) database of images, photographs and even world famous artist are posting images on Flickr. OK, so we need to somehow access this database with our code. Sure, we can parse HTML, but that would be pretty stupid, since Flickr has great APIs exposed into the wild.
Flick APIs are exposed in various formats (JSON, SOAP, REST, etc.) but using that service in .NET applications means a little bit more hacking, if you want to do it by yourself. But there is one library, called FlickrNET, which was developed by Sam Judson. So I’ve used this library, which is super easy to use.
And as today is very popular for web services, you need to acquire API key, which you can get here for free.
For my case, I need to access just one random photo from Flickr Explore, since there are pretty cool photos from public photo stream. The only “hack” that I needed to do is to check, if there is a large image. In Flikcr, you (as author) can set to which sizes of photos others can access and if you upload smaller image than the “large” – which is defined by 1024 pixels width – Flickr will not create bigger image. So when requesting images, we need to take that into account – and here’s the code to do that:
FlickrNet.Flickr f = new FlickrNet.Flickr("your_api_key"); FlickrNet.Photos photos =
f.InterestingnessGetList(FlickrNet.PhotoSearchExtras.All, 100, 1); bool stop = false; int stop2 = 0; FlickrNet.Photo photo = null; while (!stop) { Random r = new Random((int)DateTime.Now.Ticks); photo = photos.PhotoCollection[r.Next(0, 99)]; FlickrNet.Size[] size = f.PhotosGetSizes(photo.PhotoId).SizeCollection; if (size.Length == 5 || stop2 == 100) if (size[4].Label.ToLower() == "large") stop = true; stop2++; } pictureBox1.ImageUrl = photo.LargeUrl;
So what we are doing here is just get a list of 100 popular images, and then checking for the first picture, that has large format. We will get a URL pointing to that image in photo.LargeUrl property and since this is a ASP.NET application, that is enough. For Windows applications, you would need to do a simple WebRequest for getting the image and than showing it as Bitmap in picture box.
That’s it! Very simple and extremely useful for creating cool UIs. Leave a comment, if you have any question.
author: Aleš Rosina | 4 Comments | Tags: c-sharp, flickr, dotnet
January
2010
Locating Windows Mobile phone without GPS
We all know apps like Google Maps Mobile, Microsoft’s Bing equivalent, Nokia Maps, etc. In every app you have option to locate yourself, even if you don’t have GPS or it’s turned off. The only thing you need is quite good signal and access to Internet.
Obvious question is: how is it done? Since I was playing a little bit with Windows Mobile, I’ll show you how to create simple app, which will show your current location. OK, not your exact location, but location of the closest Cell ID, which is in cities quite accurate (on few 100 meters).
This app is capable of showing Cell ID info, “transforming” it into latitude and longitude, finding the closest address and showing map of your location. To achieve this, I have used a few services, that are out there:
- First of all cool wrapper for Radio Interface Layer (RIL) written in C# by Dale Lane
- Mobile Location – web service for “transforming” Cell ID into latitude and longitude by Ericsson Labs – suppose to have 3.5million cells all around the world in their databases!
- Bing Maps API – web service by Microsoft for everything you want to do with maps
Everything is very well documented, so we just need to put everything together.
The first step is very easy – just download RIL.cs from Dale’s blog and include it into your Windows Mobile project. For showing up the Cell info, you just need to modify this function rilResultCallback in RIL.cs, because original function is lacking MNC (Mobile Network Code) data, so we will add this (bolded):
public static void rilResultCallback(uint dwCode, IntPtr hrCmdID, IntPtr lpData, uint cbData, uint dwParam) { //.... celltowerinfo = rilCellTowerInfo.dwCellID + "-" + rilCellTowerInfo.dwLocationAreaCode + "-" + rilCellTowerInfo.dwMobileNetworkCode + "-" + rilCellTowerInfo.dwMobileCountryCode; //... }
Before we will pass this data to Mobile Location service, we need to register ourselves for API key. It’s simple, just fill in the form and you’ll get API key. So, next thing is to pass Cell ID info into this web service. We have option of choosing JSON or XML version, and I have chosen JSON version (with no obvious reason), so I needed to somehow parse JSON into more usable form. For doing that, I used code, found in this blog post. Remember, we are on mobile device, so using very light libraries is essential, since those devices are still not so powerful. Also notice, to put your API key instead of “yourkey” string into web service url.
string cellInfoFull = RIL.GetCellTowerInfo(); string[] cellInfo = cellInfoFull.Split(new char[] { '-' }); cellInfo[0] = Convert.ToInt64(cellInfo[0]).ToString("X"); cellInfo[1] = Convert.ToInt64(cellInfo[1]).ToString("X"); WebRequest oRequest = WebRequest.Create(
String.Format("http://cellid.labs.ericsson.net/json/lookup
?cellid={0}&mnc={2}&mcc={3}&lac={1}&key=yourkey",cellInfo)); WebResponse oResponse = oRequest.GetResponse(); StreamReader oReader = new StreamReader(oResponse.GetResponseStream()); string sContent = oReader.ReadToEnd(); Hashtable h = (Hashtable)JsonParser.JSON.JsonDecode(sContent); string latlong = ((Hashtable)h["position"])["latitude"].ToString() +
"," + ((Hashtable)h["position"])["longitude"].ToString();
We could finish here, but let me just add a little map into our application. For doing that, we need another API key, this time from Microsoft – find it here. Again, very easy, just filling in form and you’re done.
For usage and very cool example (with all steps how to use this service) follow this link on MSDN, so I will not explain in detail how to use it. We will just copy two functions into our project (after we have added two web services – GeocodeService and ImageryService) - ReverseGeocodePoint(string locationString) and GetImagery(string locationString). The first function is ready to use:
textBox2.Text = latlong + "\n" + ReverseGeocodePoint(latlong);
pictureBox1.Image = GetImageFromUrl(GetImagery(latlong));
What we’ve done here is to “convert” latitude and longitude into actual closest address.
For the second we have to add function for downloading image from given URL, which is pretty straight forward:
private Bitmap GetImageFromUrl(string url) { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); myRequest.Method = "GET"; HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); System.Drawing.Bitmap bmp =So that’s it! Now you need to create cool UI and a little bit of try-catch stuff :)
new System.Drawing.Bitmap(myResponse.GetResponseStream()); return bmp; }
Sure, this method will not work all around the world and is not accurate, so you need to do extensive testing, if you have plans to implement that kind of solution into your application.
What you can do to improve this method is to implement so called triangulation – basic idea is, that (especially) in urban areas, there are multiple cells, that covers each other. By tracking movements of your phone you can locate it much more accurate. I will finish here, since that would be completely out of scope, so leave a comment if you have any questions!
author: Aleš Rosina | 6 Comments | Tags: windows-mobile, location, ril, c-sharp
January
2010
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=0e59772a-a4e0-4c98-8194-db62f4f28624)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=0f6cd13e-32c2-4bee-962c-01fee5490a95)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=e041d5dd-a000-4cce-9abd-386461458c99)

![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=29d617cd-ae41-415e-992a-ef9aa529debb)

![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=a33305ce-6f70-4102-bdd0-79c05f8bc481)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=681cc85a-8ae7-4fc2-986f-b38d062dacb8)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=69e2c724-f75f-47cd-8213-250d99a23ee2)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=7e90b7f0-5c58-4f69-b9aa-a3cbf16087ee)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=820de37d-9889-4474-b371-42700412348f)

![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=1761bee7-5903-4975-92c8-39b39a38aa9c)
