Mital Rasaniya

Ideas ~ Illusions ~ Innovations

1 note &

Change default font of your Android device

This article applies to all types of devices, no matter it’s a phone or a tablet or a dual-boot Android PC.

First and foremost you need an Android device with “root” acces. Every Android device is on top of Linux kernel. And these fonts are stored inside Linux file system. Dalvik VM loads all the installed apps on your device and restricts access to these files. By having “root” access, you can access these files in read-write mode.

Now, back to our main subject. Assume that you have rooted your phone. Now, download and install “TypeFresh” application from Android Marketplace, which is free. TypeFresh uses Astro File Manager to choose fonts, which is also available free from Android Market place.

Come back to your PC now, select desired “Sans Serrif” family fonts based of your choice, I have got an opportunity to extract my iOS’s “Helvetica-Neue” fonts from helvetica.ttc. Make sure you choose True-type font, you need two variants of these fonts “Normal” and “Bold”. You can browse and download more fonts from here

Now, connect your device with your PC and copy your fonts in a subdirectory of your SD card/MMC (e.g. /sdcard/newfont). Dismount your memory card and start TypeFresh in your device from applications scroll.

First thing you need to do with TypeFresh is to backup your existing Droid fonts. To backup press menu key and select “Backup Fonts”. Backup will create a copy of your fonts on a new folder named “Fonts”. This will help you in case you want to roll-back original Droid fonts.

Now, it’s a time for a real action, in TypeFresh, Tap on DroidSans.ttf you will get a prompt to select new font. Navigate to /sdcard/newfont and select the “Normal” variants actual ttf file. Repeat the same step with DroidSans-Bold.ttf by choosing the “Bold” variant. After selecting new fonts, press menu key and click on “Apply Fonts”, after few seconds TypeFresh will prompt you to restart your device. If it asks for “SuperUser” permissions Tap on “Yes”.

Voila, it’s just as easy as ABC. Your phone will restart with all new font of your choice.

