Programming
How to change bullet style for unordered list UL in HTML or CSS
Nov 30th
The unordered list “<ul>” supports an attribute named “type” that specifies type of display for bullets. The “type” attribute takes values: disc,circle,square.
The following displays a square instead of default disc style for bullets.
<ul type="square"> <li>One</li> <li>Two</li> <li>Three</li> </ul>
display looks like following
- One
- Two
- Three
Similarly, a disc style appears as follows:
- One
- Two
- Three
Similarly, a circle style appears as follows:
- One
- Two
- Three
Otherwise, you can use “list-style-type” attribute in CSS as shown below:
ul {
list-style-type: square;
}
You can customize the bullets further by specifying an image url in CSS as follows:
ul {
list-style-type: url("/images/arrow.jpg");
}
More >
How to display special characters in HTML
Nov 30th
HTML is a mark up language that uses characters like “<”, “>” as part of its syntax. So it provides a special escapes to display the special characters as is in HTML. The following table provides list of special characters and their HTML syntax.
Name Symbol HTML syntax Ampersand & & Cent ¢ ¢ Copyright © © Degree ° ° Greater Than > > Less Than < < Non-breaking Space Registered Trademark ® ® Trademark ™ ™
How to disable left indentation of LI tags in HTML
Nov 29th
The <li> tag can be used under an unordered list tag <ul> or ordered list tag <ol>.
The following shows how <li> tag can be used in an unordered list. Under unordered list, each <li> shows a bullet by default.
<ul> <li>One</li> <li>Two</li> <li>Three</li> </ul>
The above code appears in the browser as follows:
- One
- Two
- Three
You can use following CSS to disable left indentation:
ul {margin: 0;}
If you don’t want to display bullets, you can do the following.
ul {
list-style-type: none;
margin: 0;
}
You can use similar trick for ordered list
- as well.
More >
How to disable display of bullets for LI tags in HTML
Nov 29th
The <li> tag can be used under an unordered list tag <ul> or ordered list tag <ol>.
Unordered List The following shows how <li> tag can be used in an unordered list. Under unordered list, each <li> shows a bullet by default.
<ul> <li>One</li> <li>Two</li> <li>Three</li> </ul>
The above code appears in the browser as follows:
- One
- Two
- Three
If you don’t want each <li> item not to display its position as number under <ul>, you can add “list-style-type: none;” style to the <ul> tag.
<ul style="list-style-type: none;"> <li>One</li> <li>Two</li> <li>Three</li> </ul>
Ordered List The following shows how <li> tag can be used in an ordered list. Under ordered list, each More >
How to check if an IP address falls in a subnet based on subnet and subnet mask
Oct 29th
This can be achieved easily with binary AND (&) operation as shown the function below.
typedef unsigned long IPv4Addr;
/* Function returns 1 if the IP falls in the subnet. Otherwise returns 0. */
int IsIpInTheSubnet(IPv4Addr ip, IPv4Addr subnet, IPv4Addr mask)
{
if((ip & mask) == (subnet & mask)) return 1;
return 0;
}
Example:
IP Address Subnet Mask Return Value 192.168.1.10 192.168.1.0 255.255.255.0 1 192.168.2.10 192.168.1.0 255.255.255.0 0The above function can easily be converted in to a macro to make it simple and more efficient.
This is what preciselyTCP/IP networking stack does for finding a route in the system routing table before More >
How to change/set/reset MySQL root password using mysqladmin
Oct 10th
After installing MySQL service, administrator should set a reasonably strong password using mysqladmin utility. In MySQL, user name of administrator is “root”. To change/set/reset password, you need to run two commands. The following shows the syntax of the commands.
[root@techpulp ~]# mysqladmin -u root password NEWPASSWORD [root@techpulp ~]# mysqladmin -u root -h HOSTNAME password NEWPASSWORD
The following commands show example usage.
[root@techpulp ~]# mysqladmin -u root password y5FxEtrh [root@techpulp ~]# mysqladmin -u root -h localhost password y5FxEtrh
As the commands you executed are stored in history file (~/.bash_history), you can avoid it by running following command before running mysqladmin utility.
[neo@techpulp ~]# echo $HISTFILE /home/neo/.bash_history More >
How to make a BSD socket non-blocking – EWOULDBLOCK
Oct 5th
Sometimes it is needed to make a socket non-blocking so that I/O requests on the socket don’t block. For a non-blocking socket, when I/O requests like read() and write() return a negative value, the errno should be checked against -EWOULDBLOCK code to find if the I/O request would have blocked.
The following utility function sets non-blocking flag of a socket.
int socketSetNonBlocking(int sockfd)
{
unsigned int flags;
flags = fcntl(sockfd. F_GETFL, 0);
if(flags < 0) return -1;
if(fcntl(sockfd, F_SETFL, flags|O_NONBLOCK) < 0) return -1;
return 0;
}
Similarly the following function makes a non-blocking socket a blocking socket.
int socketSetBlocking(int sockfd)
{
unsigned int More > How to find IP address of an interface using bash scripting
Oct 1st
In Linux, ifconfig command is used to view the information about network interfaces. Let us examine the output of the command to determine how we can parse the information for IP address.
[neo@techpulp ~]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 03:A6:2E:52:3D:BA inet addr:66.27.16.64 Bcast:66.27.16.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:14257 errors:0 dropped:0 overruns:0 frame:0 TX packets:4364 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4831053 (4.6 MiB) TX bytes:663388 (647.8 KiB) Interrupt:21 Base address:0x2000 [neo@techpulp ~]#
The IP address information is present in second line containing keyword “inet addr”. The following script accepts an interface name as command line argument More >
How to extract extension from a file name in bash
Sep 29th
The following trick can be used to extract file extension from a name.
[neo@techpulp ~]# MYFILE=filename1.txt
[neo@techpulp ~]# echo $MYFILE
filename1.txt
[neo@techpulp ~]# echo ${MYFILE##*.}
txt
[neo@techpulp ~]#
Let us try the same on a file name with full path.
[neo@techpulp ~]# MYFILE=/home/neo/filename1.txt
[neo@techpulp ~]# echo ${MYFILE##*.}
txt
[neo@techpulp ~]#
How to disable HTTPS or SSL in Apache server
Sep 17th
If your web server is not hosted using a dedicated IP address and doesn’t have a security certificate, it is implicit that you can’t host HTTPS service. In such cases, it is always better to disable HTTPS service so that there won’t be any unwanted service running in the server.
Use the following command to find if Apache is listening on HTTPS port.
[root@techpulp ~]# netstat -ntl | grep 43 tcp 0 0 :::443 :::* LISTEN [root@techpulp ~]#
To disable Apache from enabling HTTPS service, you need to comment the following line in /etc/httpd/conf.d/ssl.conf file.
#Listen 443
You need to restart the service to make the More >


Recent Comments