March 2016

PHP regex – match any digit

Php regex can use digit shorthand (\d) to match a digit (0-9). To match any non digit character, regex shorthand \D (uppercase backslash D) can read more

How to detach Chrome developer tools window

Chrome developer tools is very useful in debugging Javascript and CSS in Chrome browser. Sometimes it is useful to detach the developer tools window. Here read more

WordPress – query to dump all posts with featured image

Sometimes we need to dump all post with featured images along with post title and image title. Here is mysql query which lists all posts read more

Chrome – view javascript errors

It is useful to view Javascript errors in Chrome for debugging purpose. Chrome developer tools console can be used to view Javascript errors as shown read more

Apache – list loaded modules on Ubuntu

To list loaded module in Apache on Ubuntu linux, command line tool apachectl can be used. Here is an example. $ apachectl -M Loaded Modules: read more

PHP regex – match word character (letter, number or underscore)

Php regex can use word shorthand \w (lowercase backslash w) to match a word character. It matches with any of the following: letters (a-z,A-Z) Numbers read more

Create circle and oval in CSS

CSS circle and oval can be created using border-radius on a div. For circle the horizontal and vertical radius of each corner is same, whereas read more

How to create CSS triangles or arrow heads

CSS triangles (arrow heads) in various directions (up, down, left, right) can be created using a combination of thick CSS borders (visible and transparent) on read more

CSS automatic table row numbering

CSS3 counters can be used to number table rows automatically. We need to maintain a counter per row and display it using ::before on first read more

CSS automatic nested numbering for headings

CSS counters are variables maintained by CSS whose values may be incremented by CSS rules to track how many times they are used. Here is read more

CSS counters – automatic numbering before h2

CSS counters are variables maintained by CSS whose values may be incremented by CSS rules to track how many times they are used. Here is read more

Linux/Unix history with date and time

It is useful to run history command with date and time along with each command. Here are instructions on how to do it on Linux/Unix. read more

AngularJS ng-model

The ngModel directive binds an input, select, textarea to a property on the scope using NgModelController. One can also bind same property on multiple input read more

jQuery – read and modify iframe content

Sometime we need to read and modify same domain iframe content using jQuery. Here is code snippet which will modify the content of an iframe.

Javascript – get computed style of an element

To get computed style of an element the following approaches can be taken: Vanilla javascript: window.getComputedStyle(element) jQuery: .css(propName) Example – computed style using Javascript Example read more

CSS universal selector

The universal selector (*), matches the name of any element type. It matches any single element in the document tree. Some ways it can be read more

CSS animation shorthand property

CSS animation shorthand property is a comma-separated list of animation definitions, each of which combines animation properties into a single component value. Note that individual read more

CSS animation-play-state

CSS animation-play-state property defines whether the animation is running or paused. When a paused animation is resumed, it restarts from the current value instead of read more

CSS animation-fill-mode

CSS animation-fill-mode property defines what values are applied by the animation outside its execution time window. These two periods are considered outside animation: During delay read more

CSS animation-direction

CSS animation-animation-direction property defines whether or not the animation should play in reverse on some or all cycles. When an animation is played in reverse read more

CSS animation-iteration-count

CSS animation-iteration-count property specifies the number of times an animation cycle is played. It can be a number or infinite. In case animation-name has multiple read more

CSS animation-delay

CSS animation-delay property defines when the animation will start. It allows an animation to begin execution some time after it is applied. In case animation-name read more

CSS animation-timing-function

CSS animation-timing-function property describes how the animation will progress over one cycle of its duration. e.g. ease, linear, etc. In case animation-name has multiple values, read more

CSS animation-duration

CSS animation-duration property defines the length of time that an animation takes to complete one cycle. Few points to noe about animation-duration: It cannot be read more

CSS animation-name

CSS property animation-name defines a list of animations that apply to an element. Each name is used to select the keyframe at-rule that provides the read more

CSS text-transform – capitalize, uppercase and lowercase text

CSS property text-transform controls capitalization effects of an element’s text Example – text-transform

CSS text-decoration – underline, overline and strikeout text

CSS property text-decoration describes decorations that are added to the text of an element using the element’s color. Few points to note about text-decoration Underlines, read more

CSS text-indent – indent text in a block

CSS property text-indent specifies the indentation of the first line of text in a block container. Few points to note about text-indent In case of read more

Jenkins – how to delete old builds

Jenkins supports deleting old builds for a project by days or maxium number of builds to keeps. This is useful to keep disk usage under read more

HTML attribute contenteditable – make an element editable

