Saturday, November 23, 2013

Customizing NSLog


Customizing NSLog:
================
Search for “preprocessing” and locate the section titled “Preprocessor Macros”. Next, simply add “DEBUG=1″ to the Debug section.


ExtendNSLogFunctionality.h
-----------------------------------
#import
#ifdef DEBUG
#define NSLog(args...) ExtendNSLog(__FILE__,__LINE__,__PRETTY_FUNCTION__,args);
#else
#define NSLog(x...)
#endif
void ExtendNSLog(const char *file, int lineNumber, const char *functionName, NSString *format, ...);



ExtendNSLogFunctionality.m
-----------------------------------
#import "ExtendNSLogFunctionality.h"
void ExtendNSLog(const char *file, int lineNumber, const char *functionName, NSString *format, ...)
{
    // Type to hold information about variable arguments.
    va_list ap;
    // Initialize a variable argument list.
    va_start (ap, format);
    // NSLog only adds a newline to the end of the NSLog format if
    // one is not already there.
    // Here we are utilizing this feature of NSLog()
    if (![format hasSuffix: @"\n"])
    {
        format = [format stringByAppendingString: @"\n"];
    }
    NSString *body = [[NSString alloc] initWithFormat:format arguments:ap];
    // End using variable argument list.
    va_end (ap);
    NSString *fileName = [[NSString stringWithUTF8String:file] lastPathComponent];
    fprintf(stderr, "(%s) (%s:%d) %s",
            functionName, [fileName UTF8String],
            lineNumber, [body UTF8String]);
}



Prefix.pch
-----------
#ifdef __OBJC__
    #import
    #import
    #import "ExtendNSLogFunctionality.h"
#endif


Example:
========
int result = 20;
NSLog(@"Value of result : %d", result);

(­[AppDelegate application:didFinishLaunchingWithOptions:]) (AppDelegate.m:21) Value of result : 20







Saturday, November 16, 2013

Foods That Strengthen Bone Marrow

Bone marrow is tissue found inside your bones producing your blood cells. Strong, healthy bone marrow requires foods rich in vitamins and minerals.

Iron

Foods rich in iron can help bone marrow function more effectively. The body only absorbs approximately 1 milligram of the 10 to 20 milligrams consumed, according to University of Maryland Medical Center. Thirty percent of your iron is stored in your bone marrow, spleen or liver. Most of the iron absorbed is used by the bone marrow for erythropoiesis, a process producing new red blood cells. Foods rich in iron include red meats, shellfish, cabbage, lima beans and iron-fortified cereals and bread. Also, consume foods rich in vitamin C to aid in the absorption of iron. Vitamin C sources include citrus fruits like oranges, grapefruit and tangerines.

Folic Acid

Folic acid, a B vitamin, aids in platelet functioning and DNA synthesis, a vital step in cell reproduction. In the absence of proper synthesis of DNA, healthy division of your bone marrow cells does not occur. Division of bone marrow cells aids in the development of mature blood cells like platelets. Folic acid deficiencies cause atypical platelet growth. Foods rich in folic acid include liver, egg yolk, beans, almonds, sweet potato, wholegrain bread, spinach, cabbage, oranges and peaches.

Vitamin B12

Vitamin B12 is essential for the production of healthy bone marrow. Folic acid and vitamin B12 work together during hematopoiesis, the manufacturing of bone marrow blood cells. For these red blood cells to develop in the bone marrow, vitamin B12 activates enzymes and regulates DNA synthesis. Food sources of vitamin B12 include liver, egg yolk, cheese, red meat, fish, cabbage, spinach and kale.

Vitamin A

Foods rich in vitamin A help regulate proteins generated in your cells, which aids in cellular development. Vitamin A is particularly known to promote stem cell maturation in your bone marrow. When vitamin A is deficient in your body, typical blood cell growth is halted, as reported by the Linus Pauling Institute. Strengthen your bone marrow and cells by ingesting vitamin A-rich foods. These foods include carrots, sweet potatoes, cantaloupe, pumpkin, cod liver oil and eggs.




Calcium and Phosphorus
Some of your medicines might deplete calcium, which is important for maintaining bone strength. When the staff reviews your medications and labs, they will inform you if this is likely to be a problem. Phosphorus is a mineral that helps to strengthen bones. Some bone marrow transplant patients often need additional phosphorus. Unless you are following a special diet, we recommended you eat a diet high in calcium and phosphorus.
Dairy products high in calcium and phosphorus include:
  • Creamer (pasteurized)
  • Milk (skim, low-fat, whole)
  • Natural cheese, processed cheese (pre-packaged)
  • Cottage cheese, ricotta cheese
  • Yogurt (regular or frozen)
  • Pudding, custard
  • Ice cream or ice milk
  • Cream soup
  • Buttermilk
  • Evaporated milk
  • Powdered milk
