Posts

Showing posts with the label Web Programming

Cross-browser radio buttons and checkboxes using only CSS3

Spanish version / Versión en Español Each browser gives input elements the look and feel it desires, and it cannot be customized directly on every browser. For radio buttons and checkboxes, we can get around this issue by using only CSS3; no need to bring in extra dependencies. The trick is to use CSS to hide the native input element, and then add an empty span element as the first child of the input's label. Having a label associated to an input allows us to use the CSS3 + syntax to select those specific cases, and then we can select the child empty span to generate our custom look for the input element. So, if we wanted to customize our radio buttons, first, in HTML, we need to add the dummy span and use labels. For example: <!doctype html> <html> <div> <input type="radio" id="radio01" name="radio" /> <label for="radio01"><span></span>Radio Button 1</label> </div> ...

Serverless cloud computing: Introduction

Spanish version / Versión en Español Lately, there's been a buzz in the IT world about "Serverless" technologies. The term can be a bit misleading, because there is still a server machine doing server-side processing; the key difference is that when we talk about a "serverless" environment, the whole server infrastructure is managed by a third party. In a serverless environment, a developer only needs to provide his custom server-side code, and the platform will take care of running it when suitable. This takes the concept of cloud computing taking things off developer's hands a bit further. Let's recall those different kinds of cloud offerings and try to fit serverless there: IaaS : Infastructure as a Service. The cloud vendor offers an interface for the users to manage their infrastructure: servers, databases, and networks, using a special interface. That way, the user can allocate and consume computational resources using a pay-as-you-go mo...

Web API (.NET): POSTing an object in XML format to an ApiController

Spanish version / Versión en Español Problem : In a .NET Web API app, inside a class which extends ApiController, it is desirable to receive an object in both XML and JSON format, in the most transparent form possible. Receiving the whole XML as a string, or using attributes (.NET's annotations) in the class to serialize are not acceptable solutions. What tends to happen is that the object is always set to null when calling the method. There are various possible solutions, among them adding an "=" at the beginning of the POST message body. But doing so is not optimal, because it's a .NET specific convention and would limit us (if a partner used an HTTP client made with C++ running on Linux, we'd be in trouble). We cannot receive a string directly because that would prevent us from receiving the object in JSON format. Solution : Receive the object with the attribute (.NET annotation) [FromBody], and enable the xml serialization inside our controller. A...

Symfony 2 ignoring changes in parameters.yml

Spanish version / Versión en Español Say we want to change the database host because we changed our hosting service provider. We happily edit parameters.yml and upload it back up to the server, but we still get the "Connection timed out" error. The solution is clearing the cache, but without direct access to the server, doing that via FTP might take ages. In my case, a simpler solution was to delete only the app/cache/prod/appProdProjectContainer.php file, which seems to be where Symfony 2 caches its parameters. I'd like to personally thank the debug_print_backtrace() function. If you use it, make sure to do so with the DEBUG_BACKTRACE_IGNORE_ARGS flag, or you will get an illegible chunk of text.

Introduction to Web Programming

Image
Spanish version / Versión en Español General Concepts When first facing this new development environment, it's easy to become confused due to the enormous variety of "technologies": HTML, CSS, Javascript, JQuery, PHP, MySQL, ASP.NET, Bootstrap, SQL Server, Ruby on Rails and many more. The answer to this problem is that every web-related technology can be classified in a certain category. All technologies in that category are essentially equivalent, and deciding which one to use is no more than an administrative decision (though, as usual, some technologies are better suited than others for specific problems or scenarios). Once we know which category a technology belongs to, we already understand 60% of all there is to know about it. The remainder can be completed with a good reference for the API and syntax. General structure of a web application Every web app does essentially the same, no matter which technologies it uses: Provide a qu...