2013年1月19日星期六

Fix external SSD file system on Mac OS X

I use Retina MacBook Pro, the internal SSD capacity is 256G, no enough for me.
so I usual attach a usb SSD driver, usb 3.0 speed is very good for SSD, but the SSD driver file system crash 
three times.

some time can you Disk Utility.app  fix it, but today ,the tool give me
rMBP:~ yarshure$ sudo fsck_hfs -ry  /dev/disk1s2
** /dev/rdisk1s2
   Executing fsck_hfs (version diskdev_cmds-557.3~1).
** Checking Journaled HFS Plus volume.
   The volume name is VM
** Checking extents overflow file.
** Checking catalog file.
** Rebuilding catalog B-tree.
** Rechecking volume.
** Checking Journaled HFS Plus volume.
   The volume name is VM
** Checking extents overflow file.
** Checking catalog file.
   Incorrect number of thread records
(4, 220)
** Checking multi-linked files.
** Checking catalog hierarchy.
** Checking extended attributes file.
** Checking volume bitmap.
** Checking volume information.
** Repairing volume.
** Rechecking volume.
** Checking Journaled HFS Plus volume.
   The volume name is VM
** Checking extents overflow file.
** Checking catalog file.
   Incorrect number of thread records
(4, 220)
** Checking multi-linked files.
** Checking catalog hierarchy.
** Checking extended attributes file.
** Checking volume bitmap.
** Checking volume information.
** Repairing volume.
** Rechecking volume.
** Checking Journaled HFS Plus volume.
   The volume name is VM
** Checking extents overflow file.
** Checking catalog file.
   Incorrect number of thread records
(4, 220)
** Checking multi-linked files.
** Checking catalog hierarchy.
** Checking extended attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume VM could not be repaired after 3 attempts.

 the file system too weak, I search the web, found DiskWarrior.app.
It help me fixed the crash system.

2013年1月17日星期四

Birthday greetings

     Today is your birthday, mother。Can you hear me ?  I'm you litter son, I wish you happy every day in heaven, no illness suffering.
     This garden and hours was builded by our family. We lived in it   more than twenty years.

     



2013年1月16日星期三

introduce Multiple Layer Animation

Apple system have many methods do Animation:
1 View base, I have introduce in uiview-animation-with-block
2  ImageView base, frame animation like play film
3 Core Animation

Today, I share some code in my work:


- (IBAction)doAnimation:(id)sender {
    int i;
for (i=0 ; i< [_leafs count] ;i++) {
UIView *tmpBarItem = [_leafs objectAtIndex:i ];
[tmpBarItem.layer addAnimation:[self leafsAnimation:CGPointMake(tmpBarItem.center.x,tmpBarItem.center.y-tmpBarItem.frame.size.height/2)
                                                  beginTime:0
                                              Animationname:[NSString stringWithFormat:@"%d",i ]] forKey:@"position"];
        tmpBarItem.layer.anchorPoint= CGPointMake(0.5, 0);
tmpBarItem.center = CGPointMake(tmpBarItem.center.x-length,tmpBarItem.center.y-tmpBarItem.frame.size.height/2);
        
}
}

-(CAAnimation*)leafsAnimation:(CGPoint)fromPoint beginTime:(CGFloat)abeginTime Animationname:(NSString *)name
{
    CAKeyframeAnimation *move0 = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef thePath0 = CGPathCreateMutable();
CGPathMoveToPoint(thePath0, NULL, fromPoint.x, fromPoint.y);
CGPathAddLineToPoint(thePath0, NULL, fromPoint.x-length, fromPoint.y);
    float t1=1.2;
    float t2= 1.0;
move0.duration=t1;
move0.path = thePath0;
CGPathRelease(thePath0);
    
    //CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"transform"];
    
CAKeyframeAnimation *move = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
move.removedOnCompletion = YES;
    move.beginTime = t1;
move.duration = t2;
    
    
    
move.values = [NSArray arrayWithObjects:
                   [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(-10)))],
  [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(20)))],
  [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(-(20/2+5))))],
  [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(10)))],
  [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(-(10/2+2.5))))],
  [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(5)))],
                   [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(0)))],nil];
move.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.2],
[NSNumber numberWithFloat:0.4],
[NSNumber numberWithFloat:0.6],
                     [NSNumber numberWithFloat:0.8],
