Category Archives: Programming

Wrapping lines in Sublime Text

I’m a big fan of Sublime Text 2 and it has become my default editor for all things web design. However, there was something about the default behavior of this app that really bugged me. Whenever I would browse a document I would always get frustrated by the way the application would horizontally scroll whenever a document had really long lines of code (like lengthy CSS declarations). I knew there had to be a way to force the code to wrap to a new line and disable this behavior. Well, after a long Google search, I found the answer, and thought I’d share with you how to enable Sublime Text word wrap. ACCESS THE USER SYNTAX SETTINGS Sublime has very extensive customization capabilities. Unfortunately, they’re not stored in a preferences dialog box, they’re accessed via coding. This is a cool feature for more advanced users, but I’d imagine it’s frustrating… Read the rest

Styling table cells in a particular column using CSS

While cleaning up and refactoring my code, i used the following CSS hack. This one made my code look more beautiful and readable,  To apply CSS style to every table cell (td) in a particular column, without applying the class/style attribute to every table cell in that column, and without JavaScript, we can use pseudo classes and /or sibling selectors:  For the first and last columns you can use the :first-child and :last-child pseudo class: td:FIRST-CHILD { /* Properties for first cell of every row */ } td:LAST-CHILD { /* Properties for last cell of every row */ } You can also To style specific table cells you can use and combine :first-child with the adjacent sibling selector+  td:first-child { /* Properties for first column of every row */ } td:first-child + td { /* Properties for second column of every row */ } td:first-child + td + td {… Read the rest

Web development and debugging tools

MVP Summit at Microsoft was an event with loads of information. Within the short span of three days, i learnt about several new tools that can make life of a developer easier. These tools can be used for development, debugging, testing and more processes. Here are some of the tools which i came across and learnt and found useful for a developer . 1. Fiddler : A free web debugging proxy for any browser, system or platform http://fiddler2.com/ 2. JSHint : A tool that helps to detect errors and potential problems in your JavaScript code.  http://www.jshint.com/ 3. JSComplexity : Software complexity analysis for Javascript projects. http://www.jscomplexity.org/complexity 4. ESPrima : A high performance, standard-compliant ECMAScript parser written in ECMAScript. http://esprima.org/ 5. Postman (Chrome extension) : A REST Client that stores history of sent requests and collections. Chrome Webstore : Postman 6. Poster (Firefox extension) : A developer tool for interacting with… Read the rest

Upcoming changes in ECMAScript 6

ECMAScript is a standard that scripting languages like JavaScript and ActionScript are based on. ECMAScript is owned by ECMA International which owns other number of standards like ECMAScript intern and JSON too.  At one of the sessions today during MVP Summit,  the speaker discussed about ECMAScript 6 and changes in programming constructs being added to it. ECMA 6 allows the following constructs: Let and Const let is the new var const is read only let let/const can replace var Semantics Block scoped No use before declaration Const cant be reassigned Let Statement const Statement New collections Set Like an array, but no duplicates and O(1) add/remove/has Map Map any object or primitive to any other object or primitive in O(1) complexity http://tc39wiki.calculist.org/es6/map-set/ WeakMap Can only map objects to other objects Holds keys and objects weekly http://tc39wiki.calculist.org/es6/weak-map/ Internationalization in ECMA 6 Huge Unicode data tables Culture sensitive string sorting, number/date formatting… Read the rest

Debugging in Smarty template

While trying to debug a variable in PHP i love the var_dump() method. Off course i have debugger tools like xDebug enabled in my IDE i love using var_dumps. One of the thing i like about var_dump is it gives the complete structure of an object at that instance. Using MVC model for PHP usually ties you up with a framework and a choice of view. For Zend it is smarty which i use, and smarty is not straight forward to debug like PHP. After some research i found out various ways to use var_dump. Here are they: Method 1: {php} $var = $this->get_template_vars('var'); var_dump($var); {/php} Using php tags is not good practice and ideally they should be disabled for security reasons anyway Method 2: {$var|@print_r} It only outputs the values and not the keynames, and there are no spaces between the values, so it’s not ideal for debugging. Method… Read the rest

Reverse Commit Code changes in SVN

SVN is one of the great tools when it comes to controlling the version of your code. Code can be committed at instances to the repositories and each change is saved as a change set. Sometimes while working with SVN, there comes a need for reversing a change. Rolling out a committed change set is not straight forward in SVN and may require some trick. This can be really helpful in case when you are working on a repository copy like /trunk and you find the changes made by you in last revision or changeset (Say Changeset #783) are wrong or they should not have been committed. Now one of the solution in such scenarios can be making changes again to your codebase which revert the changes you just committed. That works, and i have done it sometimes. But, what happens if you have multiple files and many code changes… Read the rest

Centre a DIV Block using CSS Styling

Working on some templates these days, one of the most painful thing i found was styling the div containers. While styling the DIV containers, one of the roadblock was to centre align a DIV. At first i thought its as simple as adding text-align styling to center for that div as below: #divToBeAligned { text-align: center ; } However, the rule centres the text inside the box, instead of the block itself. This was causing the block to stay at the same position but internal contents to be aligned center, which is not as I desired i.e. centre the entire block but leave the internal contents formatted as it was before. To center the block in CSS i had to do the following: 1. Specify a width for the DIV block. 2. Set both its left and right margins to auto. When both margins are set to auto, web browsers… Read the rest

Redirect WordPress urls after changing WordPress Permalink Settings

Recently i changed my blog’s permalinks. This means that my blog post urls would be representing a different structure now. Earlier they were in a format http://windowsvj.com/wpblog/2009/12/windowsvj-xclusive-release-windows-7-tips-tricks-ebook/. You may notice blog post month and year present in the URL. I changed the permalink settings to http://windowsvj.com/wpblog/windowsvj-xclusive-release-windows-7-tips-tricks-ebook/ by selecting an option of setting permalinks as blog post name only. When i started this blog in late 2009 I originally setup my WordPress site to use the “Month and name” permalink option so that my post urls would include the date they were posted. However it is later i realized the “Post name” option to be better as it is short. Post publish date is anyways published in the post content itself and don’t need tobe present in the URL. After I changed the settings all of the earlier blog post URLs started showing a 404. This affected me a lot in… Read the rest

Exclamation mark before a function in Javascript

While digging into bootstrap JavaScript plugin files i stumbled across a piece of code in JavaScript where exclamation mark was used before a function call. !function () {}(); This syntax known as Negated closure is something which i encountered for the first time. Lets see more details about this: Syntax for a function definition in Javascript is : function foo() {} You may note that there’s no semicolon after the curly braces end because this is a statement and you need a separate function call or invocation of foo() to actually run the function. Unlike above code which is a statement, !function foo() {} is an expression, but that still doesn’t make a function call, but we can use !function foo() {}() to do the same, as () has higher precedence than !. So, as we know exclamation mark ! returns Boolean, but it also converts the function declaration statement… Read the rest

Understanding JavaScript Closures

Javascript closures are considered an advanced topic in Javascript and understanding closures is essential to master Javascript. After reading this article, app developers will have an understanding of the following: What are Javascript closures How are Closures useful Why to use Closures How to use Closures Javscript Closure Examples JavaScript is a functional language unlike imperative languages like C/C++/Java. Using Javascript it is possible to assign a function to a var, pass one as an argument to another function, and return a function with the return keyword. Even a function can be declared inside another function, with all the scoping rules. So if there is a function within another function, the inner function has access to variables of the outer function. One of the situation where closures play a role is when a function definition is nested within a parent function that returns the nested function object as the value… Read the rest
http://www.windowsvj.com/outlet