Double.Parse and Decimal.Parse with pointing symbols

July 5th, 2011 by Juan 1 comment »

One problem I encounter on dotnet equally in Visual Basic or C#, is when I have to parse a decimal or a double from a string. When parsing a double or a decimal, we find a mistake because in math, punctuation symbol for the decimal point, so to make a Double.Parse(number) or Decimal.Parse(number), which makes is to ignore the point and therefore take the decimal part as if it were the whole. For this does not happen, we must indicate that the number system used is the mathematician, who does not vary with culture. An example.

string number = "15.3";
double doNumber;
decimal deNumber;

doNumber = double.Parse(number);
deNumber = decimal.Parse(number);

/*
Values:
doNumber = 153
deNumber = 153
*/

doNumber = double.Parse(number, CultureInfo.InvariantCulture);
deNumber = decimal.Parse(number, CultureInfo.InvariantCulture);

/*
Values:
doNumber = 15.3
deNumber = 15.3
*/
Dim number As String = "15.3";
Dim doNumber As Double;
Dim deNumber As Decimal;

doNumber = double.Parse(number);
deNumber = decimal.Parse(number);

'Values:
'doNumber = 153
'deNumber = 153

doNumber = double.Parse(number, CultureInfo.InvariantCulture);
deNumber = decimal.Parse(number, CultureInfo.InvariantCulture);

'Values:
'doNumber = 15.3
'deNumber = 15.3

CultureInfo is a class that provides information on cultures and in particular the property InvariantCulture or CultureInfo.InvariantCulture, is the provider of culture information that does not vary by localization, see the mathematical punctuation symbols. The CultureInfo class is in the System.Globalization namespace, leaving the path as: System.Globalization.CultureInfo.InvariantCulture.

Via: Double.Parse y Decimal.Parse con símbolos de putuación

Hosting SVN with XP-Dev

May 30th, 2011 by Juan 1 comment »

Took time searching for a formula to organize the sources of my projects. Each day that passes, I have more and more projects and I find it difficult to organize, that, without taking into account the possible loss of data or the problem of changing equipment. I had a long time that in addition to hosting web host could create SVN repositories, the problem was that this had to enter the console, create the repository and could do little more than use the SVN repository. Some projects I decided that having an idea they were opensource, could take advantage of the service offered by Google Code, but of course, other projects are personal projects I'm developing for other companies and Google Code, only lets you use opensource projects.

Some research online, I found XP-Dev, a hosting service only offers hosting for SVN, GIT and Mercurial. The service offers a free version for which we use for 2 projects private and public all you want, with a maximum disk space 200 MB. The free service limits us some access features such as SSL, in addition, other features are not missing anything, because it has a complete system with which to manage projects, manage tasks, manage bugs, wikis, etc. all easily configurable. From 4 € per month, $ 5, we have access to basic account, which will give us access to full service as SSL access, you can create as many projects as you like opensource or private.

Maybe someone will think that the best and simplest is to fit a SVN server at home, but the reality is that sometimes it's more comfortable, use a cloud service and not worry about losing the sources of our projects or access to them whenever we want and it is best XP-Dev.

You can find a price list and a list of features on the website of XP-Dev.

Via: Hosting SVN con XP-Dev

RockMelt the social networks browser based on Chrome

March 14th, 2011 by Juan 1 comment »

RockMeltReading the other day @manoloruiz, I discovered a new social browser called RockMelt, based on Google ChromeRockMelt is a browser based on Google Chrome, looking very similar to Google Chrome, except for some small details. The thing that strikes me is that nothing RockMelt start, a window, similar to the connection that makes Google Chrome with GMail, but in this case access to Facebook, to import our Facebook account. Once we found it to login on Facebook, you will see a sidebar with our contacts from facebook, can chat with them. On the other side we find a bar with the applications installed by default Facebook and Twitter, but for now you can also Youtube, where you can see updates of our social networks and add content directly from this bar. Finally stands next tothe address bar, the share button, which will allow us to share the current page in any of our social networks.

The truth is that this browser is very good looking and I think it will become my secondary browser and work as well at a glance I can see the twitter. It looks pretty good, the only problem is still not in Spanish translation, but everything will come.

Here some screenshots browser.

RockMelt download page

RockMelt Facebook access

RockMelt home page

Via: RockMelt el navegador social basado en Chrome


When GMail or GTalk for Android doesn’t works

October 23rd, 2010 by Juan 8 comments »

A few days ago, stopped running the native applications on GMail and GTalk for Android that come installed by default in Android. Others may not use them, but for me the fact that GMail and GTalk not work was something that killed inside me. GMail for example I download messages stopped and gave a lot to update, no new messages and download directly, GTalk I opened, I carried the screen "loading" and briefly disappeared, ie, GTalk doesn't open. As a workaround I set the mail from HTC and install the Fring, but mail from HTC but much better than GMail, I prefer the lightness and speed of GMail, and Fring, directly I do not like, besides that the time to have it open and be in the home is closed I just do not know why.