[NSNumber numberWithFloat:1],nil];
    
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = t1+t2;
group.delegate = self;
[group setValue:name forKey:@"name"];
//move.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
group.animations = [NSArray arrayWithObjects:move0,move,nil];
return group;
}

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
NSLog(@"%@",[theAnimation valueForKey:@"name"]);
}

demo  ios application project source code https://github.com/yarshure/yarshure/blob/master/FlyLeafDemo.zip

I upload a video ,you can watch it on youtube.



[Tips]how to find MAS downloading file url


some times Mac app store application download Mac OS X update package very slow, so I write this tips.
First use MAS app start downloading
second open terminal:

rMBP:~ yarshure$ lsof |grep apple.com
WebProces  304 yarshure   33u     REG                1,3     12288   756415 /Users/yarshure/Library/Safari/LocalStorage/http_support.apple.com_0.localstorage
App\x20St 5400 yarshure   11w     REG                1,3 117339677 11229520 /private/var/folders/bk/j1vyw0wd1nx8lldrzc4z8z300000gn/C/com.apple.SoftwareUpdate/swcdn.apple.com/content/downloads/53/57/041-9585/m24b4n13ngu3s79fguytcmmzsojk1sb2o2/OSXUpd10.8.3Seed.pkg

apple update package downloading server is swcdn.apple.com, so we found the url is:

http://swcdn.apple.com/content/downloads/53/57/041-9585/m24b4n13ngu3s79fguytcmmzsojk1sb2o2/OSXUpd10.8.3Seed.pkg.

aha,very easy! I have used this method  several times  download Mac OS X 10.8.3 Beta update package.

My family second live house


My family live in this house between Aug 1995 and Oct 2005.
This photo was taken in Sep 2010, half year before my mother dead.
Before  I go to  high school, my father sell big one house in countryside, and
we move to the little town(双阳镇/double sun).


2013年1月15日星期二

UIView Animation with block


UIViewAnimationWithBlocks us block,animation finished no longer needed write callback method,it's more  beautiful than old style.

- (void)setSelectedVeg:(id)sender
{    
    [selectedVegetableIcon setAlpha:0.0];
    
    [UIView animateWithDuration:0.4
                     animations: ^{
                         float angle = [self spinnerAngleForVegetable:sender];
                         [vegetableSpinner setTransform:CGAffineTransformMakeRotation(angle)];
                     } 
                     completion:^(BOOL finished) {
                         [selectedVegetableIcon setAlpha:1.0];
                     }];

}

code came from WWDC2010 iPlant PlantCareViem.m

old UIViewAnimation style Animation
- (void)setSelectedVeg:(id)sender
{    
    [selectedVegetableIcon setAlpha:0.0];
[UIView beginAnimations:@"setSelectedVeg" context:nil];
float angle = [self spinnerAngleForVegetable:sender];
[vegetableSpinner setTransform:CGAffineTransformMakeRotation(angle)];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(done)];
[UIView commitAnimations];
}
-(void)done
{
[selectedVegetableIcon setAlpha:1.0];
}

this article was written by me in 2010 on my Chinese blog.

[Tips] Show Circle in iOS app






first get baby icon,and add a circle crop,after that ,Superposition it with background image 
Iike this:


code 
double radians (double degrees) {return degrees * M_PI/180;}
-(UIImage*)createIconWithImage:(UIImage*)src
{
    UIImage *circle=[UIImage imageNamed:@"Face@2x.png"];
    CGFloat width=circle.size.width;
    CGFloat height=circle.size.height;
   
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedFirst);
    
    CGContextDrawImage(context, CGRectMake(0, 0, width, height), circle.CGImage);
    
    if (src.imageOrientation == UIImageOrientationLeft) {
        CGContextRotateCTM (context, radians(90));
        CGContextTranslateCTM (context, 0, -height);
        
    } else if (src.imageOrientation == UIImageOrientationRight||src.imageOrientation == UIImageOrientationRightMirrored) {
        CGContextRotateCTM (context, radians(-90));
        CGContextTranslateCTM (context, -width, 0);
        
    } else if (src.imageOrientation == UIImageOrientationUp) {
        // NOTHING
    } else if (src.imageOrientation == UIImageOrientationDown) {
        CGContextTranslateCTM (context, width, height);
        CGContextRotateCTM (context, radians(-180.));
    }
    CGContextBeginPath(context);
    
    CGContextTranslateCTM (context, 4, 4);
    CGRect rect = CGRectMake(0, 0, width-12, height-12);
    CGContextAddEllipseInRect(context, rect);
    CGContextClosePath(context);
    CGContextClip(context);
    CGContextDrawImage(context, rect , src.CGImage);
    
    CGImageRef imageMasked = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    CGColorSpaceRelease(colorSpace);