Why you need to change your font ?
Better readability by applying fonts of your choice, people who have used iPhone or an iOS device for a long time will adjust themselves with Android very easily, changing font is an adventurous task :), you can install fonts based on the language of your choice (regional unicode subset), and so forth. Even, kids will like “Comic Sans” on Android and it looks pretty cool on Android. Also, few fonts are proved to be a good companion to people who are used to read e-Books on their device. Changing fonts will help them to personalize their experience. However, there is no way to install multiple fonts simultaneously on an Android device :(.

Try this, but it’s a dangerous process, you can “Brick” your phone if you know only ABC but not up to Z (Disclaimer)

Happy Reading…

(Attaching few screenshots after applying “Helvetica-Neue” on Xperia X10, a default iPhone 4.0 font)

TypeFresh Application on "rooted" device

Sample showing Wikipedia article about "Love", you will feel the difference in readability with "Helvetica-Neaue" font applied on Droid.

Filed under android font replacement typefresh astro file manager

0 notes &

All about Globalization

Globalization

Is a process to develop the application which supports multiple cultures or languages. Simplest definition is to store and retrieve the data the way it was entered in the database without any distortion and corruption in data. Main challenge rises when it comes to display and input the data in different languages.

Localization

Also is a part of the Globalization if it is a part to adapt and customize application for a given culture and locale. In localization process not only storing and retrieving data in a given culture is mandatory, but it is required to have all the menus and interface for the respective language, including Dates, Times, Currencies and other culture specific data. Specifically all the languages that you plan to support should be done using a single binary (.Net have a mechanism to do it with multiple localized assemblies) to encounter all the issues related to deployment and memory considerations. If you consider culture as a benchmark, fullowing points are mandatory to engage during development,
  • How to handle numbers, dates, times, currencies in different languages.
  • Layout changes while switching from base language to other language (text size and distortion raised by the switching)
  • Right to left and special characters.

Culture

Cullection of rules in the language, number formats currency symbuls, sort orders is individually called as “Culture”, each culture is defined in a unique culture ID. In .Net Framework Culture related classes are available under System.Globalization.CultureInfo class. CultureInfo class have two major properties called CurrentCulture (hulds information about data types like numbers and dates) and CurrentUICulture (huld information about localized resources which is used by resource manager). Globalization is more important for Web applications, cause the pages served are enhances based on the language set at server’s end, but not necessary those of the user accessing it from the browser.

Design considerations while developing applications

  • Data entered by user,
    The UI must support entry in desired language, Regional Settings provides the flexibility to choose the desired input method in various keyboard layouts either Phonetic or Devnagari and Inscript. There are several input methods available to deal with this.
  • Data displayed on the screen,

    Globalization, list the strings defined as a constant in the application and define it in a separate unit to translate upon a choice of a language. Also effective use of CultureInfo, ResourceManager, ResGen, Satellite Assemblies and System.Globalization helps to get desired results.

    Localization, support of a unicode characters and a support of a operating system for IME
  • Data handling in the application (Unicode only)

    • Make sure data entered in the application should handle the data properly all the culture centric information and strings when manipulated are passed through proper unicode functions and classes.
    • .Net itself is unicode supported, so it does not need explicit manipulation.
    • Application shall switch the CurrentCulture and CurrentUICulture accordingly language chosen by the user.
    • Culture centric user interface drawing menus, dialogs and message-boxes. Below are the possible workarounds to give a guarantee,

      • Configuration in web.config for <globalization culture=”X” and uiculture=”X”/>
      • Explicit culture specification in Page directive <%@ Page culture=”X” uiculture=”X” %>
      • Thread level culture information by using Thread.CurrentThread.CurrentCulture.
      • Localization of the string data using System.Encoding
      • Localizing number data int, long, float, currency etc.
      • Localizing date and time data by using DateTime.ToXXXString() functions
      • Custom resource files .resx files to store culture specific constant strings in manifest via satellite assemblies. Also ResourceReader and ResourceWriter classes can be used to do so.
      • Retrieving localized resources via ResourceManager.Getstring(“XXX”)
  • Data storage in the database, most mandatory need is database should support unicode or NVarChar datatype and premitive datatypes also support storage of unicode characters. And database design is also important to store culture specific details.

    • SQL Server supports unicode data so “you get what you store” is possible with SQLServer.  It gives a guarantee to display preserved data in the UI.
    • If application meeds support of multiple languages simaltaneously, database schema should be defined applying rules below:

      • If data is a master one, have a separate culumn for each field that needs to be localizes
      • If its a particular field that needs to get localized have a separate culumn in the same table for that language having a same primary or a candidate key
      • Normalize and divide multiple tables for the same localized field with the same primary key
      • Or, have a seperate tables for different languages to group and sort
    • Stored procedures / Functions / Triggers

      • Have a separate stored procedure which takes and initializes current language, to figure out the target table names
      • Application level parameters to store the current language to use in Data and Business layers, DAL constructor shall accept the parameter
Conclusion: Globalization is a concentrative job. It adds additional layer anyways in the application to support global presence. It is mandatory to have a workaround from the beginning of the construction of a software to make it future proof. For architects it also mandatory to consider different operating system for input and different browser to put and get data to the server.

Filed under architect visual studio 2008 .net blogger

1 note &

WebClient proxy downloader for SilverLight, XmlHttp/Ajax, Flash/Flex in ASP.Net

Intent of this post is to build a Solution that brings the modification of MSDN WebClient.BeginGetResponse() method example, also this little set of methods helps to create a proxy stub to overcome cross domain calls while using with SilverLight, Flash/Flex or with XmlHttpClient.

This downloads an gives output Asynchronously of everything publicly available on net. And solves many of the cross-domain issues.

We will use WebClient in System.Net to get contents of given Param in a query-string of a page and get the contents of the file as an output preserving same content-type. Example which is given on MSDN have limitations and somewhat not practical to juggle the data having it in bytes and then process it. There are several scenarios where we need a “proxy” stub,

  • Resize an image with this step, generate thumbnails in real-time while the download is on its way
  • Download a zip file and uncompress it and send it to StdOut
  • Use to resolve cross-domain issues while working with SilverLight, Flash/Flex & XmlHttpObject calls
  • Use this in ashx files or apply RegEx transformation at the level of HttpHandler
  • And many…

Add a new page to your ASP.Net (for SilverLight solutions this needs a new ASP.Net Application project in your solution then add a page) named “downloader.aspx”.

Page_Load will initialize WebClient object and uses ManualResetEvent class to bring Asynchronous communication to the remote server.

Page_Load event



string _requestUrl = string.Empty;
WebRequest wr;
WebResponse wrs;
ManualResetEvent me = null;
AutoResetEvent mew;
const int BUFFER_SIZE = 2048;
byte[] finalBt = new byte[BUFFER_SIZE];
byte[] output = new byte[0];
byte[] newfinalBt = new byte[BUFFER_SIZE];
IEnumerable<byte> outputEnum = new byte[0];

protected void Page_Load(object sender, EventArgs e)
{
_requestUrl = Request.Params["u"];
(wr = WebRequest.Create(_requestUrl)).Method="GET";

me = new ManualResetEvent(false);
IAsyncResult ar = (IAsyncResult)wr.BeginGetResponse(
new AsyncCallback(RespCallBack), null
);

//cursor will wait here until its Set() after
//final byte of file is recieved
me.WaitOne();

//copy content-type of "u"
Response.ContentType = wrs.ContentType;

//write bytes to Response
Response.BinaryWrite(outputEnum.ToArray<byte>());

//flush it without paper napkins :)
Response.Flush();

//on the callee end the file will be outputted based
//on the content-type
}



wr.BeginGetResponseStream() call will start to get the response of a _requestUrl, it also invokes RespCallBack() method asynchronously. me.WaitOne() will keep cursor on its point until it is Set().

Below is the code for RespCallBack()

RespCallBack method



void RespCallBack(IAsyncResult result)
{
//gets the WebResponse object
//ending the Response
wrs = wr.EndGetResponse(result);

//gets the initial stream from
//WebRequest
Stream s = wrs.GetResponseStream();

//this will trigger the read of actual
//bytes through ReadCallBack
s.BeginRead(finalBt,
0,
BUFFER_SIZE,
new AsyncCallback(ReadCallBack), s);

//added safety to still block the call
me.WaitOne();
//this is really necessary
s.Close();
}


RespCallBack() method queries and gets the response in Stream asynchronously, now we need to store this Stream in a bytes array, and asynchronously we need to Read the response in ReadCallBack() method.

ReadCallBack method



void ReadCallBack(IAsyncResult result)
{
Stream sr = (Stream)result.AsyncState;

//sr.EndRead() will ends the read and returns
//the count of bytes read asynchronously
int read = sr.EndRead(result);

if (read > 0)
{
//make sure only read bytes from finalBt buffer
//and only take first "read"ed elements from
//buffer
IEnumerable<byte> readBytes = finalBt.Take<byte>(read);
AppendBytes(readBytes.ToArray<byte>());
sr.BeginRead(finalBt,
0,
BUFFER_SIZE,
new AsyncCallback(ReadCallBack), sr);
}
else
{
//set initially triggered ManualResetEvent
me.Set();
}
}


And a utility function to append bytes in enumerator.

AppendBytes method



void AppendBytes(byte[] newarray)
{
//concat and append the newly arrived bytes asychronously
outputEnum = outputEnum.ToArray<byte>().Concat<byte>(newarray);
}



Now, run this page passing the “u” param as FQ file path on public server, as http://yourserver.com/download.aspx?u=http://www.otherserver.com/file.xml.

Also, here is a good example in C++ managed.

Filed under XmlHttp architect asp.net .net blogger

0 notes &

HTML5 & WebSockets

On December 21, 2009, W3C modified working draft of HTML5 the next version of HTML, having a nice new extension tags and DOM evolution. One of the great new cool feature is client side WebSockets object. Additionally with Capture API.

Evolution of XmlHttp object, Chrome has also released its support through an extension and will definitely help to create real-time rich applications through a web browser.

WebSockets interface is specifically designed to leverage the client side socket from where server or another browser API can connect to this instance and exchange data. A complete Asynchronous communication.

Overview WebSocket Interface


    1 interface IWebSocket
    2 {
    3     readonly string DOMURL;
    4
    5     //readystate
    6     const short CONNECTING = 0;
    7     const short OPEN = 1;
    8     const short CLOSED = 2;
    9
   10     //holds readyState variable
   11     readonly short readyState;
   12
   13     //length of buffered data
   14     readonly long bufferedAmount;
   15
   16     //raises events on conditions
   17     EventHandler onOpen;
   18     EventHandler onMessage;
   19     EventHandler onClose;
   20
   21     //method to send data to the connected client
   22     bool send(string data);
   23
   24     //method to close and terminates the connection
   25     void close();
   26 }

Compared to XmlHttpObject it gives a complete freedom to connect to any socket to the listener and get any data. Even it posts Unicode data, which means you have a possibility to serialize large file and send the data. bufferedAmount property will gives idea of the data which is being communicated to the listener.

There are many possibilities and solutions to deal with this object. Let’s wait jQuery people to release the API to encapsulate this object and utilize it.

To the infinitly and Web 3.0. Thanks to W3C.

Filed under XmlHttp w3c blogger

0 notes &

Marvelleous SQL Query

911 situation again to get the list of Databases who have more than 2 physical database files (.mdf + .ldf). Of course, very less documentation available on master.dbo.sysaltfiles. But, it’s really interesting table to get details of the physical files in the database instance.

It have following columns fileid (type of the file data file, a log file or an index file), groupid (primary or secondary), size in MB, maxsize (autogrow or static), growth (in percentage), status (online or offline), perf (reserved), dbid (database id), name (name of the file), filename (fully qualified physical location in the file system).


Just fire following query in master.


1 SELECT

2 COUNT(*) number_of_files_per_db,

3 DB_NAME(dbid) AS databasename

4 FROM

5 master.dbo.sysaltfiles

6 GROUP BY

7 DB_NAME(dbid)

8 HAVING

9 COUNT(*) > 1



Boom… !!

Now, my tech guys must be happy identifying their mistakes :)

