Friday, October 26, 2012

Satire, Inc..

One of the things that I like about Americans is that they have the ability to laugh at themselves. "The Onion" is truly America's finest news source. "China Daily Show" is truly China's finest news source, because remember, it's not the news unless it's the official news.

Saturday, October 20, 2012

There is an ape with a red bottom...

There is an ape with a red bottom, but I cannot seem to find what it is. I thought that youtube would be a good way to find something from description. Well, I found the monkey, but it ended there. Consider the following picture:

That is the last screen from a mis-click actually, but it did have the red-bottom monkey. Apparently, other popular links are ape fornication, which apparently google thinks is a good time to advertise:
Chinese dating sites
Ukrainian women
Filipino dating

So boys, just remember when you are looking at that cute Chinese girl in the back of the class, from the perspective of google, she's the banner child for the Chimpy Chinky Clinky.

Edit: I still want to know what that monkey is called. :(

Friday, October 5, 2012

Steve Jobs Memorial (easter egg?) from Safari

A message from Tim Cook, Apple’s CEO.

Steve’s passing one year ago today was a sad and difficult time for all of us. I hope that today everyone will reflect on his extraordinary life and the many ways he made the world a better place.

One of the greatest gifts Steve gave to the world is Apple. No company has ever inspired such creativity or set such high standards for itself. Our values originated from Steve and his spirit will forever be the foundation of Apple. We share the great privilege and responsibility of carrying his legacy into the future.

I’m incredibly proud of the work we are doing, delivering products that our customers love and dreaming up new ones that will delight them down the road. It’s a wonderful tribute to Steve’s memory and everything he stood for. - Tim

Making lines thick (or thicker) in MATLAB plots

The default line size for MATLAB is 0.5pt, which is a bit annoying when integrating graphs into LaTeX. Consider the following graph made by:
x=1:10;
plot(x,'o-');

You can thicken a line by finding the elements of the line property. Let's say that you wanted to make the line width 4pt, you would do the following:
ch = get(gca,'children'); 
ln = ch(strmatch('line',get(ch,'Type')));
set(ln,'Linewidth',4);

As you can see, the line is much thicker. Play around with getting the 'children', as there's a lot of cool stuff that you can do to help you make your graphs prettier. You can basically do everything in 'edit plots' without changing into edit mode. :)

Wednesday, October 3, 2012

xcode and it's damnable license!

It's not building; it's not building!
So, I installed 10.8 from scratch on my mac, and I was trying to get my code working again. Things just weren't building... Well it seems that I needed to agree to the license, and the command line license is different from the GUI XCode license. Also, if you agree to the license as a user, that doesn't mean that root agreed. :/
sudo xcodebuild -license
Solved my issues.

Tuesday, September 25, 2012

Tracking down USB errors on MacOS 10.6.8

I have been buried in logs.:/
How do you supposed that one figures out what this actually means?
[5] AppleUSBOHCI[0x554c000]::ControlPacketHandler(FN: 0, EP:0): Error: 0xe00002ed, 
    stage: 0x15, todo: 0x40
[3] AppleUSBOHCI[0x554c000]:ControlPacketHandler error 0xe00002ed
    occured on endpoint (0). todo = 0x0 (Clearing stall)
[5] +AppleUSBOHCI[0x554c000]: clearing endpoint 0:0 stall
Well, I found the error codes in IOReturn.h.
#define kIOReturnNotResponding  iokit_common_err(0x2ed) // device not responding
Oh no...

Saturday, September 22, 2012

MacOS USBProber script to clean logs.

MacOS' USBProber is a great tool to debug USB transactions; however, it's just full of information. The logs that it generates just have too much! I created a bash script that I use to remove timestamps and other key words.
Consider the following three entries:
 4733.082 [7] AppleUSBOHCI[0x425d800]::ControlPacketHandler(0:0): still more to come: todo=0x40
 4733.098 [7] IOUSBControllerV3(AppleUSBOHCI)[0x425d800]::RootHubTimerFired - PolicyMaker[0x45be400] powerState[4] _powerStateChangingTo[-1]
 4736.585 [7] IOUSBHIDDriver[0x474a800]::powerChangeDone from state (4) to state (4) _device name(Apple Internal Keyboard / Trackpad)

I wanted to remove anything that had "PolicyMaker" or "Trackpad", along with the timestamp. This resulted in the following script:
#!/bin/sh

#sui's script to clean out MacOS USB prober information
#densui.blogspot.com

#change this list to include more filters
removelist="PolicyMaker Trackpad"

#function that looks for things in the last
function listcontains() {
  line=$2
  a_list=( $1 )
  #echo ${#a_list[@]}
  a_length=${#a_list[@]};
 for (( i = 0; i < $a_length; ++i ))
 do
     a_word=${a_list[$i]}
     if [[ $2 == *"$a_word"* ]]
  then
   return 0
  fi
 done
  return 1
}

#remove the old file if it exists
rm -f $2
# the main loop
cat $1 | while read line; do 
    if listcontains "$removelist" "$line"; 
    then 
     #echo Y;
     HOLDER=1
    else 
     echo ${line#*.*' '} >> $2
     #echo N;
     #echo ""
    fi    
done
Running the script on a file with the lines from the top of the page, I will get a filtered output of:
[7] AppleUSBOHCI[0x425d800]::ControlPacketHandler(0:0): still more to come: todo=0x40
So, no timestamp, no trackpad and no hub information! :)