Wednesday, 22 January 2014
Batch File Concepts
BATCH FILE:
These are simple text files containing some lines with commands that get executed in sequence, one after the other. These files have the special extension BAT or CMD.
C PROGRAMMING TRICKS
C Programming Tricks:
1.
Always try to compare like
if ( 0 == i )
rather than
if ( i == 0)
In this way you can catch error for unintended assignments like
if ( 0 = i) .
2.
Dont use strlen in a loop condition:
The strlen function is expensive. For every call it must loop over every character in the input string until a nul terminator is found. Therefore, it is very unwise to call it more often than needed. This is bad code:
for ( int ix = 0; ix < strlen(a_str); ix++)
{
a_str[ix] = tolower( (unsigned char) a_str[ix] );
}
Lets consider a string 1000 characters in length. strlen will be called 1001 times and loop over 1000 characters each time. That is over one million wasted iterations. If the tolower call and assignment takes the equivalent of 10 iterations we can calculate that the operation takes one hundred times longer than it would if written correctly.
strlen as a loop condition should be replaced with:
for ( int ix = 0; a_str[ix] != '\0'; ix++)
{
a_str[ix] = tolower( (unsigned char) a_str[ix] );
}
or the slightly less efficient:
int len = strlen(a_str);
for ( int ix = 0; ix < len; ix++)
{
a_str[ix] = tolower( (unsigned char) a_str[ix] );
}
As well as removing unnecessary strlen calls from loops, we should try to remove any other expensive function calls.
3.
Temporarily swap:
Here's a neat trick to swap two variables without creating a temporary:
void swap(int& a, int& b)
{
a ^= b;
b ^= a;
a ^= b;
}
To check correctness, you only need to know that (a^b)^a = b and (b^a)^b = a.
Tuesday, 10 December 2013
HDMI(High Definition Multimedia Interface)
HDMI
stands for High Definition Multimedia Interface. A HDMI cable is a
single cable that serves as link for audio as well as video
applications. For a video recorded in high definition, a standard
Audio-video component cable gives an output of 480 pixels per inch. On
the other hand, HDMI connectors give at least a 720 pixel/inch output,
thus giving a more rich and lively video that can recreate the actual
scene with more accuracy. There are similar enhancements in audio side
too (2.1 channel sound and above). This means that a single HDMI cable
can replace up to 11 analog signal cables not only in aspects like
reduced clutter, but in bandwidth, content transmission and presentation
quality too. HDMI is constantly worked upon and improved by HDMI
Consortium, which also handles certifying HDMI cables.
Friday, 6 December 2013
Wi-Fi SD card and USB drive reader
Elecom is going to release the SD card and USB drive reader MR-WI01BK in early December.
The MR-WI01BK is compatible with Wi-Fi connection (IEEE802.11n/g/b). By setting an SD memory card or USB drive to the reader, you can check data or play music saved in those media wirelessly with your smartphone or tablet. This, in effect, allows you to increase the media available to you beyond the smartphone or tablet’s capacity shortage.
It’s able to be accessed by a maximum of 5 devices at a time so that it makes data share with your friends easier.
21 kinds of media are compatible with the card reader MR-WI01BK (5 more kinds can be compatible if you use a conversion adapter).
Your Next USB Connector Will Be Thinner, Reversible
As mobile devices get increasingly slimmer, so too will their corresponding USB connectors. Even better, you won't have to flip the cable when you try to slip it in upside down. Finally.
Development for the next-generation USB connector, called the Type-C, is underway and will be thinner and sleeker than current USB 3.0 cables (pictured above), according to the USB 3.1 Promoter Group, which is made up of industry heavy hitters including Microsoft, Hewlett-Packard and Intel.
To pack the powerful punch of the USB 3.1 standard, which can move data at 10 gigabits per second, into a smaller cable, it will closely resemble the USB 2.0 Micro-B. But it has a few advantages over existing models: Specifically, it's reversible, meaning users no longer need to worry about plug orientation.
The plug design is similar to the Apple's Lightning cables and will take away one of USB's main frustrations. The downside is that the new cables won't work with existing connectors.
The Type-C connector is built on existing USB 3.1 and USB 2.0 technologies and will have scalable power capabilities, meaning it will be able to charge a wide range of gadgets.
“While USB technology is well established as the favored choice for connecting and powering devices, we recognize the need to develop a new connector to meet evolving design trends in terms of size and usability,” said Brad Saunders, USB 3.0 Promoter Group Chairman, in a statement. “The new Type-C connector will fit well with the market’s direction and affords an opportunity to lay a foundation for future versions of USB.”
Subscribe to:
Posts (Atom)
