Nokia Mini Speakers MD-4 – Travel sounds

0 comments

Nokia Mini Speakers MD-4 are for you if you want to listen to music tracks or FM radio on your compatible phone.




With Nokia Mini Speakers MD-4 you can:

listen to music from your compatible phone for up to 30 hours on a single set of batteries
travel light: the speakers are extremely lightweight and fold away when you’re not using them
enjoy stereo sound from your compatible phone's music player and radio with mini speakers that fit your pocket

Nokia N95 tech review

0 comments

Nokia N95 Specifications
=========================


Network :
Technology / Frequency Bands GSM : 850/900/1800/1900 MHz UMTS : 2100 MHz
Battery :
Type Li - Ion
Capacity 1100 mAh
Standby 220 hours UMTS: 200 hours
Talktime 240 mins UMTS: 162 mins
Built :
Dimensions 99x53x21 mm
Weight 120 g
Antenna Type Internal
Form Factor Slide
Display :
Size 240 x 320 pixels
Type color : TFT
Colors 16000000 colors
Secondary Display no

Camera / Imaging / Video :
Camera yes Inbuilt
Resolution 2592x1944 pixels
Image Formats EXIF / JPEG
Resolutions Supported 640x480 / 2592x1944 pixels
Zoom yes 20x
Flash yes
Video Recording yes Resolution :640x480 30 fps
Video Formats MPEG-4 / 3GPP H.263
Video Resolutions Supported 176x144 / 352x288 / 640x480 / 320x240 pixels
Video Out yes
Secondary Camera yes
Secondary Camera :
Resolution 320x240 pixels
Image Formats EXIF / JPEG
Zoom 2x
Flash no
Video Recording yes Resolution :176x144 Zoom:2x 15 fps
Video Formats 3GPP H.263
Connectivity :
Bluetooth Yes , version 2.0 profiles: BIP Basic Imaging / DUN Dial Up Networking / HFP Hands Free
Irda Yes
Wlan/Wi-fi Yes Modes: 802.11b / 802.11g Supporting: WPA,WPA2 (AES/TKIP)
Pc Sync yes
SyncML yes
USB yes
GPS yes
UMA no
UnPnP yes
Data :
Data Modes GPRS / EDGE (EGPRS) / WCDMA (UMTS) / HSCSD / CSD / HSDPA 1.8
GPRS Yes
EDGE Yes
3G Yes
HSDPA yes
Internet :
WAP yes 2.0
Browsing S60 OSS Browser , HTML, XHTML
Media :
Audio Playback Yes
Audio Formats MP3 / MP4 / M4A / WAV
Video Playback Yes
Video Formats RealVideo / MPEG-4 / 3GPP H.263 / H.264/AVC
Ringtones
FM Radio Yes Visual Radio
3.5mm Headphone Jack yes
Memory :
Inbuilt 160 MB
Memory Slot yes microSD/TransFlash Hot Swappable
Included : 128 MB Expandable Upto : 4 GB
USB Mass Storage no

Messaging :
SMS Yes
MMS Yes
Email Yes Protocols : IMAP4,POP3,SMTP

Predictive Text Input T9
Templates yes
Instant Messaging yes
Input :
Multiple Languages yes
Music Keys yes
Internet Key yes
Calling / Voice :
Voice Recording yes
Voice Dial yes
Video Calling yes
Vibration yes
Speaker yes
VOIP yes
Push2Talk yes
Contacts :
PhoneBook yes
Multiple Numbers per contact yes
PictureID yes
RingerID yes
Software :
Operating System Symbian / S60 Symbian OS 9.2

Platform S60 3rd Edition, Feature Pack 1
Java yes MIDP 2.0 CLDC 1.1
Flash Lite yes Version 2.0
Games yes
Personal Information Management :
Alarm yes
Calculator yes
Stopwatch no
To Do yes
Calendar yes
Countdown no
Flashlight no
Servicelight no

Sony's Laptop

1 comments

Slowly but surely, like desktop PCs, laptop computers are becoming boring, me-too commodity products. Most are made for brand-name computer companies by a handful of contract manufacturers in Asia, and too many of those brand-name companies merely make limited tweaks to cookie-cutter designs the contractors develop.


But a few laptop makers are still innovating regularly, both in function and style. Even though they may hire the same Asian factories to fabricate their laptops, they begin with their own unique designs. These innovators include Apple Computer, of course; but also Lenovo, the Chinese firm that now makes IBM-brand ThinkPad laptops; and Sony, long a laptop innovator, especially in the ultra-portable segment of the laptop market, where small size demands great design.


Sony’s new TX650 laptop can record CDs and DVDs.Sony’s latest coup is a new, ultra-portable series that manages to shrink the overall size and weight of its predecessor while expanding the size of the screen and extending an already impressive battery life. And it’s one of the few laptops on the market that can connect to the Internet over a cellphone network without requiring any adapters.

I’ve been testing this new laptop, the TX650, and in general I like it. Unfortunately, it also has a few downsides, including some disappointments in its most vaunted feature: its wireless capability.

The TX650, which will be available next month for $2,300, replaces, and tops, the very nice T series that came before it. Like the T, the TX is a sleek, svelte laptop that still manages to pack in a DVD drive that can read and record DVDs and CDs. Like the T, it also has a good complement of ports and connectors and excellent battery life, which is rare in such tiny machines.

In addition, the new TX series has a wide screen that measures 11.1 inches diagonally and features a high resolution of 1,366 by 768. The T series had a 10.6-inch screen with a resolution of 1,280 by 768. The screen is very sharp, and the keyboard, while a bit cramped, is adequate.

The TX650 also beats the T series on battery life, which is saying a lot. In my harsh battery test, where I turn off all power-saving software, set the screen brightness to maximum, turn on the Wi-Fi wireless networking, and then play an endless loop of music to keep the hard disk spinning, the TX650’s battery lasted an astonishing four hours and 53 minutes. That’s nearly half an hour longer than the T lasted in the same test, and it means the TX could probably top six hours in normal use, with battery-saving features enabled.

Yet the TX is actually a bit smaller than the T series was. It has the same 10.7-inch width as its predecessor, but it is as little as 0.83 inch thick at its front edge, compared with one inch for the T series. And it’s just 7.7 inches deep, compared with 8.1 inches for the T series. It also weighs less than the T series — 2.76 pounds, down from 3.04 pounds.

Much of this size and weight reduction is a result of Sony’s use of an innovative carbon-fiber casing that allows the lid to be the thinnest I’ve ever seen. Also, the battery doesn’t protrude much from the rear.

The TX has a 60-gigabyte hard disk and a Pentium M processor running at 1.2 gigahertz. It has a decent 512 megabytes of memory, though up to 128 megabytes of that is shared with the graphics system. To Sony’s credit, the TX also includes a slot for the popular SD type of camera memory card in addition to one for Sony’s proprietary Memory Stick card.

Like some larger laptops, the TX650 has a special instant-on mode that allows you to play music or DVDs without going through the slow process of launching Windows. However, my test machine lacked the software that powers this feature, so I couldn’t test it.

The TX650 has Wi-Fi and Bluetooth wireless networking. And like the last model of the T series, it also has built-in access to a cellphone network for wireless Internet access, something which usually requires buying and installing a plug-in card. (You have to buy a cellphone plan to use this feature.)

In my tests, I was able to get on the Internet just fine with both the Wi-Fi and cellphone features, which can’t be used simultaneously. But the wireless networking on the TX650 has some drawbacks. First, this laptop uses an external, rubber swivel antenna that can easily pop off and get lost. That’s a pain.

Second, Sony chose as its cellphone solution Cingular’s EDGE network, which gets only about 100 kilobits a second, or a bit more, at best. That’s only two to three times as fast as a home dial-up modem and nowhere near broadband speed. It’s too bad Sony didn’t opt for Verizon’s EV-DO network instead, as several of its competitors have, including Dell and Lenovo. The Verizon network is roughly seven times as fast as EDGE and is about the equivalent of a wired DSL broadband connection.

All in all, the Sony TX650 is an impressive design. But if you really expect to use a built-in cellphone mode to get online, you’d be better off picking a competitor that uses Verizon’s EV-DO.

Dell VostroTM laptops

0 comments

Dell VostroTM laptops are designed for small business. Packed with customized features and a choice of software, the Vostro line delivers easy-to-use technology, flexible connectivity options and exceptional support – all in a thin, durable design.




Vostro 1510 at a Glance:
---------------------------
Customized Software Suite - Eliminate trialware and choose only the software your business needs.
Outstanding Out-of-Box Performance - Excellent first boot experience puts you in business in minutes.
Durable Construction – Enjoy the durability of Vostro’s magnesium-alloy reinforced chassis, sturdy hinges and sealed keyboards.
Maximum Wireless Connectivity – Designed to minimize dead spots and connect virtually anywhere3 business takes you with optional next-generation Wireless-N Wi-Fi® .
Exceptional Service and Support – Vostro laptops include 1-year Limited warranty and specially trained technical support.
System and Data Protection – Help prevent unauthorized access, malicious attacks and theft with flexible security options.


Easy-to-Use Technology
--------------------------
When your business demands time, your technology shouldn’t. The all-purpose Vostro 1510 includes a comprehensive portfolio of small business support services and features. Enjoy simplified system set-up, management and maintenance.Consolidate network set-up and troubleshooting with Dell Network Assistant.
Ensure peak system performance with automated maintenance tools.
Receive personalized support from specially trained technicians.
Enhance standard services with optional Dell ProSupport tailored support plans.





