Wednesday, February 20, 2013

Mounting an ISO in FreeBSD


Mounting an ISO file in FreeBSD is slightly different than in Linux




In FreeBSD:
# mdconfig -a -t vnode -f -u 0
mdconfig creates a memory disk /dev/md0. Then you mount it to your destination:
# mount -t cd9660 /dev/md0

Thursday, September 27, 2012

UnInheritable Class


You must be familiar with the NonCopyable Base class:


class NonCopyable
{
  protected:
    NonCopyable () {}
    ~NonCopyable () {}
  private: 
    NonCopyable (const NonCopyable&);
    NonCopyable& operator = (const NonCopyable &);
};

class A : private NonCopyable
{
};


How do you make a class un-inheritable?


template
class UnInheritable
{
private:
    ~UnInheritable();
    friend class T;
};


class A : virtual public UnInheritable
{
...
};

Wednesday, September 05, 2012

Slow SSH logon

If the hostname of a Linux box is not resolvable using DNS, SSH logins may be slow. It takes a several seconds from the Username prompt to Password prompt.

To resolve this problem edit


$ vi /etc/ssh/sshd_config
UseDNS no
# service ssh restart

Tuesday, May 08, 2012

Validate IPv4 netmask in C

Here's a useful routine I frequently use to validate whether a given string is a netmask or not:


int isValidNetMask (char* netmaskStr)
{
    unsigned char oneFound = 0;
    unsigned long int netmask = inet_addr(netmaskStr);
    
    if ( netmask == INADDR_NONE )
    {
        if ( strcmp(netmaskStr, "255.255.255.255") == 0 )
        {
            return 1;
        }
        return -1;
    }
    else
    {
        netmask = ntohl(netmask);
        unsigned long int mask;
        for ( mask = 1; mask; mask <<= 1 )
        {
            if ( netmask & mask )
            {
                oneFound++;
            }
            else if ( oneFound )
            {
                return -1;
            }
        }
        return 1;
    }
}

Tuesday, April 03, 2012

Acetaminophen Dosage for Infants and Children

Baby's Weight
Milligram Dosage
Infant Drops
(80mg/0.8mL)
Children's liquid
(160mg/5mL)
5-8 lbs
40mg
½ dropper 
¼ tsp 


(.4ml)
(1.25ml)
9-10 lbs
60mg
¾ dropper 
1/3 tsp 


(.6ml)
(1.8ml)
11-16 lbs
80mg
1 dropper 
½ tsp 


(.8ml)
(2.5ml)
17-21 lbs
120mg
1 ½ droppers 
¾ tsp 


(1.2ml)
(3.75ml)
22-26 lbs
160mg
2 droppers 
1 tsp 


(1.6ml)
(5ml)
27-32 lbs
200mg
2 ½ dropper 
1 ¼ tsp 


(2ml)
(6.25ml)
33-37 lbs
240mg
3 droppers 
1 ½ tsp 


(2.4ml)
(7.5ml)
38-42 lbs
280mg
3 ½ droppers 
1 ¾ tsp 


(2.8ml)
(8.75ml)
43-53 lbs
320mg
4 droppers 
2 tsp 


(3.2ml)
(10ml)
54-64 lbs
400mg
Use Liquid
2 ½ 



tsp(12.5ml)
65-75 lbs
480mg

3 tsp 



(15ml)
76-86 lbs
560mg

3 ½ tsp 



(17.5ml)
87-95 lbs
640mg

4 tsp 



(20ml)

Friday, December 09, 2011