UIImage *image = [UIImage imageWithCGImage:imageMasked];
CGImageRelease(imageMasked);
    return image;
}
I thank there has a good way do this work, I use code do this like first picture in this article.

sample code : 


#import <QuartzCore/QuartzCore.h>        
self.contentView.layer.cornerRadius = 35.0;
        self.contentView.layer.borderWidth = 1.0f;
        self.contentView.layer.borderColor = [UIColor blueColor].CGColor;
        self.contentView.layer.shadowColor = [UIColor blueColor].CGColor;
        self.contentView.layer.shadowOffset = CGSizeMake(2.0, 2.0);
        self.contentView.layer.shadowOpacity= 0.5;
        self.contentView.backgroundColor = [UIColor underPageBackgroundColor];


reference 
Apple CALayer Class Reference 

2013年1月13日星期日

Retina What?

I have used Retina MacBook Pro  for four months, retina is very comfort for Reading.
Last week I Sell My old MacBook Pro 17' MC227, I purchase it spend 16300¥, after purchased, I add one intel X25-M 80G SSD, 4Gx2 1066 Memory, and 256G SSD. totally about 3000$.

In Mar 2011,I buy Carriers contract's iPhone4 from China Unicom.
In Oct 2011,I buy contract free iPhone 4s from Apple Canada online store, my fiend who live in Toronto help me Received Goods, and send to China.
In May 2012,I get retina version iPad, +Leask Huang buy it from HK.
In Nov 2012,I get iPhone5 HK version from my provider, before it on my hand, it have been actived.
                     anyway, it is a consumer electronic。
                     I use China Telecom sim card because it bind my fiber optic broadband,it only cost me             1$.

In Nov 2012, My friend +Nan Chen help me buy on iPad 4th in Canada, the month Human flesh Express on my hand.

iPad mini release one  week, I have chance to use it. It's light more than 9.7' iPad, but mot comfort for Reading.

This year ,I guess apple will release retina version iPad mini, and more will Quad-Core Arm iDevice?




   
 


2013年1月11日星期五

Practice ZFS on FreeBSD server.


Today,I setup one FreeBSD Server.
use 12*1T SAS Driver.
1 two driver use LSI controller  make RADI1
2 others use zfs
   enable zfs

echo 'zfs_enable="YES"' >> /etc/rc.conf
echo 'zfs_load="YES"' >> /boot/loader.conf

start zfs support
# /etc/rc.d/zfs start
setup gpt partion

    13 9:55 gpart create -s gpt da1
    14 9:55 gpart create -s gpt da2
    15 9:55 gpart create -s gpt da3
    16 9:55 gpart create -s gpt da4
    17 9:55 gpart create -s gpt da5
    18 9:55 gpart create -s gpt da6
    19 9:55 gpart create -s gpt da7
    20 9:55 gpart create -s gpt da8
    21 9:55 gpart create -s gpt da9
    22 9:55 gpart create -s gpt da10
add FreeBSD zfs part ion

    23 9:56 gpart add -t freebsd-zfs -l disk0 da1
    24 9:56 gpart add -t freebsd-zfs -l disk1 da2
    25 9:56 gpart add -t freebsd-zfs -l disk2 da3
    26 9:56 gpart add -t freebsd-zfs -l disk3 da4
    27 9:56 gpart add -t freebsd-zfs -l disk4 da5
    28 9:57 gpart add -t freebsd-zfs -l disk5 da6
    29 9:57 gpart add -t freebsd-zfs -l disk6 da7
    30 9:57 gpart add -t freebsd-zfs -l disk7 da8
    31 9:57 gpart add -t freebsd-zfs -l disk8 da9
    32 9:57 gpart add -t freebsd-zfs -l disk9 da10

create raidz tank use disk8 and disk9 as spare



root@FreeBSD-zfs:/root # zpool create tank raidz disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 spare disk8 disk9
cannot open 'disk0': no such GEOM provider
must be a full path or shorthand device name

not success,because disk0 maybe conflict with raid1 disk disk name (da0)
so use gpart modify change da1 label name