Extraordinary Performance and Value
------------------------------------
Even small business demands big results. The multi-functional Vostro 1510 delivers lightning-fast processing, crisp images, flexible drive options and up to 4GB4 of memory – all at exceptional small business value. Withstand the rigors of home and office with rugged, lightweight magnesium-alloy reinforced construction.
Enhance performance and battery life with latest-generation Intel® CoreTM 2 Duo processor.
Get higher contrast ratio than standard anti-glare displays for brighter images with TrueLifeTM display technology.
Choose from Combo and DVD read/write optical drives
Enhance video and photo clarity with an optional graphics card up to 256MB.
Help protect your hard drive against unexpected drops with Free Fall Sensor included in optional 7200RPM hard drives



Convenient Size, Operation and Weight
------------------------------------
Expertly designed Vostro laptops offer heavyweight performance – without the weight. Thin and highly portable, the 1510 starts at just 2.6 kg2. And the glossy 15.4" TrueLifeTM display delivers vibrant widescreen images in a convenient, road-ready size. Easy multimedia operation with convenient controls.
Simplify disc loading with convenient slot-load optical drives.
Increase work time with long battery life.




Exceptional Connectivity and Security
------------------------------------
When business extends beyond the desk, Vostro 1510 is designed to enable secure connectivity - from virtually anywhere, anytime. Help Maximize productivity and up-time with optional Wireless-N WiFi® , Bluetooth® technology. Then protect your system – and important data – with flexible Dell security options and standard software. Maximize hot spot connectivity, throughput and range with next-generation Wireless N WiFi® .
Enable cable-free computing with Bluetooth® connectivity to peripherals.
Restrict system access with optional fingerprint reader.
Authenticate network access with Trusted Platform Module (TPM 1.2).

Tech Specs
===========
Processors
Up to Intel® CoreTM 2 Duo Processor T9500 (2.60 GHz, 6 MB L2 cache, 800 MHz FSB)

Operating System
Genuine Windows Vista® Ultimate
Genuine Windows Vista® Business
Genuine Windows Vista® Home Basic
Genuine Windows Vista® Business with Windows® XP Pro Downgrade Rights
Genuine Windows Vista® Ultimate with Windows® XP Pro Downgrade Rights

Memory
Up to 4 GB6 Dual Channel 667MHz DDR2 SDRAM5.
Chipset
With integrated graphics: Intel® 965GM Express chipset
With discrete graphics: Intel® 965PM Express chipset
Graphics
Intel Integrated Graphics Media Accelerator X31009
256MB NVIDIA® GeForceTM 8400M GS Graphic Card

LCD Display
15.4" Widescreen WXGA (1280 x 800) Display
15.4" Widescreen WXGA+ (1440 x 900) Display
15.4" Widescreen WXGA+ (1440 x 900) Display with TrueLifeTM
15.4" UltraSharp™ Widescreen WUXGA (1920 x 1200) Display with TrueLifeTM
Audio and Speakers
Two channel high definition audio codec; Two stereo 2 watt internal speakers with HD Audio 2.0 software standard
Hard Drives
5400 RPM hard drives up to 320GB or optional 7200 RPM Free Fall Sensor hard drive at 160GB8
Optical Drives
Fixed Internal 8x DVD / 24x CDRW Combo Slot Load Drive including Software
Fixed Internal 8X DVD+/-RW7 Slot Load Drive including Software
Security
Optional Biometric fingerprint reader
Optional Trusted Platform Module 1.2 with Infineon TPM management Security Software


Power
6-cell 56WHr Li-Ion Battery
Camera
Optional integrated 1.3 mega pixel with single digital microphone
Wireless
Wi-Fi Options:
Modem : 56K V.92 External USB Modem (Optional)
Integrated Wired : Gigabit RJ45 Ethernet network interface adapter standard (100% attached)
Intel Pro/Wireless 3945 802.11 a/g Mini Card Wireless
Intel 4965AGN Wireless-N Mini Card


Bluetooth Options:
Dell Wireless 360 Bluetooth® Module

Ports, Slots, Chassis
----------------------
Externally Accessible:
(4) USB 2.0 compliant 4-pin ports
15-pin VGA video connector
Network connector (RJ45)
Modem optional external via USB port
AC adapter connector
Microphone in & Headphone jack
4-pin IEEE 1394 port
8-in-1 media memory card reader
54 mm ExpressCard slot

Internal Card Slots:
Bluetooth
2 Mini-Card

Dimensions & Weight:
--------------------
Width: 357mm
Height: 25.4mm (f), 1.50" / 38mm (b)
Depth: 258mm
Weight: Preliminary starting weight at 2.59kg 2 with 15.4" WXGA Anti-Glare display, UMA integrated graphics, 6-cell battery, Optical Drive and WLAN
Modem optional external via USB port

Interview quest-1

0 comments

-Disk Label
========================
can you remind what is the meaning of cXtXdXsX?

DISK SLICE NAMING CONVENTION:
An 8 character string typically represents the fully name of aslice (c# t# d# s#)

1)controller:identifieshost bus adapater(HBA) which controls communication between the system and disk unit

2)targernumber:corresponding to a unquie hardware address that is assigned to each disk ,tape or cdrom

3)disk number:
also know as logical unit number (LUN) this number reflects the number of disks as the target number
4)slice number: a slice number range from 0-7

the disk label is the ares set aside for storing information about the disk controller, geometry and slices
another term used to describe a disk label is the volume table of contents(VTOC)

the label dsik means to write slice information on the disk

what is function of sccli ?
===============================
Using Certain sccli Commands to Manage a Sun StorEdge 3510 or 3511 Fiber Channel Array

What is the command to do an interactive boot from the ok prompt?
==================================================================
if os is up and runing, take help for man to eeprom command

stop+a command is to boot an interactive boot from the ok prompt

The Interactive Boot Process:

At the ok prompt, type boot -a and press Enter. The boot program prompts you interactively


Consider the following crontab entry: ?59 23 13 * 5 /wipe.disk? What time will this cronjob run?
===================================
That means: on Black Friday, your hard drive will get wiped out.

==> (on 13th and Friday) 23:59, /wipe.disk will be running


--------------------------------------------------------------------------------
If the 13'th Day of the month is Friday, the job will run. (week day starts from Sunday day 1).


How can i disable STOP+A utility on SUN machines, which brings system into OK> prompt???.
===========================================================
in /etc/system set abort_enable=0 will disable STOP-A

--------------------------------------------------------------------------------
There are several ways to disable "STOP-A"
(1)Edit the /etc/default/kbd file
KEYBOARD_ABORT=disable

(2)Use the "kbd -a disable" command
(3) Edit /etc/system file
set abort_enable = 0

How do we know how many LAN cards we have in server?
========================================================
Just Type in the following command at prompt#ifconfig -a.That shall give the LAN Cards as well as total Physical and Logical IP Addresses

dmesg - It displays all configured items on systems

#prtconf
#prtdiag
# cat /etc/path_to_inst

What is "Piping"?
====================
piping:- sending the output of a command to the input of another is called piping.

some examples are:

$cal | wc

will output total line's,word's and character's

$cal | wc | wc

will output total line's,word's and character's

A unix pipe provides a one-way flow of data.

for example

For example, if a Unix users issues the command
$who | sort |lpr
then the Unix shell would create three processes with two pipes between them:

A pipe can be explicitly created in Unix using the pipe system call. Two file descriptors are returned--fildes[0] and fildes[1], and they are both open for reading and writing. A read from fildes[0] accesses the data written to fildes[1] on a first-in-first-out (FIFO) basis and a read from fildes[1] accesses the data written to fildes[0] also on a FIFO basis.


When a pipe is used in a Unix command line, the first process is assumed to be writing to stdout and the second is assumed to be reading from stdin. So, it is common practice to assign the pipe write device descriptor to stdout in the first process and assign the pipe read device descriptor to stdin in the second process. This is elaborated below in the discussion of multiple command pipelines.

Where are the templates stored that are copied into the user's home directories for their personal customizations?
==========================================================
/etc/skel

Which NFS daemons are found on the NFS server?
=============================================
nfslogd

In NFS server side there are

nfsd
mountd
lockd
statd
nfslogd

These five daemons will be in NFS server.

statd and lockd will be in NFS client too.


What file controls system wide password aging?
==============================================
/etc/shadow

What flag used with patchadd will prevent a later back out by preventing patchadd from backing up files? If this flag is used, the patch cannot be removed.
=======================================================================
You have to use the option "d" along with th patchadd commnad.

patchadd -d

What file do you put the umask setting in?
============================================
The UMASK value for bourne and korn shell users can be modified system wide by editing the "umask" entry in the "/etc/profile" file. To change the default UMASK for the C shell, modify the UMASK variable in "/etc/default/login" file.

When using the admintool, the membership list for groups is separated by what?
==================================================
commas


Among the applications below, which one is not a client/server application?
==================================
cron

What command will display the VTOC for disk c0t0d0s0?
==================================================
prtvtoc /dev/rdsk/c0t0d0s0

PRTVTOC

What file contains the location of the namespace configuration textfiles such as hosts.rev, named.local, etc..?
==================================
/etc/named.conf

