Some of the unexpected queries that get here and some hopefully useful answers:
1/ Some netstat based commands, e.g.:
As far as I can tell, it prints a summary of network connections. This includes established connections and connections that are about to close, and also connections that are locally awaiting for a client.
In the Mac OS X version of netstat, the "-p" option is not supported; sort is also capable of uniquing its results so you can rewrite the line as:
2/ check a word how many times in nsstring
I'd do something like:
3/ /tmp/msgsends
It's the prefix of files created by setting the variable NSObjCMessageLoggingEnabled to YES in the environment of a Cocoa application. The ObjC runtime will write an entry for each ObjC message received in the application.
4/ average life expectancy of macbook
I don't really know - we've had two in the office, one ran for about 18 months before dying (mine), the other is still running (after more then 2 years).
5/ core image histogram
Look for vImageHistogramCalculation_ARGB8888, part of Accelarate.framework.
6/ raising x to power of y "objective c"
NSLog(@"2 to the power of 3: %f", pow(2.0, 3.0));
1/ Some netstat based commands, e.g.:
netstat -anp | grep "tcp\|udp" | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
As far as I can tell, it prints a summary of network connections. This includes established connections and connections that are about to close, and also connections that are locally awaiting for a client.
In the Mac OS X version of netstat, the "-p" option is not supported; sort is also capable of uniquing its results so you can rewrite the line as:
netstat -an | grep "tcp\|udp" | awk '{print $5}' | cut -d: -f1 | sort -nu
2/ check a word how many times in nsstring
I'd do something like:
int count = 0;
NSString * s = [NSString stringWithString:@"foobar contains foobar and some more foobar"];
while([s rangeOfString:@"foobar"].location != NSNotFound)
{
count++;
s = [s substringFromIndex:([s rangeOfString:@"foobar"].location + [s rangeOfString:@"foobar"].length)];
}
3/ /tmp/msgsends
It's the prefix of files created by setting the variable NSObjCMessageLoggingEnabled to YES in the environment of a Cocoa application. The ObjC runtime will write an entry for each ObjC message received in the application.
4/ average life expectancy of macbook
I don't really know - we've had two in the office, one ran for about 18 months before dying (mine), the other is still running (after more then 2 years).
5/ core image histogram
Look for vImageHistogramCalculation_ARGB8888, part of Accelarate.framework.
6/ raising x to power of y "objective c"
NSLog(@"2 to the power of 3: %f", pow(2.0, 3.0));