2019年1月15日 星期二

[Android] BLE Gatt error 133 (solved)

BLE disconnect. Gatt error 133

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

            connectDevice.connectGatt(context, Consts.autoConnect, gatt_callback, BluetoothDevice.TRANSPORT_LE);
}else {

            connectDevice.connectGatt(context, Consts.autoConnect, gatt_callback);
}

2016年3月14日 星期一

Delete a branch in "CVS"


Delete a branch in "CVS"

command: tag -dB branchname
-d: delete
-B: override and let it know to delete the branch (not a tag).

2015年9月23日 星期三

Two floating numbers 四捨五入


Input two floating numbers X and P.

a. 0 < X <1
b. P = 1 / 0.1 / 0.01/ 0.001
c. answer format %.4f

ex:
if X is 0.5678 and P is 0.01, then the answer is 0.5700
if X is 0.1269 and P is 0.1, then the answer is 0.1000

2015年9月17日 星期四

C int mapping string


Encoding scheme defined by the following mapping: 

1->'A',
2->'B',
3->'C',
...,
9->'I',
0->'J'.

Input A three-digit integer N

Output The encoding result

2014年9月24日 星期三

Xcode 6.0.1 / iOS 8 UIAlertController

UIAlertControllerStyleAlert with Buttons

UIAlertController  *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
   
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
NSLog(@"Cancel Action");
        }];
   
UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:@"Delete"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"Delete Action");
}];

[alertController addAction:cancelAction];
[alertController addAction:deleteAction];

[self presentViewController:alertController animated:YES completion:nil];

2014年9月10日 星期三

iOS set UIImageView to CircleView


- (id)imageViewSetCornerRadius:(UIImageView *)imageView withImage:(UIImage *)image {
    
    imageView.image = image;
    imageView.layer.borderWidth = 3.0f;
    imageView.layer.borderColor = [UIColor whiteColor].CGColor;
    imageView.layer.cornerRadius = imageView.frame.size.width / 2;
    imageView.clipsToBounds = YES;
    
    return imageView;
}

2014年7月13日 星期日

[iOS] Objective-c sharedApplication delegate, global @property



AppDelegate.h

#define appDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])


@property (nonatomic, assign)NSInteger globalCount;


How to use?