root@FreeBSD-zfs:/root # gpart  modify -i 1 -l disk10 da1 da1p1 modified




verify modify


root@FreeBSD-zfs:/root # gpart list da1 
Geom name: da1
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 1953525134
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: da1p1
   Mediasize: 1000204851712 (931G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 17408
   Mode: r1w1e1
   rawuuid: 23c46e3a-5b92-11e2-bd81-001e674f5978
   rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
   label: disk10
   length: 1000204851712
   offset: 17408
   type: freebsd-zfs
   index: 1
   end: 1953525134
   start: 34



recreate zfs 


root@FreeBSD-zfs:/root # zpool create tank raidz disk0 disk1 disk2 disk3 disk4 disk5 disk6 disk7 spare disk8 disk9 



root@FreeBSD-zfs:/root # zfs list
NAME   USED  AVAIL  REFER  MOUNTPOINT
tank   975M  6.20T   975M  /mnt
success,^_^。

I do another stupid work, execute

echo 'vfs.root.mountfrom="zfs:zroot"' >> /boot/loader.conf
and reboot
But the FreeBSD give up mount root partion,give me message 


GEOM: da11: geometry does not match label (64h,33s != 255h,63s).
GEOM: da11: media size does not match label.
Trying to mount root from zfs:zroot []...
Mounting from zfs:zroot failed with error 2.
Loader variables:
  vfs.root.mountfrom=zfs:zroot
Manual root filesystem specification:
  <fstype>:<device> [options]
      Mount <device> using filesystem <fstype>
      and with the specified (optional) option list.
    eg. ufs:/dev/da0s1a
        zfs:tank
        cd9660:/dev/acd0 ro
          (which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /)
  ?               List valid disk boot devices
  .               Yield 1 second (for background tasks)
  <empty line>    Abort manual input
mountroot>
restart ,I want to use usb FreeBSD  memory stick system fix.
But my friend have erase the memory stick.
So, enter mimiboot?
>unload all module,and boot
but stop at mountroot second time.
mountroot>ufs:/dev/da0p2

FreeBSD accept,and mount all partion and zfs.



root@FreeBSD-zfs:/root # df -h
Filesystem    Size    Used   Avail Capacity  Mounted on
/dev/da0p2    9.7G    385M    8.5G     4%    /
devfs         1.0k    1.0k      0B   100%    /dev
/dev/da0p4     48G     32M     44G     0%    /var
/dev/da0p5     96G    1.2G     88G     1%    /usr
/dev/da0p6    9.7G     32M    8.9G     0%    /home
/dev/da0p7    732G     38M    673G     0%    /usr/local
tank          6.2T    975M    6.2T     0%    /mnt



dmesage show hard drivers:
da0: <LSI Logical Volume 3000> Fixed Direct Access SCSI-6 device 
da0: 952720MB (1951170560 512 byte sectors: 255H 63S/T 121454C)
da10 at mps0 bus 0 scbus2 target 29 lun 0
da10: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da10: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da9 at mps0 bus 0 scbus2 target 28 lun 0
da9: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da9: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da8 at mps0 bus 0 scbus2 target 27 lun 0
da8: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da8: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da1 at mps0 bus 0 scbus2 target 4 lun 0
da1: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da1: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da7 at mps0 bus 0 scbus2 target 26 lun 0
da7: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da7: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da3 at mps0 bus 0 scbus2 target 22 lun 0
da3: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da3: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da5 at mps0 bus 0 scbus2 target 24 lun 0
da5: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da5: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da6 at mps0 bus 0 scbus2 target 25 lun 0
da6: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da6: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da4 at mps0 bus 0 scbus2 target 23 lun 0
da4: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da4: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)
da2 at mps0 bus 0 scbus2 target 5 lun 0
da2: <ATA ST91000640NS SN03> Fixed Direct Access SCSI-6 device 
da2: 953869MB (1953525168 512 byte sectors: 255H 63S/T 121601C)


todo ZFS porfermance

2013年1月8日星期二

What's Next?

I was born in China northeast province JILIN. Until 1995 I went to high school, I live in a small  village. Blow is the village's paddy field.

Between 1995 and 1999, I live in SHUAGNYANG town. 
After graduate from high school ,I went to SHENYANG University of Technology.
Now I haven work in shanghai for ten years.My old Chinese blog address is http://iphone.ipsw.info


so, What's Next?
I start a new blog out of China Great Fire wall, all In English.