Which of the following commands can tell you whether packets are being delayed or dropped on your network?
===========================================
spray

PHP Files n Directory manipulation

0 comments

Create Directory

mkdir("/path/to/my/dir", 0700);
?>

delete dir
rmdir($dir);

Permissions :

chmod("/adirectory/", 0777); //Will CHMOD a directory
chmod("/adirectory/afile.txt",0777); //Will CHMOD a file


delete file:
// Then unlink :)
unlink($somefile);


example:

function SureRemoveDir($dir, $DeleteMe) {
if(!$dh = @opendir($dir)) return;
while (false !== ($obj = readdir($dh))) {
if($obj=='.' || $obj=='..') continue;
if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true);
}

closedir($dh);
if ($DeleteMe){
@rmdir($dir);
}
}

String Formating in VB

0 comments

VB format syntax
Using the Visual Basic format() function
The Format function converts a value to a text string and gives you control over the string's appearance. For example, you can specify the number of decimal places for a numeric value, leading or trailing zeros, currency formats, and portions of the date. The syntax is:
Syntax
Format(expression [,format [,firstdayofweek [,firstweekofyear]]])
expression
Any valid expression
format
A valid named or user-defined format expression
firstdayofweek
A constant that specifies the first day of the week
firstweekofyear
A constant that specifies the first week of the year The firstdayofweek argument has these settings: Constant Value Description
vbUseSystem 0 Use NLS API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

The firstweekofyear argument has these settings: Constant Value Description
vbUseSystem 0 Use NLS API setting.
vbFirstJan1 1 Start with week in which January 1 occurs (default).
vbFirstFourDays 2 Start with the first week that has at least four days in the year.
vbFirstFullWeek 3 Start with the first full week of the year.

Notes
If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using Format don’t include a leading space reserved for the sign of the value; those converted using Str retain the leading space.
If you are formatting a non-localized numeric string, you should use a user-defined numeric format to ensure that you get the look you want.
If the Calendar property setting is Gregorian and format specifies date formatting, the supplied expression must be Gregorian. If the Visual Basic Calendar property setting is Hijri, the supplied expression must be Hijri.
If the calendar is Gregorian, the meaning of format expression symbols is unchanged. If the calendar is Hijri, all date format symbols (for example, dddd, mmmm, yyyy) have the same meaning but apply to the Hijri calendar. Format symbols remain in English; symbols that result in text display (for example, AM and PM) display the string (English or Arabic) associated with that symbol. The range of certain symbols changes when the calendar is Hijri.
Formatting Symbols
Character Description
None
No formatting Display the number with no formatting.
: Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.
/ Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.
C Display the date as ddddd and display the time as t t t t t, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion.
D Display the day as a number without a leading zero (1 - 31).
dd Display the day as a number with a leading zero (01 - 31).
ddd Display the day as an abbreviation (Sun - Sat).
dddd Display the day as a full name (Sunday - Saturday).
ddddd Display the date as a complete date (including day, month, and year), formatted according to your system's short date format setting. The default short date format is m/d/yy.
dddddd Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. The default long date format is mmmm dd, yyyy.
w Display the day of the week as a number (1 for Sunday through 7 for Saturday).
ww Display the week of the year as a number (1 - 53).
m Display the month as a number without a leading zero (1 - 12). If m immediately follows h or hh, the minute rather than the month is displayed.
MM Display the month as a number with a leading zero (01 - 12). If m immediately follows h or hh, the minute rather than the month is displayed.
MMM Display the month as an abbreviation (Jan - Dec).
MMMM Display the month as a full month name (January - December).
q Display the quarter of the year as a number (1 - 4).
y Display the day of the year as a number (1 - 366).
yy Display the year as a 2-digit number (00 - 99).
yyyy Display the year as a 4-digit number (100 - 9666).
h Display the hour as a number without leading zeros (0 - 23).
hh Display the hour as a number with leading zeros (00 - 23).
n Display the minute as a number without leading zeros (0 - 59).
nn Display the minute as a number with leading zeros (00 - 59).
s Display the second as a number without leading zeros (0 - 59).
ss Display the second as a number with leading zeros (00 - 59).
t t t t t Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. The default time format is h:mm:ss.
AM/PM Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M.
am/pm Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M.
A/P Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M.
a/p Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M.
AMPM Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. The default format is AM/PM.
0
Digit placeholder Display a digit or a zero. If the expression has a digit in the position where the 0 appears in the format string, display it; otherwise, display a zero in that position. If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, display leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, round the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, display the extra digits without modification.
#
Digit placeholder
Display a digit or nothing. If the expression has a digit in the position where the # appears in the format string, display it; otherwise, display nothing in that position. This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal separator in the format expression.
.
Decimal placeholder
In some locales, a comma is used as the decimal separator. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal separator. If you always want a leading zero displayed with fractional numbers, use 0 as the first digit placeholder to the left of the decimal separator instead. The actual character used as a decimal placeholder in the formatted output depends on the Number Format recognized by your system.
%
Percent placeholder The expression is multiplied by 100. The percent character (%) is inserted in the position where it appears in the format string.
,
Thousand separator In some locales, a period is used as a thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (0 or #). Two adjacent thousand separators or a thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) means “scale the number by dividing it by 1000, rounding as needed.” You can scale large numbers using this technique. For example, you can use the format string “##0,,” to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent thousand separators in any position other than immediately to the left of the decimal separator are treated simply as specifying the use of a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system.
:
Time separator In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.
/
Date separator In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.
E- E+ e- e+
Scientific format If the format expression contains at least one digit placeholder (0 or #) to the right of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents.
- + $ ( ) space
Display a literal character To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (” “).
\
Display the next character in the format string Many characters in the format expression have a special meaning and can't be displayed as literal characters unless they are preceded by a backslash. The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\). Examples of characters that can't be displayed as literal characters are the date- and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, and /:), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).
“ABC”
Display the string inside the double quotation marks To include a string in format from within code, you must use Chr(34) to enclose the text (34 is the character code for a double quotation mark).
@
Character placeholder Display a character or a space. If the string has a character in the position where the @ appears in the format string, display it; otherwise, display a space in that position. Placeholders are filled from right to left unless there is an ! character in the format string. See below.
&
Character placeholder Display a character or nothing. If the string has a character in the position where the & appears, display it; otherwise, display nothing. Placeholders are filled from right to left unless there is an ! character in the format string. See below.
<
Force lowercase Display all characters in lowercase format.
>
Force uppercase Display all characters in uppercase format.
!
Force left to right fill of placeholders The default is to fill from right to left.

Named Formats
Visual Basic provides several standard formats to use with the Format function. Instead of using symbols, you specify these formats by name in the format argument of the Format function. Always enclose the format name in double quotation marks (“”). The following table lists the format names you can use. Named format Description
General Number Shows numbers as entered.
Currency Shows negative numbers inside parentheses.
Fixed Shows at least one digit.
Standard Uses a thousands separator.
Percent Multiplies the value by 100 with a percent sign at the end.
Scientific Uses standard scientific notation.
General Date Shows date and time if expression contains both. If expression is only a date or a time, the missing information is not displayed.
Long Date Uses the Long Date format specified in the Regional Settings dialog box of the Microsoft Windows Control Panel.
Medium Date Uses the dd-mmm-yy format (for example, 03-Apr-93)
Short Date Uses the Short Date format specified in the Regional Settings dialog box of the Windows Control Panel.
Long Time Shows the hour, minute, second, and “AM” or “PM” using the h:mm:ss format.
Medium Time Shows the hour, minute, and “AM” or “PM” using the “hh:mm AM/PM” format.
Short Time Shows the hour and minute using the hh:mm format.
Yes/No Any nonzero numeric value (usually - 1) is Yes. Zero is No.
True/False Any nonzero numeric value (usually - 1) is True. Zero is False.
On/Off Any nonzero numeric value (usually - 1) is On. Zero is Off.

Multiple Formats
A user-defined format expression can have from one to four sections separated by semicolons. (If the format argument contains one of the named formats, only one section is allowed.) If you use The result is
One section The format expression applies to all values.
Two sections The first section applies to positive values and zeros, the second to negative values.
Three sections The first section applies to positive values, the second to negative values, and the third to zeros.
Four sections The first section applies to positive values, the second to negative values, the third to zeros, and the fourth to Null values.