HTML attribute contenteditable makes an element editable. Few things to note about attribute contenteditable Its value can be empty string, true or false. Empty string read more

CSS word-spacing – additional space between words

CSS property word-spacing indicates inter-word space in addition to the default space between words. Word spacing is also influenced by justification (see the text-align property) read more

CSS letter-spacing – additional spacing between adjacent chars

CSS property letter-spacing specifies additional spacing between adjacent characters. Depending on the justification rules in effect (see text-align), user agents may further increase or decrease read more

CSS adjacent sibling selector

Sometime we need to define css style for adjacent sibling elements. It can be defined by using syntax E1 + E2. It will match when read more

CSS text-align – align text left, right or justify

CSS property text-align specifies how the inline-level content of a block is aligned along the inline axis. Note that text-align will also affect inline and read more

Vim – show line numbers

Vim can show and hide line numbers in editor. Here are Vim commands for it. Show line numbers in vim After [ESC] enter the following read more

CSS word-break – specify line breaking rules between letters

CSS property word-break specifies line breaking rules between letters. Note that this different from word-wrap which applies when word does not fit in line box. read more

CSS word-wrap/overflow-wrap – specify if a word can break anywhere

CSS property word-wrap (or overflow-wrap) specifies whether the Browser may break within a word to prevent overflow when an unbreakable string is too long to read more

Recursive grep and excluding directory

