Skip to content

Instantly share code, notes, and snippets.

View NarendraPunchh's full-sized avatar

Narendra NarendraPunchh

  • Punchh
  • Jaipur
  • 09:16 (UTC -04:00)
View GitHub Profile
///
/// Author : Gaurav D. Sharma
/// Run on Swift 3.0
/// IBM swift sandbox : https://swiftlang.ng.bluemix.net/#/repl
///
//// Are you using ObjectMapper for model mapping in swift.
//// Object creation like Mapper<T>().map(jsonString)
//// And you are irritaed with the type name passing and syntex memorization
////
@NarendraPunchh
NarendraPunchh / shadow.m
Last active December 2, 2016 19:40
Form shadow
- (CGPathRef)renderRect:(UIView*)imgView {
UIBezierPath *path = [UIBezierPath bezierPathWithRect:imgView.bounds];
return path.CGPath;
}
- (CGPathRef)renderTrapezoid:(UIView*)imgView {
CGSize size = imgView.bounds.size;
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(size.width * 0.33f, size.height * 0.66f)];
- (void)setMaskImage {
CALayer *mask = [CALayer layer];
mask.contents = (id)[[UIImage imageNamed:@"infoLogo"] CGImage];
mask.frame = self.imgItem.bounds;
self.imgItem.layer.mask = mask;
self.imgItem.layer.masksToBounds = YES;
self.imgItem.contentMode = UIViewContentModeCenter;
}
@NarendraPunchh
NarendraPunchh / controller.m
Last active February 22, 2017 09:30
This will help us in creating a clear section header. As right now the simple solution is to use a solid color in place of clear background so the content is not visible behind header.
#define Header_height 30
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
for (UITableViewCell *cell in self.tblRedeemables.visibleCells) {
CGFloat hiddenFrameHeight = scrollView.contentOffset.y + Header_height - cell.frame.origin.y;
if (hiddenFrameHeight >= 0 || hiddenFrameHeight <= cell.frame.size.height) {
[self maskCell:cell
fromTopWithMargin:hiddenFrameHeight];
}
}
const checkForceUpdate = (serverVersion, localVersion) => {
const strServerVersion = serverVersion.replace(/\./g, '');
const strLocalVersion = localVersion.replace(/\./g, '');
const power =
Math.max(strServerVersion.length, strLocalVersion.length) -
Math.min(strServerVersion.length, strLocalVersion.length);
let numServer = parseInt(strServerVersion);
let numLocal = parseInt(strLocalVersion);
if (strServerVersion.length < strLocalVersion.length) {
#chmod +x <fileName>
#!/bin/bash
# Add this file on you desktop folder
read -p '[Enter AppName:] ' appName
# - Create a folder
mkdir "$appName"
# - Move to the same folder
cd "$appName"