The following example has two sections: the first defines the format for positive values and zeros; the second section defines the format for negative values.
$#,##0;($#,##0)
If you include semicolons with nothing between them, the missing section is printed using the format of the positive value. For example, the following format displays positive and negative values using the format in the first section and displays “Zero” if the value is zero.
$#,##0;;\Z\e\r\o
Note If you try to format a number without specifying format, Format provides the same functionality as the Str function. However, positive numbers formatted as strings using Format lack the leading space reserved for displaying the sign of the value; whereas, those converted using Str retain the leading space.
Examples
The following conversions assume that the country in the Windows Control Panel is set to “English (United States).” Format syntax Result
Format(8315.4, “00000.00”) 08315.40
Format(8315.4, “#####.##”) 8315.4
Format(8315.4, “##,##0.00”) 8,315.40
Format(315.4, “$##0.00”) $315.40
Format(7, “0.00%”) 700.00%
Format(“This Is A Test”, “<”) this is a test
Format(“This Is A Test”, “>”) THIS IS A TEST
Format(Now, “m/d/yy”) 1/27/93
Format(Now, “dddd, mmmm dd, yyyy”) Wednesday, January 27, 1993
Format(Now, “d-mmm”) 27-Jan
Format(Now, “mmmm-yy”) January-93
Format(Now, “hh:mm AM/PM”) 07:18 AM
Format(Now, “h:mm:ss a/p”) 7:18:00 a
Format(Now, “d-mmmm h:mm” 27-January 7:18
Format(Now, “d-mmmm-yy”) 27-January-93
Format(Now, “d mmmm”) 27 January
Format(Now, “mmmm yy”) January 93
Format(Now, “hh:mm AM/PM”) 08:50 PM
Format(Now, “h:mm:ss a/p”) 8:50:35 p
Format(Now, “h:mm”) 20:50
Format(Now, “h:mm:ss”) 20:50:35
Format(Now, “m/d/yy h:mm”) 1/27/93 20:50
Format (format) Positive 5 Negative 5 Decimal .5 Null
Zero-length string 5 -5 0.5
0 5 -5 1
0.00 5.00 -5.00 0.50
#,##0 5 -5 1
#,##0.00;;;Nil 5.00 -5.00 0.50 Nil
$#,##0;($#,##0) $5 ($5) $1
$#,##0.00;($#,##0.00) $5.00 ($5.00) $0.50
0% 500% -500% 50%
0.00% 500.00% -500.00% 50.00%
0.00E+00 5.00E+00 -5.00E+00 5.00E-01
0.00E-00 5.00E00 -5.00E00 5.00E-01

Credit
Most of this is a re-hash of the documentation available from Microsoft. But Microsoft has its Format() documentation spread out in a number of loosely related entries, instead of being in one place.

Calnder using PHP and Ajax

0 comments

Online calendars are often used in many web applications. Though popular, the logic behind creating a calendar can be scary especially for those who are new to programming. There are many web calendars in the market but some of them are quite complicated. If we are not able to understand the code, it becomes harder for us to customise the calendar to fit into our existing application. As such, we need to create a calendar that can plug itself into any system seamlessly without problems. Whether we are using Wordpress, Mambo/Joomla or Drupal, we should only need to insert one line into our code for the calendar to work. ie something like this:

require_once('quick_calendar.php');
?>

If you are already bored at this point or not interested to know how to create a web calendar, feel free to see a live demo of the simple calendar here. The installation procedures is in the source code.

Other than configuring the database access for the calendar, I do not want to change other things. With AJAX, I could even make the page static as I navigate between different months in the calendar. In this tutorial, I would like to share with you a simple calendar I created that fufills the objectives discussed above. The tutorial assumes that you have basic knowledge of PHP and SQL but don't worry, the actual code is minimal and you should be able to customise it easily by reading at the comments. I used PHP 4 so that it is compatible with most servers. You should also be able to re-create the calendar easily in other programming languages using the same logic.

The First Step: Problem Identification
Perhaps the hardest part in creating a calendar is to come up with a good solution to display the days of the month in the correct column, ie Monday, Tuesday..etc.

Apr 2006
Sun Mon Tue Wed Thur Fri Sat
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

Let us take April 2006 for example. There are 30 days and 6 rows in the calendar. If we are given a day in the month, say 15, we have to know that it falls on a saturday and is in the third row (third week). We cannot take for granted that the first day is always the first cell in the table (top left cell). Sometimes, we get 4 or 5 weeks in a month. Only if we know how many days are there in a certain month and which day the first of the month falls in only can we construct the calender as shown above.

Getting Crucial information From The PHP Date function
PHP provides a date() function that gives us alot of useful information about the days and months of the year. To built the calendar for any month, We need 2 important pieces of information from the Date function, ie the "number of days in the month" and a "numeric representation of the first day of the month".

I can get today's date easily from the following code:

// get year, eg 2006$year = date('Y');// get month, eg 04$month = date('n');// get day, eg 3$day = date('j');To get the number of days in this month, I will use the both the date and mktime function like so:

// get number of days in month, eg 28$daysInMonth = date("t",mktime(0,0,0,$month,1,$year));The numeric representation of the day of the week ranges from 0 to 6. 0 is sunday and 6 is saturday. Again, to get the numeric first day of this month, the function mktime comes in handy.

// get first day of the month, eg 4$firstDay = date("w", mktime(0,0,0,$month,1,$year));The Monthly Calendar As A 2-D Array
If we look at the calendar again for April 2006, we will see that it is actually a table(grid) filled with values starting from 1 to x (no of days in the month). The first day of the month is a variable though... It can occur in any day of the week. In the table, imagine each cell as having coordinates (x,y), starting from the top left cell as (0,0) and the bottom right cell as (5,6). In the month of April, the first day of the month is stored in coordinate (0,6). So, the plan now is to store the days of the month in a 2-D Array.

Firstly, we want to know the number of cells needed.

// calculate total spaces needed in array$tempDays = $firstDay + $daysInMonth;Then we want to know the number of rows needed.

// calculate total rows needed$weeksInMonth = ceil($tempDays/7);Populating The 2-D Array
Knowing the number of rows and columns in the 2-D array, we can now fill the arrays with values using 2 for-loops. The first cell will start with a value of 1 and the subsequent cells will have their values increased by 1 till it reaches the end of the array.

for($j=0;$j<$weeksInMonth;$j++) {
for($i=0;$i<7;$i++) {
$counter++;
$week[$j][$i] = $counter;
}
}
?>
For the month of April, the temporary array should be something like this:

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
The Magic Offset
As you can see, the array above is not correct. The first day of April, ie value 1 should be in (0,6) instead of (0,0). Remeber the variable $firstDay? It is the numeric representation of the first day of month which happens to be 6 in April 2006. If we subtract $firstDay from all the values in the array, we will get the array as follows:

-5 -4 -3 -2 -1 0 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 32 33 34 35 36

You should now be able to guess what we are going to do next. Looking at the array above, you see that we already got the values we want but we also have some unwanted values. Any number less than 1 or more than $daysInMonth (number of days in a month) should be ignored.

function fillArray() {
// create a 2-d array
for($j=0;$j<$this->weeksInMonth;$j++) {
for($i=0;$i<7;$i++) {
$counter++;
$this->week[$j][$i] = $counter;
// offset the days
$this->week[$j][$i] -= $this->firstDay;
if (($this->week[$j][$i] < 1) || ($this->week[$j][$i] > $this->daysInMonth)) {
$this->week[$j][$i] = "";
}
}
}
}
?>
This is the core function in the entire calendar generation algorithm.

Displaying The Calendar
Getting the values right in the 2-D array, we are now ready to display them. Now, we will create a table and start looping again using the foreach function.


$val) { echo ""; for ($i=0;$i<7;$i++) { echo ""; } echo "";}?>
Sun Mon Tue Wed Thur Fri Sat
$date

The final display will be like this:

Apr 2006
Sun Mon Tue Wed Thur Fri Sat
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

We now have a plain calendar.

Adding Special Dates To The Calendar
This calendar only tells you "the days of a week" at the moment and is not very useful. Most online calendar will have reminders as well. Say for example, if my birthday falls on the 4th of April, I want the number 4 in the calendar be displayed differently, possible with a hyperlink in which upon clicking on it, will perform some task like redirecting me to a certain page or displaying more information about myself in a popup windows..etc. To do that, we need to a table in the database with at least 6 columns: id, day, month, year, link, desc.

CREATE TABLE calendar (
id INT NOT NULL AUTO_INCREMENT ,
day VARCHAR( 2 ) NOT NULL ,
month VARCHAR( 2 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL ,
link VARCHAR( 255 ) NOT NULL ,
desc TEXT NOT NULL ,
PRIMARY KEY ( id )
);
We then need to insert some data into the table for testing:

INSERT INTO calendar ( id , day , month , year , link , desc )
VALUES (
'', '24', '*', '2006', 'http://www.sitecritic.net', 'Check your web cccount on the 24th of every month. 2006 only!'
), (
'', '5', '11', '2006', 'some_javascript_funtion', 'Olympics, remember to buy ticket from alice.'
),(
'', '2', '1', '2007', 'some_javascript_funtion', 'early 2007. Any new plans for the year?'
), (
'', '9', '*', '*', 'http://www.evolt.org', 'Remember to check updates from evolt.org every month.'
);
The * under the month or year column means every month or year.

Next, we do a query and extract the important dates for a certain month and store it in an array.

$sql = "SELECT * FROM calendar WHERE (month='$month' AND year='$year') || (month='*' AND year='$year') || (month='$month' AND year='*') || (month='*' AND year='*')";
$rs = $db->query($sql);
while ($rw = $rs->fetchRow()) {
extract($rw);
$links[] = array('day'=>$day', 'month'=>$month, 'year'=>$year, 'link'=>$link, 'desc'=>$desc);
}
?>
If we create a class to generate the calendar, we need to pass the $links array into the class like so:

$cal = &new Calendar($cArray, $today, $links, $css);
$cal->render();
?>
The $cArray is a class containing the array for the plain calendar as shown in step 6. The $today variable is today's date. The $links variable contains the important dates in this month. With the $css variable, we can decorate the calendar table and make it look nicer.

Adding AJAX Capability
To make the calendar more user friendly, we want to be able to navigate easily between the months or years without refreshing the page. Thanks to AJAX, we can now do that easily. If the user clicks on "next month" for example, we need to call the AJAX function to refresh the calendar without refreshing the page. We do that using XMLHttpRequest. This is the main code that does the trick.

http.open('get', 'quick_calendar.php?m='+m+&y='+y+'&ran='+ran_no);After I get a response from the AJAX function, i need to update the calender. The calendar is wrapped around with the div tag called 'quickCalender'. I just need to rewrite the contents of the tag on the fly.

document.getElementById("quickCalender").innerHTML = http.responseText; Conclusion and Future Improvements
In this tutorial, we went through the concept of how to create a web calendar using AJAX and PHP. I left the details in the code to prevent the tutorial becoming too long and indigestable. If you look at the code hard enough, you will notice that I packed alot of codes in one file. As a good programming practice, I should have broken them down into smaller parts/files. Because the objective of this project is to create a quick "plug and forget" calendar system, I did that on purpose.

Also, the object oriented approach I used in the code may not be flexible enough if I want to have different layouts for the calendar. The problem can be easily fixed by using inheritance, ie creating a superclass for the QuickCalendar class. We can then have BrownCalendar, SpecialCalendar ...etc.

Hope you enjoy reading this tutorial as much as I wrote it. The full demo can be seen here and source code is here.

Bernard Peh specialises mainly in SEO and PHP programming. He is also the web developer behind Sitecritic.net Web Design. During his free time, he maintains his melbourne web developer blog.
52 comments on this article. Log in to add your comment | Rate this article:

dcal
Submitted by Douglas Clifton on November 14, 2006 - 21:59.

dcal is a PHP calendar I wrote a few years ago. It will display any year or month from 1970 to 2037 and includes holidays, moon phases, the vernal and autumnal equinox, summer and winter solstices, and some other goodies including a slick JavaScript slider interface for jumping directly to a particular month.
login or register to post comments

Hi Bernard, just so you know
Submitted by dmackinn on November 23, 2006 - 16:19.

Hi Bernard, just so you know the source code and the demo links appear to be broken.
login or register to post comments

Great Article
Submitted by cianuro on November 23, 2006 - 20:24.

Great article Bernard. Although there are many perfectly decent calendar apps already out there made by the big guys, it's nice to follow along the creative process. And it seems the URLs are fied now. Regards Dave
login or register to post comments

There's a problem...
Submitted by daiBach on November 30, 2006 - 17:22.

If you are in December and try to navigate back one month then the year gets incremented as well e.g. moving from Dec 06 to Nov 06 actually brings up Nov 07.
login or register to post comments

changes to the script
Submitted by bpeh on December 2, 2006 - 10:02.

thanks all esp daibach for pointing out the error, I've updated the script: php calendar. I emailed the admin with the changes but it wasnt updated. I did a typo with the link in the first paragraph. The link in last paragraph is fine.
there is also an extended version http://web-developer.sitecritic.net/quick_calendar_demo2.php

the source code is http://web-developer.sitecritic.net/quick_calendar.txt

login or register to post comments

Good script. On your
Submitted by bichenoubi on December 4, 2006 - 06:39.

Good script. On your website, on the simple version, there is still errors if you go back and froth a couple of time between dec 2006 and jan 2007. On the extended version, there is no problem. One advice, even thought this is not the point of the article, for accessibility reasons, you should remove the hre f = "java script:; "(errors only for evolt filter) and replace it with the ajax function, eg: hre f="quick_calendar2.php ? m=11&y=2006"(errors only for evolt filter). You will only have to change a bit the php code to find a new way to send only calendar html code for your ajax functions (i.e. your already there random var?).
login or register to post comments

thx for your script.but your
Submitted by jabky on December 4, 2006 - 08:30.

thx for your script.but your source code up there are not like your extended version. and i try to change like gichenoubi said but it still doesn't work for me. i'm the newbie in ajax
login or register to post comments

Some quickCalendar fixes
Submitted by kirk837 on January 5, 2007 - 07:13.

1. To fix the Jan->Dec problem in the "simple" version: In createHeader(), in elseif ($prevMonth==0){, need to add the forgotten statement $prevMonth=12;

2. The "jumpiness" of dates in calendar body when changing month to month is fixed by css changes:

td {height: 22px; border: 0px;
.today and .link {padding: 1px;
Jumpiness of the entire page is improved by setting weeksInMonth (in CreateQCalendarArray) to 6 (this sometimes leaves a blank bottom week, but it keeps the rest of the page from jumping).
3. I found it necessary to initialize the links[] array to '' prior to filling it in the "while mysql_fetch_array" loop, to avoid empty array errors at the foreach loop in createBody. Don't know why this isn't a problem for the posted demo.

4. Each next/previous month or year causes the entire css to again be written to the page, making the page increasingly large (to see this, save the page and examine in an editor). Here's a fix: Place css in quick_calendar.css; in function createHeader, read in the css within the "class=calendar" table with fread:

$this->html = "
";
$this->html .= fread(fopen($this->cssfile,'r'),filesize($this->cssfile));
$this->html .= " ... "
(where $cssfile='quick_calendar.css', passed to function QCalendar through added parameter cssfile; in QCalendar, $this->cssfile=cssfile).

5. Along with quick_calendar.txt (the "simple" version), it would be nice if Bernard would post quick_calendar2.txt for the "advanced" version. (I have done my own; I'd like to compare notes.) It would also be nice if Bernard would fix the erroneous "we-developer" links on this page.

login or register to post comments

Some quickCalendar fixes - continued
Submitted by kirk837 on January 5, 2007 - 23:23.

6. Every change of month or year creates another
around the calendar. (To actually see this, use FireFox with Firebug and set Outline Blocks.) To avoid this, remove from $this->html = " in createHeader(), and remove at the very end of createFooter(). To place a calendar on a (.php) page, surround the php with a div:




(This is only slightly less "quick" than the php-only statement.)
7. Also, throughout css, "a:link" should be "a.link" (Now I can get rid of those underlines!)

login or register to post comments

Starting with Mondays
Submitted by a1phanumeric on January 12, 2007 - 15:05.

You can easily update this script to start with Mondays (therefore having Sat and Sun together at the end of the table) by changing:







to...







and adding:
// Start with Monday
if($firstDay == 1){
$counter = 1;
}
?>
before the
for($j=0;$j<$this->weeksInMonth;$j++) {
for($i=0;$i<7;$i++) {
$counter++;
...
?>
loop Simple! Ed.
login or register to post

Flat Button in VB

0 comments

How do we implement a Flat Button?

Well, let's describe step by step how we can create a usercontrol that behaves as a flat button. From VB open a new ActiveX project and save it as MyFlatButton.ctl.


Open a new ActiveX control project

Events "MouseDown" and "MouseUp" will help us to draw the edge sunken or raised when the user mouse-clicks the usercontrol. When the MouseDown event is fired we will draw a sunken edge. When the MouseUp event is fired we will draw a raised edge. This is when we should take the first decision: do we draw the edge directly from the mouse event? or should we call the Paint event instead? Is there a difference? The answer is yes, there's a big difference! Always try to have as little code as you can in procedures that are message consumers. The more code we add to the MouseDown message the slower our application will process mouse events. It is a better approach to put all drawing code in the Paint event and let the MouseDown and MouseUp events flow faster.

Let's see this with more detail. If we were drawing the button edge directly from the MouseDown event we would code something like:

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Call pDrawEdgeSunken
End If
End Sub

Where pDrawEdgeRaised would be a procedure that draws the usercontrol edge with a sunken style. On the other hand, if we just call the Paint event our code would be:

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
m_MouseDown = True
Call UserControl_Paint
End If
End Sub

Where m_MouseDown is a boolean flag we've created to let the rest of the code know when the mouse is down. The UserControl_Paint event will have all necessary drawing code. What's the difference? well, the first version is calling procedure pDrawEdgeSunken and therefore the MouseDown event will not finish until pDrawEdgeSunken does. On the other hand, the second version calls UserControl_Paint and doesn't wait for this procedure to finish (Paint is an event procedure). It just posts a message WM_PAINT to itself and quits. This second version is more efficient and would not convert the MouseDown procedure in a potential "bottle-neck".

Using this second approach we are now going to create the first version of our flat button. You can paste the following code into your usercontrol:

Option Explicit

Public Event Click()

Private m_MouseDown As Boolean
Private m_MouseOver As Boolean
Private m_ClientRec As RECT

'API declarations:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Const BDR_RAISEDINNER = &H4
Private Const BDR_SUNKENOUTER = &H2
Private Const BF_RECT = &HF

Private Declare Function DrawEdge Lib "user32" ( _
ByVal hdc As Long, _
qrc As RECT, _
ByVal edge As Long, _
ByVal grfFlags As Long) As Long

Private Declare Function GetWindowRect Lib "user32" ( _
ByVal hwnd As Long, _
lpRect As RECT) As Long

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
m_MouseDown = True
Call UserControl_Paint
End If
End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not m_MouseOver Then
m_MouseOver = True
UserControl_Paint
End If
End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
m_MouseDown = False
UserControl_Paint
RaiseEvent Click
End If
End Sub

Private Sub UserControl_Resize()

GetWindowRect UserControl.hwnd, m_ClientRec

'Transform from screen to client coordinates
With m_ClientRec
.Right = .Right - .Left
.Bottom = .Bottom - .Top
.Left = 0
.Top = 0
End With

UserControl_Paint

End Sub

Private Sub UserControl_Paint()

Dim lEdge As Long

If Not UserControl.Ambient.UserMode Then
m_MouseOver = True
End If

UserControl.Cls

lEdge = 0

If m_MouseOver Then
If m_MouseDown Then
lEdge = BDR_SUNKENOUTER
Else
lEdge = BDR_RAISEDINNER
End If
DrawEdge UserControl.hdc, m_ClientRec, lEdge, BF_RECT
End If

'
'Add your code here to draw the picture and caption...
'

End Sub

Let's review this code before we test it. As you can see, MouseUp and MouseDown only check whether the right mouse button has been pressed and they both set the flag m_MouseDown to either True or False depending on the event. MouseMove only takes care of flag m_MouseOver and all three events call Paint to force a re-painting of the object. Resize is responsible for getting the size of the client area - using the API GetWindowRect - and also forces a re-paint. Finally the Paint event clears the usercontrol and draws the appropriate edge based on the values of m_MouseOver and m_MouseDown. Easy, isn't it?

We can now test the usercontrol. If we do so, we can see that the control first shows flat. Then, as soon as the mouse enters its client area, the control shows raised. We can now start clicking the button and the edge turns sunken when we down-click and it turns back to raised when the mouse is released.

Good, it seems to work! There are only two remaining problems:
1. The edge doesn't show flat when the mouse leaves the button.
2. The push-pop effect seems to be wrong if we mouse-click quickly.

In the next section I'm going to discuss how these two problems can be solved.


Trapping messages to solve flat button "issues"

The first question that arises is: how can we know when the mouse leaves the button? In March 1997 Microsoft published the source code of a flat button implemented with Visual Basic. The project was called Visual Basic Soft Button Sample. Since then, many soft buttons have appeared on the net and I would say all share the same technique: they use APIS SetCapture and ReleaseCapture in order to detect when the mouse leaves the button.

How does this solution work and what sort of problems does it have? Basically the solution presented by Microsoft is based on capturing the mouse when the mouse gets into the button client area. Using SetCapture, it holds the mouse until detects that it has moved outside of the button to then release it. Sounds logical? I think it is a very good approach. So what's the problem then? Well, I would say the implementation of this solution has mainly two problems:

1. SetCapture only allows one window to be holding the mouse.
2. MouseMove event will have to release and capture the mouse every time this event is fired.

We'll better understand this if we have a code sample. If we were using SetCapture and ReleaseCapture we would have to modify the MouseMove event with the following code:

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

ReleaseCapture

If X >= 0 And _
Y >= 0 And _
X <= UserControl.ScaleWidth And _
Y <= UserControl.ScaleHeight Then

SetCapture UserControl.hwnd

m_MouseOver = True

UserControl_Paint
End If

End Sub

After calling the SetCapture API, all mouse messages, no matter where the mouse is, are posted to our window. It would be more logical if we just call SetCapture the first time we detect the mouse has entered the button area and call ReleaseCapture only once too, as soon as we detect that the mouse has left the button. We can't! Why? because only one window can hold the mouse by calling SetCapture. If an external application/code calls SetCapture while the mouse is over the button, we would lose its messages and we would never know when to call ReleaseCapture and draw the edge flat again. Therefore, the solution is based on releasing and capturing the mouse every time the user moves the mouse over the button. Not very efficient and still containing potential problems...

There's a better way to detect when the mouse leaves the button: using API TrackMouseEvent and WM_MOUSELEAVE message. TrackMouseEvent can be used to ask the system to track the mouse for us and post a WM_MOUSELEAVE message as soon as the mouse leaves our window area. It is a cleaner and more efficient approach but, how can we detect the WM_MOUSELEAVE message? We're going to use the SmartSubclass library to trap all messages posted to the usercontrol. You will have to add a reference to SmartSubclass.dll, as described in the article, and you'll be able to create a SmartSubclass variable. You'll find another example on how to use this class in Trap the Mouse!

Add the following code to the usercontrol:

Private WithEvents m_Sniff As SmartSubClass

Private Type TrackMouseEvent
cbSize As Long
dwFlags As Long
hwnd As Long
dwHoverTime As Long
End Type

Private Const WM_MOUSELEAVE = &H2A3
Private Const TME_LEAVE = &H2

Private Declare Function TrackMouseEvent Lib "comctl32.dll" Alias "_TrackMouseEvent" ( _
ByRef lpEventTrack As TrackMouseEvent) As Long

Private Sub UserControl_Initialize()
Set m_Sniff = New SmartSubClass
m_Sniff.SubClassHwnd UserControl.hwnd, True
End Sub

Private Sub UserControl_Terminate()
m_Sniff.SubClassHwnd UserControl.hwnd, False
End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim tTrackMouseEvent As TrackMouseEvent

If Not m_MouseOver Then

With tTrackMouseEvent
.cbSize = Len(tTrackMouseEvent)
.dwFlags = TME_LEAVE
.hwnd = UserControl.hwnd
End With

TrackMouseEvent tTrackMouseEvent

m_MouseOver = True
UserControl_Paint
End If

End Sub

Private Sub m_Sniff_NewMessage( _
ByVal hwnd As Long, _
uMsg As Long, _
wParam As Long, _
lParam As Long, _
Cancel As Boolean)

Select Case uMsg
Case WM_MOUSELEAVE
m_MouseOver = False
UserControl_Paint
End Select

End Sub

If you add the code to your usercontrol and you test it again, you will see that the button turns flat again as soon as the mouse leaves its client area. We've had to call TrackMouseEvent just once and when our 'sniffer' gets the WM_MOUSELEAVE message, it sets the m_MouseOver flag to False and forces a control re-painting.

I honestly prefer TrackMouseEvent to SetCapture, basically because we don't get conflicts with other windows, we rely on the system to track the mouse position and we don't need to over-charge the MouseMove event.

Now let's go back to our usercontrol. If you remember there's still a remaining problem: The "push-pop" effect seems to be wrong if we click the button fast. I describe this problem with more details in Trap the mouse!. I will only tell you that this problem is due to receiving DblClick rather than MouseDown. To fix the problem we need to get rid of the DblClick event and get MouseDown instead.

Add the following code to the usercontrol:

Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201

Private Sub m_Sniff_NewMessage( _
ByVal hwnd As Long, _
uMsg As Long, _
wParam As Long, _
lParam As Long, _
Cancel As Boolean)

Select Case uMsg
Case WM_MOUSELEAVE
m_MouseOver = False
UserControl_Paint

Case WM_LBUTTONDBLCLK
uMsg = WM_LBUTTONDOWN
End Select

End Sub

You can now click the flat button as fast as you want. You will always get the right "push-pop" effect. We've used our "sniffer" to get the WM_LBUTTONDBLCLK message and replaced it with a WM_LBUTTONDOWN. It couldn't be easier!

The flat button has now a very solid structure. We can only add enhancements to it. In the next section I will describe how we can make the flat button post click events when we hold the mouse down-clicked.


How can we make the flat button simulate repeated clicks?

When you hold the mouse down-clicked on the button you will get only one MouseDown message. You need to release the mouse and down-click again in order to receive the next MouseDown message. This could be a problem if we would like to use our flat button on the implementation of let's say a viewport control. The user may want to scroll the viewport area by holding the mouse down on the flat button. Makes sense. So how can we do that if Windows sends only one message? We will need to do it ourselves!

We need a timer. Actually we need two timers! We could use the Timer control that comes with Visual Basic, but we're going to use API calls. Why? because it is a good way of learning Windows core functions!

Once the user down-clicks the button we need a timer to control when to start posting Click events and we need another timer to control the frequency of this posting. Windows provides two very good timer functions, SetTimer and KillTimer, and a timer message WM_TIMER.

In order to implement the repeated click you should add the following code:

Private Const m_TimerDelay = 1
Private Const m_TimerLapse = 2
Private Const m_RepeatDelay = 250
Private Const m_RepeatLapse = 125

Private Const WM_TIMER = &H113

Private Declare Function SetTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Private Declare Function KillTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long

Private Sub m_Sniff_NewMessage(ByVal hwnd As Long, uMsg As Long, wParam As Long, lParam As Long, Cancel As Boolean)

Select Case uMsg

Case WM_MOUSELEAVE
m_MouseOver = False
UserControl_Paint

Case WM_LBUTTONDBLCLK
uMsg = WM_LBUTTONDOWN

Case WM_TIMER
Select Case wParam
Case m_TimerDelay
KillTimer UserControl.hwnd, m_TimerDelay

If m_MouseDown Then
SetTimer UserControl.hwnd, m_TimerLapse, m_RepeatLapse, 0
End If
Case m_TimerLapse
If m_MouseDown Then
RaiseEvent Click
End If
End Select

End Select

End Sub

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = vbLeftButton Then
m_MouseDown = True
UserControl_Paint

If m_RepeatDelay > 0 Then
SetTimer UserControl.hwnd, m_TimerDelay, m_RepeatDelay, 0
End If
End If

End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = vbLeftButton Then
m_MouseDown = False

KillTimer UserControl.hwnd, m_TimerDelay
KillTimer UserControl.hwnd, m_TimerLapse

UserControl_Paint

RaiseEvent Click
End If

End Sub

Now the flat button starts waiting m_RepeatDelay milliseconds once the user down-clicks. After this time it will start posting Click events every m_RepeatLapse milliseconds.

Let's review the solution: we've modified MouseDown to program the first timer (m_TimerDelay). When the "sniffer" gets a WM_TIMER message it checks for its timer ID. If it is the first timer, the delay lapse has expired and it programs the second timer (m_TimerLapse). It also kills the first timer. Otherwise, if the WM_TIMER message belongs to the second timer, it posts a Click event (the user is holding the mouse down). Finally, the MouseUp event only has to kill both timers.

Well, that's it! Now you have a flat button working that only needs extra properties like Caption, Font, Picture, ForeColor... I will leave it up to you to implement the enhancements.

Format numbers in VB

0 comments

This is a FAQ for VB Beginners that deals with the problem of numbers that have more digits after the decimal point than you want to use or display.

Topics covered are:


a. Use the "Fixed" Format and Format$
b. Use the "Standard" Format and Format$
c. Use Format$ and your own settings
d. Use FormatNumber
e. Use the Round Function

Sometimes calculations in your project will result in numbers with a lot of decimal places - users input numbers with multiple digits after the decimal point or the calculation throws up a long list of decimal digits that you don't want or need you want to restrict these numbers to, say, 2 decimal places, here are a few ways you can do this:


a. Use the "Fixed" Format and Format$

This example takes a user input from a textbox and performs a calculation on it. The result, correct to 2 decimal places, is shown in a label. If your project needs are different, you can adapt the code as necessary.

Add a textbox (Text1), a commandbutton(Command1) and a Label (Label1) to a form, then copy and paste this code:-

Code:Option Explicit
Dim lngDemoNo As Double

Private Sub Form_Load()
Text1 = 123764.76464646 ' You can change this at run time if you want
lngDemoNo = Text1 * 3.142 ' Create some demo data
End Sub

Private Sub Command1_Click()
' For demo purposes, display the result
Label1 = "Your Input Number * Pi = " & Format$(lngDemoNo, "Fixed")
End Sub


b. Use the "Standard" Format and Format$

The only difference to the above is that this will insert commas if the value of the number is greater than 999 (ie. 1,000.00 instead of 1000.00).

You can recyle the code example above and just change the code line in the Command1_Click event to:

Code:Label1 = "Your Input Number * Pi = " & Format$(lngDemoNo, "Standard")


c. Use Format$ and your own settings

You can force the result to appear in whatever format you like by using Format$ and creating the settings yourself. Re-use the first example and change the code line in the Command1_Click Event to:

Code:Label1 = "Your Input Number * Pi = " & Format$(lngDemoNo, "0.000")

Notice that I have put three zeros after the decimal point, so the resulting label display is shown correct to three decimal places. You can, of course, change this to whatever suits your purposes.


d. Use FormatNumber

You can also use the FormatNumber Function provided by VB. This function will accept several arguments that can be used to present a number in different ways, but we will just use one in this FAQ.

Once again, replace the Command Button code line with this one:

Code:Label1 = "Your Input Number * Pi = " & FormatNumber(lngDemoNo, 3)

The "3" digit is the number of decimal places to use. Again, you can change this to whatever you want.


e. Use the Round Function

Similar to most of the above options, the Round Function will return a value set to the number of places you decide and will round the last digit up or down.

The replacement code line in this case is:

Code:Label1 = "Your Input Number * Pi = " & Round(lngDemoNo, 2)

So there you have various ways of achieving the same thing – dictating how many digits you want to have after the decimal point.

Solaris interview questions

0 comments

Solaris interview questions -1

View More Questions

View more
View more
View more


List the files in current directory sorted by size ?
- ls -l | grep ^- | sort -nr

List the hidden files in current directory ? -
- ls -a1 | grep "^\."

Delete blank lines in a file ?
- cat sample.txt | grep -v ‘^$’ > new_sample.txt

Search for a sample string in particular files ?
- grep “Debug” *.confHere grep uses the string “Debug” to search in all files with extension“.conf” under current directory.

Display the last newly appending lines of a file during appendingdata to the same file by some processes ?
- tail –f Debug.logHere tail shows the newly appended data into Debug.log by some processes/user.

Display the Disk Usage of file sizes under each directory in currentDirectory ?
- du -k * | sort –nr (or) du –k . | sort -nr

Change to a directory, which is having very long name ?
- cd CDMA_3X_GEN*Here original directory name is – “CDMA_3X_GENERATION_DATA”.

Display the all files recursively with path under current directory ?
- find . -depth -print

Set the Display automatically for the current new user ?
- export DISPLAY=`eval ‘who am i | cut -d"(" -f2 | cut -d")" -f1′`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.

Display the processes, which are running under yourusername ?
- ps –aef | grep MaheshvjHere, Maheshvj is the username.

List some Hot Keys for bash shell ?
- Ctrl+l – Clears the Screen. Ctrl+r – Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a – Places cursor at the beginning of the command at shell. Ctrl+e – Places cursor at the end of the command at shell. Ctrl+d – Kills the shell. Ctrl+z – Places the currently running process into background.

Display the files in the directory by file size ?
- ls –ltr | sort –nr –k 5

How to save man pages to a file ?
- man | col –b > Example : man top | col –b > top_help.txt

How to know the date & time for – when script is executed ?
- Add the following script line in shell script.eval echo "Script is executed at `date`" >> timeinfo.infHere, “timeinfo.inf” contains date & time details ie., when script is executed and history related to execution.

How do you find out drive statistics ?
- iostat -E

Display disk usage in Kilobytes ?
- du -k

Display top ten largest files/directories ?
- du -sk * | sort -nr | head

How much space is used for users in kilobytes ?
- quot -af

How to create null file ?
- cat /dev/null > filename1

Access common commands quicker ?
- ps -ef | grep -i $@

Display the page size of memory ?
- pagesize -a

Display Ethernet Address arp table ?
- arp -a

Display the no.of active established connections to localhost ?
- netstat -a | grep EST

Display the state of interfaces used for TCP/IP traffice ?
- netstat -i

Display the parent/child tree of a process ?
- ptree Example: ptree 1267

Show the working directory of a process ?
- pwdx Example: pwdx 1267

Display the processes current open files ?
- pfiles Example: pfiles 1267

Display the inter-process communication facility status ?
- ipcs

Display the top most process utilizing most CPU ?
- top –b 1

Alternative for top command ?
- prstat -a

login to a windows domain from linux

0 comments

for an NT domain, you should have the following in your smb.conf:
netbios name = SAMBA
workgroup = EVALUESERVE
security = domain
password server = IP_address_of_your_DC

you should then be able to do something like:
smbpasswd -j EVALUESERVE -r IP_address_of_your_DC -U NT_ADMINISTRATOR

Windows Active directory
First, make sure kerberos is installed:
# rpm -qa grep krb
this should return at least 3 packages: krb5-devel, krb5-libs and krb5-workstation Next, make sure the ldap development libraries are installed:
# rpm -qa grep ldap-devel
If either of these returns nothing, you'll need to install them - which you can do from the Redhat CD.
make sure there's an entry for your active directory DC in your /etc/hosts file: 1.2.3.4 addc.example.com addc
Next, edit your /etc/krb5.conf to match your site. Everything should be fairly self-explanitory - and everything is case sensitive. Do not comment this file.
Once you've gotten to this point, you can try:
# /usr/kerberos/bin/kinit user@DOMAIN.COM
replacing *user* with a real user and DOMAIN.COM with a real domain (which must be UPPERCASE). If things are working, you'll be prompted for a password. If you enter the correct password, you'll come back to a bash shell, if not, you should be presented with:
"kinit(v5): Preauthentication failed while getting initial credentials"
or some such.
Note: If the clock time on the Linux machine is more than 5 minutes off from the time on the windows machine no ticket information will work. There are three wys to deal with this:
1. Have the Linux server act as a network time server, with the windows machine as a client
2. Have the windows machine act as a time server for the linux client
3. Make both systems pull the time from the same 3rd server ( some are listed here - http://ntp.isc.org/bin/view/Servers/NTPPoolServers )

Next, uninstall samba if it's installed:
# rpm -e samba
get the latest version of samba:
$ wget http://us1.samba.org/samba/ftp/samba-latest.tar.gz
expand and install samba:
$ tar -zxvf samba*.tar.gz
$ cd samba-3.0.13
$ ./configure --prefix=/usr/local/samba --with-ldap --with-ads --with-krb5 --with-pam --with-winbind
# make && make installIn
your smb.conf:
----8<-----
netbios name = LINUX_SERVER_NAME
realm = DOMAIN.COM ads server = 123.123.123.123
security = ADS
encrypt passwords = yes
----8<-----
start samba:
# /etc/rc.d/init.d/smb start
To add the linux computer to the AD, you need to log into the DC and add it as a user with such privledges, so (from the Linux system):
# /usr/local/samba/bin/net ads join -U Administrator
it should prompt you for Administrator's password. Note that Administrator should be a user with the right to add a computer to the AD.
you should see something like:
Joined 'LINUX_MACHINE_NAME' to realm 'DOMAIN.COM'

To verify this worked, go to the windows DC and open Active Directory->Users and Computers and look for your linux machine to be listed there.
That's all you absolutely need to connect to the AD. If you want to map users to the AD (which is probably why you're doing this), open /etc/nsswitch.conf and change this:
passwd: files
shadow: files
group: files
to this:
passwd: compat winbind
shadow: compat
group: compat winbind
start the winbind daemon:
# winbindd
make sure it's running:
# ps -ae grep winbindd
if nothing gets returned, you probably didn't configure samba with kerberos and ldap support. If it shows winbindd running, you're all set. To make sure everything starts on reboot:
open /etc/rc.d/init.d/smb and /etc/rc.d/init.d/winbindd and make sure the line:
# chkconfig: 345 NN NN exixts (NN will be different numbers pertaining to priority), it should be on line 3 of both files. if these lines don't exist, add them. If they read:
# chkconfig: - NN NN change the - to 345 save and close those files and run chkconfig:
# chkconfig smb reset
# chkconfig winbindd reset you can check the runlevels they will start at with # chkconfig smb --list
# chkconfig winbindd --list
That should about cover everything.

Samba Config

0 comments

Samba is a suite of applications and daemon processes used on *nixmachines primarily for communicating with win* machines for sharingfilespace and printers.
Samba is a suite of applications and daemon processes used on *nixmachines primarily for communicating with win* machines for sharingfilespace and printers. Developed by a Pizza Lover, Andrew Tridgell,Samba is based upon SMB (Server Message Block) protocol whichdescribes rules for communication among various machines on a network(for sharing filespace and printers). If you still don't understandwhat SMB protocol is, just launch Network Neighborhood (assuming youwork on windows), and what you see is a live demonstration of SMBprotocol. So, you can call Samba network neighborhood of *nix (Assuch, I prefer it the other way round ;-). Samba's flexibility andfunctionality are unmatched and it's performance has been a matter ofconcern for M$. Apart from sharing filespace and printers, it offerssome more services like.. (I'll be surprised if I have come up with acomplete list ;-)
1. It can act as a Local Browse Master for a Workgroup. Supportsdomain logon and logon scripts. Supports browsing on other subnetsand also supports replication of Browse list across subnetboundaries. (Phew!!)2. It supports a 'Shared User Database' with all the servers in adomain sharing a distributed NIS or kerberos authenticationdatabase.3. It can act as a WINS server.4. It supports SMB password encryption scheme.5. It can be turned into a Fax Server.6. It can take backup of PCs directly to a tape.I come back to the focus point of this article now; sharing filespaceand printers using Samba. Hmmmmm. I think the discussion can bebranched into sharing your filespace and printers with others andsharing others filespace and printers with yours.Sharing your filespace and printers with others:This is accomplished in terms of services (shares in windows). Theconcept is simply that your machine offers services to other machineswhen it lets them read from/write to your drive or when it lets othersprint on your printer. Services are created by configuring/etc/smb.conf (In fact, smb.conf is the backbone of Samba Suite).Samba offers so much flexibility in making the services that it can bereal fun for a creative mind. This is accomplished by the followingcomponents of Samba suite....smbdsmbd is a daemon process that plays key role in providingservices. It listens to the service requests from othermachines and responds as specified in /etc/smb.conf (got theimportance of this file? ;-)nmbdnmbd is a daemon process that understands and replies tonetbios name service requests. Whenever its own name (themachine it's running on) is specified, it responds with the IPaddress of the machine it's running on.smb.conf This is the configuration file for Samba. All daemon processesof Samba suite read this file which makes it extremelyimportant. I advise you to go through man pages and how-tosbefore you sit down to edit this file. If you don't feel likedoing it, I have made an attempt of writing a generic file thatshould satisfy your needs. You can use it but the condition isthat you will have to tell me how bad it is so that others findit a little less bad ;-).testparmOnce smb.conf is edited to meet your requirements, you have tocheck it's validity. Here testparm comes for your rescue!! Itcan point out most of the blunders that your smb.conf is likelyto cause.testprnsThis one points out printing related blunders.Sharing others filespace and printers:This is accomplished by a host of commands...smbclientsmbclient lets you inquire about the services a machine offers.All you have to do is smbclient -L hostname and it lists allthe services of hostname. If you want to browse through aservice, just do smbclient \hostservice. It will give youan ftp like interface.smbmountCall it mapping hostservice on drive U:!! You need to accesssome services quite frequently. smbclient is good for quickbrowsing but not feasible in such a case. So, here comessmbmount. It lets you mount hostservice on a directory justthe way you mount any filesystem. Just do smbmount//host/service /path_to_mount_point and it's done. Access thefiles/printers just as they are attached to your machine!!!smbumountWell, it's obvious!! You may want to unmount the filesystemonce you are through with your job. Just do smbumount/path_to_mount_point and ....nmblookupIt finds the IP Address of a machine given it's netbios name(the name by which a machine appears in Network Neighborhood).LinNeighborhood Just don't forget to pick it up. It's a do-all application witha nice GUI for Samba. A pretty good substitute of the abovefour commands if you find command line a little messy!!"What about Network Neighborhood?", They asked.I smiled and launched LinNeighborhood....Besides these, there are a few other, distribution specific commandswhich I have not described. Please refer to the documentation thatcame with your distro."So, you have Network Neighborhood also on Linux!!", they mumbled.

Samba NT Domain Controller

0 comments

Currently, Samba can go beyond merely emulating Windows shares to actually acting as the Primary Domain Controller for your Windows network. Of course, Samba can also become a NT domain member. In this article we shall look at both these options.
The domain concept is much better than the traditional workgroup concept. One of the primary benefits is having a centralized password database on the Primary Domain Controller. Once authenticated, you can access any of the shares in the domain, without having to re-authenticate yourself.
If you're unfamiliar with Samba, then we've got a couple of good howto's that you can refer to. Look for links to them at the bottom of the article.
Samba as a NT Domain Member
Samba emulates a NT workstation when becoming part of the domain. So, the first thing you need to do is create a machine account for your Samba machine on the domain controller. In NT you would use the program Server Manager for Domains to create the account. Once the account is created, all you need to add are the following lines to your smb.conf file under the global section.
# Your Workgroup or Domain that you want
# to login to
workgroup = FREEOS
# Tell Samba to talk to domain controller
# for authentication
security = domain
# Specify the server to get authenticate
# from. You can specify the
# NetBIOS # names of the servers or simply
# put in a "*" here to let
# Samba find the server through broadcast
password server = PS1 PS2
# Make sure Samba is using encrypted
# passwords
encrypt passwords = yes
Now stop the Samba daemons
/etc/rc.d/init.d/smb stop
Give the following command to join the
NT Domain
smbpasswd -j DOMAIN -r DOMAINPDC
DOMAIN here is the domain that you want to log on to. DOMAINPDC is the primary domain controller for that domain. You will then see a message saying, “Joined domain DOMAIN”.
Now start your SMB and NMB daemons.
/etc/rc.d/init.d/smb start
That was all about joining an NT domain. Setting up Samba as your Primary Domain Controller is not very difficult.
Samba as Primary Domain Controller
Add the following to the global section of your smb.conf file.
# The domain you want to be a PDC for
workgroup = SIMPLE
# Tell Samba to use domain logons
domain logons = yes
# User-level security. Users must
# authenticate themselves with
# valid username and password
security = user
# Set to yes so that nmbd participates
# in local master browser
# elections
local master = yes
# Set Os level value to make sure nmbd
# wins local browse master
# elections. 65 should beat everyone
# according to the man page
os level = 65
# Give nmbd an advantage in local
# master browser elections
preferred master = yes
# Set so that nmbd claims a unique
# NetBIOS name identifying it as
# a domain master
domain master = yes
# The following share is required to support
# domain logons. The directory may be
# created anywhere on your system. Make
# sure the share is non-writeable and also
# not a public share.
[netlogon]
comment = The domain logon service
path = /usr/local/samba/netlogon
public = no
writeable = no
The next thing to do is create the users on the Samba server that is to act as the domain controller. You can do this using the useradd command.
useradd –-g smbuser –-d /dev/null –-s /dev/null ntuser
As you can see, both shell and home directory for ntuser is set to /dev/null. If your Windows users are not required to access the Unix box, you should use the above to deny access to the machine. Passwords are also not required to be set because Samba keeps the password hash in a separate file specified in the configuration file.
# Path to Samba password file
# Make sure only root has read/write access
smb passwd file = /usr/local/samba/smbpasswd
After adding a user (you can also use vipw to add a user), you need to add the user to the samba password database.
“smbpasswd –a” will add all users in Unix passwd file to smbpasswd file. The usage and syntax is similar to the Unix passwd command. To change a users’ password use “smbpasswd username”.
That will be enough for Samba to start authenticating Windows 9X clients. For NT workstations, some more work is to be done. You have to create a machine account for each NT client that will logon. A machine account is simply a regular /etc/passwd entry, with a “$” appended to the name of the NT machine.
useradd –-g smbuser -–d /dev/null -–s /dev/null ntclient$
Now add it to the password database
smbpasswd –a –m ntclient (the $ at the end is not required)
Samba can now accept logons from a NT client.
As you can see, configuring samba as a domain controller and domain member is a fairly easy job. The flip side is that since samba is the result of major amounts of hacking and reverse engineering, it doesn’t have all the functionality of a proper domain controller. There is an alternative branch, Samba TNG that adds more functionality in this area.

Sun Mon Tue Wed Thur Fri Sat Mon Tue Wed Thur Fri Sat Sun