Seeing that this was something they were doing a change from Google, I decided to fix it. The solution has been rather more simple than I imagined, as always, a cleaning program is best, and therefore we're going to Settings> Applications> Manage Applications and once here, we should look for applications that call "Gmail", "Gmail Storage", "Google Talk" and "Saving Google Talk". In each of the chips must erase the system data and to do so by pressing the "Clear" and ready, but that if, in the 2, program and storage and if you're like me you not function or GMail or GTalk They have to do it in 4. Once done, we can open new applications and GMail will receive mailings, but will have to sync and if you take a lot of time, but the GTalk works on the first run.

I hope you have served this small fix GMail for Android or GTalk for Android when not working.

Via: Cuando GMail o GTalk para Android no funcionan

Released version 0.2 of puntoengine

October 3rd, 2010 by Juan 1 comment »

I posted the new version of Punto Engine PHP, or PEP in the version 0.2. This version brings significant improvements over the previous version, by managing the system better able to make templates for dynamic pages much easier and faster. Among the improvements are:

  • Added change log file
  • Added virtual path (accesible in the browser) at the kernel
  • Added servlet url in a class attribute
  • Added detailed exception trace where are configured in web.xml
  • Added in web.xml a config section with debug mode
  • Added debug atribute in servlet class to realice the traces if the project are in debug mode
  • Added base redirect same a aspnet. If redirect url starts with "~/", the url take the base project url
  • Added masterpage functionality with secction page and dinamic code same include and php code
  • Added functionality when a path has ~/ chageit for virtual path same a dotnet with runat server
  • Updated the error page message that are reference at IDCS Server and change its for "Punto Engine Server"
  • Updated the HomeController class to a TestController with many examples of templates use with masterpage
  • Fixed the some exception pages showed when have a multiple errors. Now stops the process when the error throwed
  • Delete temporaly the PepAdminController from web.xml to can't access it

The improvements in this release are quite substantial and allows for more fluid pages. For those who want to download it can do so by logging into the project puntoengine website.

Via: Publicada la versión 0.2 de puntoengine

Curious char methods, IsLetter and IsDigit

September 30th, 2010 by Juan 6 comments »

The other day, we were about my boss and I make a control on a text field of a web application. The idea was that this area could include only text or numbers, but in no case should be possible to include strange characters. Let us be honest and if we needed to use this in languages where the framework was not prepared to differentiate what kind of character he was, just creating an array or dictionary, and comparing the characters or by using regular expressions. Of course, since the leap to Microsoft technology (in this case Visual Basic. Net) I decided to find some class or method to do just what I wanted, and found.

DotNet exists a class Char, which is the method Char.IsLetterOrDigit(boolean) which indicates a char or character, and this will return true or false if a number or letter and false if not. Ride a function to go character by character text field is alphanumeric checking whether or not the idea of erasing non-alphanumeric characters. Once mounted the role, I try a few times and everything works great. When we're going to have to get into production ... surprise, the last test failed (but impossible), we slipped the finger and put a "1", put a "º". When we investigate (ha try boars), we realize that this function requires that the characters "º" and "ª" are alphanumeric, we are lyrics, I suppose the "o" and "a".

We control it and go, but if someone is in the same situation and knows that if some function to work properly comment on it. And if anyone looking for internet is blocked and is found in this post, you can breathe easy, because there is a malfunction, it does not work quite right. Yes, I know that for some "º" and "ª" are letters, but they are really special characters.

Via: Char curiosidad de IsLetter e IsDigit

OmmWriter, a Zen text edit

September 28th, 2010 by Juan 2 comments »

Logo de OmmWriter

I recently discovered a new text editor for Mac called OmmWriter, at first seemed a bit simple and rare, since it is a very zen background (simple as they come) with a little music relaxing. I thought it was a notebook, but more pulling to roll zen. When I turn off the television, music and started writing, I discovered that is true of what supposedly is the editor, and its aim is to concentrate all attention on what is being written.

When you remove all distractions, where the only sound you hear is the music zen and keystrokes, which besides their own, OmmWriter has a special little sounds for the beats, gives a relaxing feel very good, plus it has an entire screen with a very relaxing background where you write and the only thing that appears is the text you type, no menus or anything that may distract. There are no words to explain how to write from the text editor, you just have to try.

Among other options such as opening and saving documents (logically had to come), we can change the font and size, as well as keyboard sounds, background zen music and background among several preset options, always including a very soothing tone, like music of nature with animal sounds, rivers, sea, etc.

Only one problem I see with this app is that when you move the mouse to select menu options and pass the mouse over an option, in fact we need a title indicates that it is each option, except that I think that the purpose of this app fulfills to perfection.

