CSS tricks

Web design
Here are a few CSS tricks very useful for Front End programmers: Convert an element from inline to block and viceversa Some tags are thought to be inline and some others to act as a block. That is why some tags have some default style like margins or paddings and also, some of them will not act as others when you apply some style. For example, an anchor (inline tag) with a with=200px; will not use that space because its an inline element, but you can change its behavior with the property display:block, display:inline, display:inline-block, display:table, etc. With display:inline-block; it will maintain most of its inline behaviour but use the width or height you place, unfortunately this value has some problems in IE, so I recommend you to focus on…
Read More

Selecting odd and even rows in a table using CSS3

Web design
Fast trick to style a table using CSS3 selectors to set the odd and even rows style: [sourcecode language="css" wraplines="false"] table > tr:nth-child(even) {background: #ccc;} table > tr:nth-child(odd) {background: #fff;} [/sourcecode] So instead of having this: text more and more texttext more and more textmore and more text more and more texttext more and more textmore and more text more and more texttext more and more textmore and more text more and more texttext more and more textmore and more text more and more texttext more and more textmore and more text more and more texttext more and more textmore and more text more and more texttext more and more textmore and more We will have this: text more and more texttext more and more textmore and more text more…
Read More

Add new post Types and Fields to our wordpress blog

Web programming
Hi there! Have you ever thought to have another field in the wordpress post edit page, for example, an image field to set a thumbnail for that post, a price field to set the price of the houses you are showing or, who knows, just a subtitle field to place a text down the post title? Whatever you have imagined now is possible in wordpress 3.0+ using a few plugins and... coding a bit. Let's start by downloading the needed plugins: More Types More Taxonomies More Fields All of them are independent but can work together very well. I don't want this post to be so long so, I'm gonna let you install those plugins and check them a bit until you realize how they work. More Fields lets you,…
Read More

Visual Studio Intellisense not working

Other
This has happened to me a few times and, when it happens, I just don't know what to check to see if I've changed any configuration or what. So I decided to write here a list of possible solutions: 1 - Make your project an application Sometimes when you use the quick access to a project instead of opening it as an application it is opened as a "folder project". Then classes are not being compiled and Intellisense doesn't work. Solution: Open it using the .sln file or right click on the project main folder and select "Make it an application". 2 - Error on compilation Similar to the last one, sometimes an error doen't let VS to compile your class, try to fix that compiling error and recompile. That…
Read More

Using preprocessor directives in C#.Net

Web programming
We can use conditional directives in C# that will be executed at the pre-compiler to allow us determine which code will be compiled or not: #if and #endif. To sue them, we need to define a symbol. What do you mean with a symbol? A symbol is like a variable that we will use for this purpose. You can declare one of those using #define or #undef and use it later to add some pre-compiler conditional directives. Let's see an example: [sourcecode language="csharp" wraplines="false"] #define DEVELOPMENT_MODE #undef PRODUCTION_MODE public class OleDB { public static OleDbDataReader ExecuteReader(string cmdText){ #if PRODUCTION_MODE srcDB = "c:\\server\\databases\\bd1.mdb"; #else srcDB = "c:\\bd1.mdb"; #endif } } [/sourcecode] As a mere example, see how we could use a pre-compiler directive to set the database source when we are…
Read More

Connecting OleDB using ADO.Net (C#)

Web programming
Connecting OleDB in .Net is no different than connecting other database engines, you only need to use a Connection object, a Command object and then make the operations you were planning to do. First of all, you should import the libraries we need for connecting OleDB, so if for connecting to SQL Server you use System.Data.SQLServer, now you will use System.Data.OleDB: [sourcecode language="csharp" wraplines="false"] using System.Data.OleDb; [/sourcecode] Now we'll need a ConnectionString in which the connection details will be set, and which has a different structure for OleDB than for SQL Server. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DataBaseFileSource;User Id=Admin;Password='' And here we go: [sourcecode language="csharp" wraplines="false"] public static string srcDB = "c:\\development\databases\bd1.mdb"; public static OleDbDataReader ExecuteReader(string cmdText){ OleDbConnection conex = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + srcDB + ";User Id=Admin;Password=''"); conex.Open(); } [/sourcecode] As you can…
Read More

Inheritance in C#.Net

Web programming
Inheritance is the posibility of making a class act as a child of another and inherite its parent methods and properties. So if you have a class called building with the property address and you make another class called flat, you can make flat a child of building and it will inherit the property address without having to declare it. To make flat inherit building you only need to do something like this: [sourcecode language="csharp" wraplines="false"] public class Flat : myClasses.Building { // Here goes the class code } [/sourcecode] Assuming that the class building is inside the namespace MyClasses. But flat will not inherit everything building has, the private methods or properties will not be inherited. Does this means I have to declare everything as public if I want…
Read More

Ada Lovelace, first programmer in History

Computing History
This is a translation from my original post in spanish. I hope you like it! If we have a look into a tech high school it will be most likely hard for us to find a girl around there, and if we try to have a look at the computing class we may find none at all. Be woman and skilled in computers is not very common, and despite there are some, computer world is clearly dominated by men. But, what would all those computer guys say if I said that the first programmer in history was actually a woman? Augusta Ada Byron King was born in 1815 in England, belonging to the aristocracy she had access to private teachers and good education, she focused her studies in maths and…
Read More

Making your web semantic

Web standards
One of the most important issues that HTML5 brings to us is the possibility of placing semantic content in our code, this means that we can say robots or crawlers what is about the content inside some tag. For example, the tags <sidebar>, <header>, <footer> or <nav> will act as a div that also is explaining which type of content you are going to find inside them. That's semantic. But you do not need to use those new tags in HTML5 for having a semantic page, HTML4 and XHTML are also semantic, though not that much, if you use standards correctly. How to use standards correctly to have a semantic web? Well, we only need to use the tags we normally use for what they were thought. This means, if…
Read More

The real privacy your photos have in Facebook

Web security
I realized the other day that Facebook doesn't give you many privacy with your images, and I wondered about something, if anyone who knows the source of a picture can have a look at it despite I want to place it as private and share it only with some friends, what if I try to delete it? Well, first of all, first example, this is going to be a private photo I've uploaded to Facebook, if you can see it, then its not that private... Now, lets try it with a photo that I have uploaded, yes, but now I've deleted it and shouldnt be in the Facebook image server: And finally, both of them, a photo I uploaded and its private, then Ive deleted it, can you see it?…
Read More

Hacking a site’s photo directory using DOM or jQuery

Web programming, Web security
I watched the film about Facebook the other day, yes I coudn't resist, and I thought it has some interesting moments. At the beginning, Marck "hacks" some Harvard websites which contain profile photos from the students. How did he made this? Well I didnt saw the code or remember it from the film but I am going to suppose what he did and how. Lots of webpages store they images in the same directory, or at least place all the same type images together, this means all the profile images were in the same source. Also, due to programming issues, those images tend to have a name which is a numeric code, maybe the student id, or maybe the number of the photo when that photo was uploaded. This means…
Read More

JQuery’s $(document).ready() method

Web programming
JQuery has a method that can help you when developing a website called "document.ready", in JQuery language: "$(document).ready()". This method let's you start doing things in your page using javascript once the document is ready but without having to wait for all the images to load. I mean, if you don't use JQuery and you want to do something like an effect or whatever when the page loads, you will for sure use the window.onload to start it, but if you have used this option in the past you will notice that window.onload needs the entirely page to be loaded, and sometimes due to images or something that is being requested to another server this takes some time making the effect less impressive or even regrettable. So JQuery gives you…
Read More

Third-party cookies

Web security
I am sure you have read something about third party cookies before, mainly because if you check your browser options you have an option to block those type of cookies. But first of all, let's start from the beginning: What is a Cookie? A cookie is something to eat made with some flour and water and.... wait, that's not what I was talking about. On the Internet, a cookie is a text file used to save some data about you in your PC by a webpage. Why would a webpage want to do that? Normally to identify you or to remember some options you chosed and use them in the future. In fact, lots of pages use cookies to identify you as a unique user and that is why without…
Read More

Accesing a page element using JavaScript

Web standards
Lately I feel like making a master about selectors but I promise this is only a coincidence. When working with javascript we need to select the element we want to use and we have many ways to do so, I was wondering which one is the better to use so I wondered and found an answer to this issue. Let's see the alternatives: [sourcecode language="js" wraplines="false"] alert(document.forms[0].elements[0].value); alert(document.forms["myForm"].elements["myInputText"].value); alert(document.myForm.myInputText.value); alert(document.getElementById('myInputText').value); [/sourcecode] The first option just moves across the document objects and knowing the position let us get the object we want with its value or other properties. This option is really risky since in case you change something in the page and add more forms or elements before the one selected it will not be at the same position anymore…
Read More

Introduction to jQuery

Web programming
To use jQuery we need to get the library from one of those sites hosting it, for example the JQuery project page, or use the Google Libraries API. We can call the online versions and save server resources or better have our own version to make sure it never goes off. jQuery library has methods, selectors and events to interact with the page objects and let you make some very nice effects, change or add styles and some other issues with no effort at all. I am going to have a look at it with the basics to get initiated into this amazing library. Selectors First of all, to interact with the page objects we need to select them, so that we can know with which object we are working.…
Read More