Footnote: [apologies]

Filed under query sql server blogger

1 note &

Fluent Interfaces - Builder Pattern

I was unaware of the LINQ syntaxes’ that produce a long level of method chaining and in last calling a void() to produce a class out of it. Indeed, Fluent Interfaces are very useful example of the Builder Pattern which exposes the real world OOP. Code becomes self readable when you really consume the class.

In recent of my work in jQuery and LINQ I never found a chance to use it somewhere in my code, because I wanted it very simple. But, finally I can’t stop myself consuming this beauty to call a subsequent method or property.

It works on three basic thumb rules.

a. Method returns a same instance value - Self Copy
b. Self referential, to pass the last context to the call
c. Terminates the assignments with a void() method

Here we go with a simple or traditional implementation.


1 ///

2 /// IPerson traditional interface

3 ///

4 public interface IPerson

5 {

6 string Name { get;set;} //Name

7 string Brilliance { get;set;} //Brilliance

8 string Intelligence { get;set;} //Intelligence

9 string EnergyLevel { get;set;} //Energy Level

10 void Introduce(); // Introduction

11 }



And now we have the Fluent one.

1 ///

2 /// Fluent Interface IPersonCharacteristics

3 ///

4 public interface IPersonCharacteristics

5 {

6 //Name

7 IPersonCharacteristics SetName(string strName);

8

9 //Brilliance

10 IPersonCharacteristics SetBrilliance(string strAnswer);

11

12 //Intelligence

13 IPersonCharacteristics SetIntelligence(string strAnswer);

14

15 //Energy Level

16 IPersonCharacteristics SetEnergyLevel(string strAnswer);

17

18 //Method to introduce

19 string Introduce();



Its implementation,

1 public class MySelfImpl : IPersonCharacteristics

2 {

3 #region Private Variables

4

5 string _myName = “anonymous”;

6 string _isBrilliant = “not brilliant”;

7 string _isEnergetic = “not energetic”;

8 string _isIntelligent = “not funny”;

9

10 #endregion

11

12 #region IMySelf Members

13

14 public IPersonCharacteristics SetName(string strName)

15 {

16 this._myName = strName;

17 return this;

18 }

19

20 public IPersonCharacteristics SetBrilliance(string strAnswer)

21 {

22 this._isBrilliant = strAnswer;

23 return this;

24 }

25

26 public IPersonCharacteristics SetIntelligence(string strAnswer)

27 {

28 this._isIntelligent = strAnswer;

29 return this;

30 }

31

32 public IPersonCharacteristics SetEnergyLevel(string strAnswer)

33 {

34 this._isEnergetic = strAnswer;

35 return this;

36 }

37

38 public string Introduce()

39 {

40 return _myName +

41 ” is “ +

42 _isBrilliant +

43 ”, “ +

44 _isIntelligent +

45 ” and “ +

46 _isEnergetic + ”.”;

47 }

48

49 #endregion

50 }



And consumption

1 public class Consumer{

2

3 public string Intro()

4 {

5

6 IPersonCharacteristics myself = new MySelfImpl();

7

8 return myself.SetName(“Mital”)

9 .SetBrilliance(“is Brillian”)

10 .SetEnergyLevel(“is Energetic”)

11 .SetIntelligence(“is Intelligent”)

12 .Introduce();

13 }

14 }



Output too. :)