Finally say that whoever is lucky enough to have a Mac and want to try this great text editor for Mac OS X, you can do from the homepage of the project OmmWriter.

Captura OmmWriter

Via: OmmWriter, el editor de textos Zen

Virtual namespaces with javascript

September 27th, 2010 by Juan 2 comments »

In most programming languages relatively mature and powerful, there is what we call a namespace. The namespace is a container name where we hold classes, functions and variables that can be repeated with the same name in other namespaces without involving an error. A example of what the real utility of organizing or namespaces is in the graphics libraries of programming languages, since in these libraries a very common element the Window class is usually referred to a window but may be in GTK, QT,. Net, Windows API, etc. (This is not quite correct since GTK would GtkWindow but for the example). Javascript as a language and more to mature over the years and relatively standardized by modern browsers, despite being a multiparadigm programming language, as do PHP, also has namespaces, but due to weakness of these namespaces variables are more virtual than real.

And understanding that it is serving a namespace to declare it in javascript, what we should do is use arrays to generate. Thanks to the weakness and dynamism of the variables in javascript, we can assign to a variable array of positions by name and access these through a punctuation mark "." and not their common key array ["key"], so here comes the trick. Basically what we do by declaring a namespace in javascript is assigned to a variable array with the positions of the namespace and then and within these positions, log in as if from .Net or Java in question. With an example is simpler.

var Indalcasa = { Tools : {} };
 
Indalcasa.Tools.MyClass = function() {
  this.variable = "value";
 
  this.myMethod = function(parameters) {
    return this.variable + " " + parameters;
  }
};
 
var iClass = new Indalcasa.Tools.MyClass();
iClass.variable = "new value";
alert(iClass.myMethod("test"));

The above example shows an alert window with a message such that "new value test", as we have instantiated the namespace class, we changed the value to the class attribute and the class method, concatenate the value of class attribute to the parameters that we have passed. This is a small and simple example of what can be done with javascript, namespaces and classes.

Via: Namespaces o espacios de nombre virtuales en javascript

Released version 0.1.1 of puntoengine

September 26th, 2010 by Juan No comments »

Yesterday I posted the version 0.1.1 of puntoengine. Punto Engine PHP or puntoengine or shortened PEP, is an alpha-phase PHP MVC framework type Model View Controller. This framework bases its functionality in a mixture of different web frameworks such as ASP.Net, Java Servlets and PHP in and old framework called RLM Engine. Today, despite being in a very green stage of development, but it is fully operational and can build websites with a servlets as you would a website in JavaVersion 0.1.1 in revision 7 puntoengine is the last released version 0.1.1 of puntoengine but with full documentation of the code, making it easier for anyone who wants to see and study the code and its operation, make it easier to follow. For version 0.2 of puntoengine is expected to create an administrator, currently under development to manage including servlets installed and preparation for future plugins such as the CMS system.

This is a long-term and very ambitious to go far and I hope to use it to build several websites that I have in mind. According to a calculation made according to the COCOMO system, currently the project with almost 1500 lines of code, would have a private cost of 6,000 €. For those who want to take a look and even collaborate with the development, documentation or providing issues, you can do on the web puntoengine project.

Via: Publicada la version 0.1.1 de puntoengine

Valid Autocomplete=”off” for XHTML

September 12th, 2010 by Juan 2 comments »

When writing a text in a text input type (<input type="text" />) we find that generally the browser is going to autocomplete what you are writing at that time with text that we have already written earlier, recalling for input called "name" the name or names you have entered.

The practice of auto is very helpful whenever we have repetitive forms such as registration forms are similarly always call and they always ask the same data, avoid rewrite all our data over and over again.

There are cases where you might not want that the browser will autocomplete the text, may be the case that we have an online store that paying by credit card and we do not want that credit card we autocomplete. To avoid this, there is an attribute that is used by the vast majority of browsers is the attribute autocomplete="on|off", if the value is cleared off, tells the browser not autocomplete the field.

Although in many cases it is good practice to use the autocomplete attribute, the W3C has recognized this attribute as an attribute of the input tag with which to try to validate and meet with the autocomplete attribute, we give a validation error. To resolve the validation error that will be using javascript to add this attribute, the functionality is still there, but we will not have validation issues.

The only thing we do is add the following code at the bottom of the page, or at least, just after declaring the input

<script type="text/javascript">
    //<![CDATA[
    var inputElement = document.getElementById("inputId")
    inputElement.setAttribute("autocomplete", "off");
    //]]>
  </script>

In this way we will ensure that when entering text in a input autocomplete not by the browser and if we can do for you autocomplete javascript.

A good and beautiful example of autocomplete fields is the use for muchoviaje in the areas of origin and destination.

Via: Autocomplete=”off” valido para XHTML