Recursive grep is pretty handy way to searching a pattern in a directory recursively. Sometimes it is useful to exclude a specific directory (or multiple read more

CSS3 animation overview

CSS property animation along with @keyframw definition can be used to implement animation on properties in CSS. The behaviour of these keyframe animations can be read more

Online React jsx to javascript transformer using babel-cli

This online transformer can be used to compile react jsx to Javascript using babel-cli.

HTML5 drag and drop – move an element to dropzone

HTML5 Drag and Drop interfaces enable applications to use drag and drop (using mouse) features in web browser. It involves dragging an element and dropping read more

CSS visibility – hide an element keeping its space

CSS property visibility specifies whether the boxes generated by an element are rendered. Invisible boxes still affect layout. One can set the css display property read more

HTML pre tag tutorial

HTML pre tag (<pre>) represents a block of preformatted text. By default pre tag does not collapse white spaces, and uses monospaced (fixed-width) font like read more

CSS text-overflow – truncate text with three dots

CSS property text-overflow specifies rendering when inline content overflows its line box edge in its block container element (“the block”) that has overflow other than read more

AngularJS – implement tabs using ng-switch

Angularjs ng-switch directive is used to conditionally swap DOM structure on your template based on a scope expression. ng-switch usage Example – horizontal tabs using read more

Python find length of string or list using len()

Python len can be used to return length of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or read more

AngularJS – include inline template

Angularjs ng-include can be used to include internal or external (separate url) templates. This tutorial will cover including inline template using ng-include. ng-include usage Example read more

AngularJS – include url template

Angularjs ng-include can be used to include inline or external (url) templates. This tutorial will cover including url template using ng-include. ng-include usage Template used read more

CSS border-style tutorial and examples

CSS border-style property specify the line style of a box’s border (solid, double, dashed, etc.). Few points to note: When four values are specified this read more

CSS border-color – define color of four borders

The border-color property sets the color of the four borders. Few points to note: When four values are specified this is the order: border-top-color, border-right-color, read more

CSS border-width – set element border width of four sides

The border-width properties specify the width of the border area of an element. Few points to note: When four values are specified this is the read more

CSS list-style – shorthand for list marker type, image and position

CSS list-style property is a shorthand notation for setting the three properties list-style-type, list-style-image and list-style-position at the same place in the style sheet. Example read more

CSS list-style-image – use image as marker in list

The property list-style-image sets the image that will be used as the list item marker. When list-style-image set and image is available, it will replace read more

CSS list-style-position – specify if list markers will be outside or inside

CSS list-style-position property specifies the position of the marker box with respect to the principal block box. outside: The marker box is outside the principal read more

CSS list-style-type – specify marker (disc, square, numeric, etc.) for a list

CSS list-style-type property is used to describe type of list item marker in a list. Its initial value is disc. The value of list-style-type can read more

CSS white-space – collaping and wrapping of whitespaces and newlines

CSS whitespace property is used to describe how whitespace inside the element is handled. This property specifies two things: Whether and how white space inside read more

HTML ol tag

HTML ol tag (<ol>) can be used to create ordered list. It can contain multiple list items using tag li (<li>) and it can be read more

WordPress mysql query to get all posts with a specific custom field

Handy mysql query to get all posts with a specific custom field. We’ll query post_type=page for the purpose of this tutorial. You will have to read more

HTML li tag

HTML li tag (<li>) can be used to create a list item. It can be used either in unordered list – ul (<ul>) or in read more

HTML ul tag

HTML ul tag (<ul>) can be used to create unordered list. It can contain multiple list items using tag li (<li>) and it can be read more

HTML5 audio tag

HTML5 audio tag (<audio>) can be used to play an audio in HTML page. When multiple sources are specified, browser uses the first recognized format. read more

React Overview

React is a Javascript library for building user interfaces. Lots of people use React as the V in MVC (Model View Controller). React can work read more

CSS transform – skew (skewX and skewY)

Using CSS3 property transform, elements can be translated, rotated, scaled and skewed in two or three dimensional space. This tutorial will covered skewing an element read more

Scale an element using css transform

Using CSS3 property transform, elements can be translated, rotated, scaled and skewed in two or three dimensional space. This tutorial will covered scaling an element read more

Rotate an element using css transform

Using CSS3 property transform, elements can be translated, rotated, scaled and skewed in two or three dimensional space. This tutorial will covered rotating an element read more

CSS – align div in center vertically

To place a div (or any block level element) of unknown size containing text, in center of its parent vertically, the following approach can be read more

CSS transform – translateX and translateY

Using CSS3 property transform, elements can be translated, rotated, scaled and skewed in two or three dimensional space. This tutorial will covered translating an element read more

CSS all – shorthand to reset all properties

CSS property all is a css shorthand to reset all properties to their initial or inherited values. Note that it is not supported in IE. read more

CSS unset value examples

If CSS property value is unset, then if it is an inherited property, this is treated as inherit, and if it is not, this is read more

CSS inherit value examples

CSS inherit value is used to set a css property value to its parent element value. It can be used during debugging (e.g. In Chrome read more

CSS initial value examples

CSS initial value is used to reset a css property to its user-agent value. It can be used during debugging (e.g. In Chrome developer tools) read more

WordPress – add content filter after shortcode execution

Sometimes we need to add content filter in wordpress which should execute after all the shortcodes. The shortcodes in wordpress are executed by filter do_shortcode read more

node-sass quick start tutorial on Linux and Mac

Sass (Syntactically Awesome Stylesheets) is a style sheet language which brings programming features like variables, etc. to css. It makes maintaining and modifications in css read more

Python re search vs match

Python re.match() checks for a match only at the beginning of the string, while re.search() checks for a match anywhere in the string. Re search read more

Python re (regex) match examples

Python regular expression module (re) can be used to check a string begins with a pattern using re.match(). Note that it is different from re.search() read more

CSS – style for element having two classes (both)

Sometime we need to define css style for elements having two or multiple clasess (all of them). It can defined by using syntax .class1.class2 (or read more

CSS max-height – limit maximum height of an element

CSS max-height property is used to set maximum height of a box element. Few points to note about max-height It cannot be negative. If max-height read more

CSS min-height – set minimum height of an element

CSS min-height property is used to set minimum height of a box element. Few points to note about min-height It cannot be negative. If min-height read more

Composer – quick start guide on Linux and Mac

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) read more

CSS max-width – limit maximum wodth of an element

CSS max-width property is used to set maximum width of a box element. Few points to note about max-width It cannot be negative. If max-width read more

CSS min-width – set minimum width of an element

CSS min-width property is used to set minimum width of a box element. Few points to note about min-width It cannot be negative. If min-width read more

Install redis on Mac

Redis is an open source, in-memory data structure store, used as database, cache and message broker. It is one of the most popular key-value nosql read more

Install rabbitmq on Ubuntu Linux

RabbitMQ is an open source message broker software that implements the Advanced Message Queuing Protocol (AMQP). It is written in the Erlang programming language. Here read more

jQuery toggleClass() examples

jQuery toggleClass can be used to toggle a class (add or remove depending upon current state) in an element (or set of matched elements). In read more

HTML5 label tag examples

Label element (<label>) represents a caption and can be used with one form input element. There are two ways to associate a label to an read more

Monitor apache using mod_status on Ubuntu

Apache installation on Ubuntu Linux automatically installs mod_status also. mod_status can be used to view server activities and performance from a web interface. Here are read more

PHP sort associative array using custom compare function

PHP associative array can be sorted using custom user compare function while maintaining index association using uasort. The function is passed two values and it read more