Mital is Brilliant, is Intelligent and is Energetic.

How beautiful ? Isn’t it ? Just try yourself, you will love to code it.

Filed under architect .net blogger

2 notes &

Cloud Computing - Monopoly Ends

Now gone are the days of n-Tier architecture. Everything is getting scattered with all new Web 2.0 3.0. Wikipedia defines cloud computing as “Internet-based development and use of computer technology.” To define it simply - Cross Domain Solutions. Where data does not come from the single data-source. It seems complex, but not exactly.




Simplest example is blog subscription and aggregation. When information comes from various scalable and virtual sources, which can be applied different transforms to the presentation layer. Consider Google Alerts which searches entire net for the news and serves you in the mail for the specific keyword.

In technical scenario it can lead to Software as a Service (e.g. Zoho Framework) or Platform As A Service (e.g. Amazon S3). Thanks to the evolution of the SOAP and Aggregated platforms which helped to achieve.

Cloud computing has many benefits, Commercially as well as Technically. Let’s say you need a e-commerce website with no content management system. And you are confident to stand on an international market. Just go and have eBay or Amazon shopping web-services and get up-to-date product inventory without calling eBay.com or Amazon.com. Its your exclusive presence.



Microsoft has also recently launched Azure Services Platform, collectively it becomes an Operating System with different scattered bits and pieces of the information. Its integrated tightly with Microsoft Platform by W3C specified protocols like SOAP and HTTP.

