Latest ROM: G930FXXU1DQEU
E7+DEV
Android iOS Web C++ HTML CSS Javascript Java Objective-C
Saturday, July 8, 2017
Sunday, April 2, 2017
[Google Cloud] Upload Cron using Eclipse
1. Create cron.xml and put it on src/main/webapp/WEB-INF:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/tasks/summary</url>
<target>beta</target>
<description>daily summary job</description>
<schedule>every 24 hours</schedule>
</cron>
</cronentries>
2. And change pom.xml to:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.maven.plugin.version}</version>
<configuration>
<deployables>
<param>target/appengine-staging/WEB-INF/appengine-generated/cron.yaml</param>
</deployables>
</configuration>
</plugin>
Note that cron.yaml is the output staging of cron.xml when deploying.
3. And run command below on Terminal for checking if the deployed works correctly:
mvn appengine:deploy -X3. And run command below on Terminal for checking if the deployed works correctly:
Why not using Eclipse to upload cron?
It seems it is Google Tools issues.Wednesday, July 27, 2016
[iOS] NSString to hex value
+ (UIColor*)colorFromHex:(NSString*)hexString { // https://github.com/timd/UIColor-HexValues hexString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""]; if ([hexString length] == 3) { hexString = [NSString stringWithFormat:@"%@%@%@%@%@%@", [hexString substringWithRange:NSMakeRange(0, 1)],[hexString substringWithRange:NSMakeRange(0, 1)], [hexString substringWithRange:NSMakeRange(1, 1)],[hexString substringWithRange:NSMakeRange(1, 1)], [hexString substringWithRange:NSMakeRange(2, 1)],[hexString substringWithRange:NSMakeRange(2, 1)]]; } if ([hexString length] != 6) { return nil; } // Brutal and not-very elegant test for non hex-numeric characters NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[^a-fA-F|0-9]" options:0 error:NULL]; NSUInteger match = [regex numberOfMatchesInString:hexString options:NSMatchingReportCompletion range:NSMakeRange(0, [hexString length])]; if (match != 0) { return nil; } NSRange rRange = NSMakeRange(0, 2); NSString *rComponent = [hexString substringWithRange:rRange]; NSUInteger rVal = 0; NSScanner *rScanner = [NSScanner scannerWithString:rComponent]; [rScanner scanHexInt:(unsigned int *)&rVal]; float rRetVal = (float)rVal / 254; NSRange gRange = NSMakeRange(2, 2); NSString *gComponent = [hexString substringWithRange:gRange]; NSUInteger gVal = 0; NSScanner *gScanner = [NSScanner scannerWithString:gComponent]; [gScanner scanHexInt:(unsigned int *)&gVal]; float gRetVal = (float)gVal / 254; NSRange bRange = NSMakeRange(4, 2); NSString *bComponent = [hexString substringWithRange:bRange]; NSUInteger bVal = 0; NSScanner *bScanner = [NSScanner scannerWithString:bComponent]; [bScanner scanHexInt:(unsigned int *)&bVal]; float bRetVal = (float)bVal / 254; return [UIColor colorWithRed:rRetVal green:gRetVal blue:bRetVal alpha:1.0f]; }
Monday, June 8, 2015
[iOS] Making fancy view with border, corner and shadow
self.imageView.layer.borderColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1].CGColor; self.imageView.layer.borderWidth = 1; self.imageView.layer.cornerRadius = 3.0; self.imageView.layer.masksToBounds = YES; self.imageView.layer.shouldRasterize = YES; self.imageView.layer.rasterizationScale = [UIScreen mainScreen].scale; self.imageViewBG.layer.shadowOffset = CGSizeMake(1, 1); self.imageViewBG.layer.shadowRadius = 1; self.imageViewBG.layer.shadowOpacity = 0.1; self.imageViewBG.layer.cornerRadius = 3.0; self.imageViewBG.layer.masksToBounds = NO; self.imageViewBG.layer.shouldRasterize = YES; self.imageViewBG.layer.rasterizationScale = [UIScreen mainScreen].scale; UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.imageViewBG.bounds cornerRadius:3.0]; self.imageViewBG.layer.shadowPath = path.CGPath;
Wednesday, April 8, 2015
[iOS] How to get top most view controller?
+ (UIViewController *)topViewController { return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; } + (UIViewController *)topViewController:(UIViewController *)rootViewController { if (rootViewController.presentedViewController == nil) { return rootViewController; } if ([rootViewController.presentedViewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navigationController = (UINavigationController *)rootViewController.presentedViewController; UIViewController *lastViewController = [[navigationController viewControllers] lastObject]; return [self topViewController:lastViewController]; } UIViewController *presentedViewController = (UIViewController *)rootViewController.presentedViewController; return [self topViewController:presentedViewController]; } + (UINavigationController *)navigationController { UIViewController *topViewController = [self topViewController]; UINavigationController *navigationController = nil; if ([topViewController isKindOfClass:[UINavigationController class]]) { navigationController = (UINavigationController *)topViewController; }else { navigationController = topViewController.navigationController; } return navigationController; }
[iOS] How to open a native app or Appstore from Safari or UIWebView
1. Promoting App Banner:
2. Take user to Appstore from Safari link:
Thursday, March 5, 2015
[iOS] Draw Dashed Border Around View
+ (void)drawDashedBorderAroundView:(UIView *)v cornerRadius:(CGFloat)cornerRadius borderWidth:(CGFloat)borderWidth dashPattern1:(NSInteger)dashPattern1 dashPattern2:(NSInteger)dashPattern2 lineColor:(UIColor*)lineColor { //border definitions // CGFloat cornerRadius = 10; // CGFloat borderWidth = 2; // NSInteger dashPattern1 = 4; // NSInteger dashPattern2 = 8; // UIColor *lineColor = [UIColor grayColor]; CGRect newR = v.frame; newR.origin.x += borderWidth/2; newR.origin.y += borderWidth/2; newR.size.width -= borderWidth; newR.size.height -= borderWidth; v.frame = newR; //drawing CGRect frame = v.bounds; CAShapeLayer *_shapeLayer = [CAShapeLayer layer]; //creating a path CGMutablePathRef path = CGPathCreateMutable(); //drawing a border around a view CGPathMoveToPoint(path, NULL, 0, frame.size.height - cornerRadius); CGPathAddLineToPoint(path, NULL, 0, cornerRadius); CGPathAddArc(path, NULL, cornerRadius, cornerRadius, cornerRadius, M_PI, -M_PI_2, NO); CGPathAddLineToPoint(path, NULL, frame.size.width - cornerRadius, 0); CGPathAddArc(path, NULL, frame.size.width - cornerRadius, cornerRadius, cornerRadius, -M_PI_2, 0, NO); CGPathAddLineToPoint(path, NULL, frame.size.width, frame.size.height - cornerRadius); CGPathAddArc(path, NULL, frame.size.width - cornerRadius, frame.size.height - cornerRadius, cornerRadius, 0, M_PI_2, NO); CGPathAddLineToPoint(path, NULL, cornerRadius, frame.size.height); CGPathAddArc(path, NULL, cornerRadius, frame.size.height - cornerRadius, cornerRadius, M_PI_2, M_PI, NO); //path is set as the _shapeLayer object's path _shapeLayer.path = path; CGPathRelease(path); _shapeLayer.backgroundColor = [[UIColor clearColor] CGColor]; _shapeLayer.frame = frame; _shapeLayer.masksToBounds = NO; [_shapeLayer setValue:[NSNumber numberWithBool:NO] forKey:@"isCircle"]; _shapeLayer.fillColor = [[UIColor clearColor] CGColor]; _shapeLayer.strokeColor = [lineColor CGColor]; _shapeLayer.lineWidth = borderWidth; _shapeLayer.lineDashPattern = @[@(dashPattern1), @(dashPattern2)]; _shapeLayer.lineCap = kCALineCapRound; //_shapeLayer is added as a sublayer of the view, the border is visible [v.layer addSublayer:_shapeLayer]; v.layer.cornerRadius = cornerRadius; }
Subscribe to:
Posts (Atom)
[ROM] Samsung S7 Stock Firmware BRI (Taiwan台灣)
Latest ROM: G930FXXU1DQEU Download: https://kfhost.net/tpl/firmwares.php?record=B7E6DE774E3811E7963AFA163EE8F90B Reference: http://...
-
In Android 4.1 (API 16) and above, MediaCodec is introduced by Android. By using MediaCodec, we can easily decode video without using Androi...
-
#include <sstream> #include <assert.h> // include in android platform-9 or newer #include <android/asset_manager.h> #inclu...
-
Latest ROM: G930FXXU1DQEU Download: https://kfhost.net/tpl/firmwares.php?record=B7E6DE774E3811E7963AFA163EE8F90B Reference: http://...