Non-dairy products high in calcium include:
  • Calcium-enriched fruit juice
  • Roasted almonds
  • Dried peas and beans (cooked thoroughly)*
  • Tofu (calcium enriched, cooked thoroughly)
  • Greens (kale,collard, mustard, turnip*)
  • Canned salmon with soft bones
  • Broccoli*
  • Bok choy
  • Spinach
  • Mackerel
  • Sardines*
  • Shrimp
*a good source of phosphorus
Additional foods with significant amounts of phosphorus:
  • Brussels sprouts
  • Peanut butter
  • Beef and Chicken livers
  • Whole grain breads
  • Coconut
  • Chocolate
  • Avocados
  • Chick peas
  • Nuts
  • Mushrooms
  • Artichokes
  • Tropicana Fruit Punch®
  • Hawaiian Punch®
  • Tropicana Peach Papaya®
  • Tropicana Strawberry Melon®
  • Fruitworks -- all varieties except pink lemonade
  • Cool Iced Tea -- all varieties except lemonade iced tea 


Potassium and magnesium
Antibiotics, diarrhea, and vomiting can cause electrolyte (mineral) imbalances. Even after your hospital discharge, it is common to require potassium and magnesium supplementation, which can be given by pill or intravenous infusion.
Potassium is an electrolyte (mineral) that maintains normal fluid balance, supports cell integrity, facilitates the making of protein, assists in the transmission of nerve impulses, and the contraction of the heart and other muscles.
Fruit sources of potassium include:
  • Apricots
  • Avocados
  • Bananas
  • Dates, figs
  • Honeydew/cantaloupe
  • Oranges
  • Peaches
  • Prunes
  • Raisins
Vegetables high in potassium include:
  • Artichokes
  • Bamboo shoots
  • Beans
  • Beets
  • Chard
  • Chick peas
  • Escarole
  • Leeks
  • Mushrooms
  • Spinach
  • Squash
  • Tomatoes
  • White potatoes, sweet potatoes
Magnesium is also an electrolyte (mineral) that is involved in bone mineralization, building of protein, transmission of nerve impulses, and normal muscular contraction.
Significant sources of magnesium include:
  • Legumes
  • Leafy green vegetables
  • Nuts
  • Milk
  • Whole grain cereals
  • Chocolate
  • Meat 

Thursday, November 14, 2013

What is Hadoop ?

Hadoop is an open-source, Java-based implementation of Google's MapReduce framework. Hadoop is designed for any application which can take advantage of massively parallel distributed-processing, particularly with clusters composed of unreliable hardware.

For example, suppose you have 10 terabytes of data, and you want to process it somehow, (suppose you need to sort it). Using a single computer, this could take a very long time. Traditionally, a high-end super-computer with exotic hardware would be required to do this in a reasonable amount of time.

Hadoop provides a framework to process data of this size using a computing cluster made from normal, commodity hardware. There are two major components to Hadoop: the file system, which is a distributed file system that splits up large files onto multiple computers, and the MapReduce framework, which is an application framework used to process large data stored on the file system.

Of course, there are many distributed computing frameworks, but what is particularly notable about Hadoop (and Google's MapReduce) is the built-in fault tolerance. It is designed to run on commodity hardware, and therefore it expects computers to be breaking frequently. The underlying file system is highly-redundant (blocks of data are replicated across multiple computers) and the MapReduce processing framework automatically handles computer failures which occur during a processing job by reassigning the processing to another computer in the cluster.

Hardware Machine name


#include <sys/types.h>
#include <sys/sysctl.h>
     

- (NSString *)machine
{
    size_t size;
   
    // Set 'oldp' parameter to NULL to get the size of the data
    // returned so we can allocate appropriate amount of space
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
   
    // Allocate the space to store name
    char *name = malloc(size);
   
    // Get the platform name
    sysctlbyname("hw.machine", name, &size, NULL, 0);
   
    // Place name into a string
    NSString *machine = [NSString stringWithUTF8String:name];
   
    // Release allocated memory
    free(name);
   
    return machine;
}

Friday, November 8, 2013

Taking Screenshot programatically in iOS

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
    UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
} else {
    UIGraphicsBeginImageContext(self.window.bounds.size);
}

[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData * data = UIImagePNGRepresentation(image);
[data writeToFile:@"foo.png" atomically:YES];

   

App Icon File name and Size for iOS 7


Icon.png - 57*57

Icon@2x.png - 114*114

Icon-Small.png - 29*29

Icon-Small@2x.png - 58*58

Icon-80.png - 80*80

Icon-120.png - 120*120