Next is Google Apps Engine. Mostly powered by Google WebToolkit which have high quality web and UI tools to aggregate data from its services. Recently, Gears has made it very easy to store this aggregated data to the local client machine.

Saleforce, mainly CRM application based on a Services as a Software (SaaS) platform enables on-demand application activation and installation with the least footprint.

FaceBook, share everything. Your blog, email, applications, links, photographs and tons of information.

Conclusion, future is Cloud a Web 3.0.

Filed under cloud computing scalability virtualization .net blogger

0 notes &

Indic languages made easy…

Gone are the days to depend on “US - English” locale.

Now its not a supremacy of just an English to express some thing in our own language.

Yes नमस्कार.

Previously almost the whole India and Indians were dependent on Bhasha Bharati and CDAC-Gist Shell. How thanks to UTF and Phonetic Indic langauges (if you write namaskar in english, it will convert it to नमस्कार) . Here are the cool new gadgets to make urself feel in home.

Standalone - ChitChat.

A small little utility which runs on Windows XP and greater Operating Systems. It not only supports to write in Phonetic Indic. But, you can ping-up your chat buddies directly from the populated list within with popular messaging applications like Yahoo! Messenger, MSN Messenger and GTalk.

Google Transliteration

This innovative online utility supports almost all the Indian languages with accurate phonetic conversion. This also have in my bookmark list.

QuillPad

Online version converts Indian as well as one more Devnagari language - Nepali. It have the tabbed environment to switch between languages and have support to save Text in HTML and Plain Text.

Expect more Indic blogs from me…

आपका दिन मंगलमय रहे

Filed under quillpad chitchat utf google transliteration hindi indic blogger