Skip to content

Instantly share code, notes, and snippets.

View nenadvulic's full-sized avatar

Nenad VULIC nenadvulic

  • KeepOnApps
  • Paris
View GitHub Profile
@nenadvulic
nenadvulic / gist:4375865
Last active December 10, 2015 03:38
Get correct UILabe height with NSAttributedString
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)activityLbl.attributedText);
CGSize targetSize = CGSizeMake(YOUR_WIDTH, CGFLOAT_MAX);
CGSize fitSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, [activityLbl.attributedText length]), NULL, targetSize, NULL);
CFRelease(framesetter)
@nenadvulic
nenadvulic / AVCaptureMetaDataOutput
Created September 23, 2013 22:29
AVCaptureMetaDataOutput Bar Code Reader iOS7
AVCaptureSession *session = [[AVCaptureSession alloc] init];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device
error:&error];
if (input) {
[session addInput:input];
} else {
NSLog(@"Error: %@", error);
@nenadvulic
nenadvulic / estimateHeight
Created February 12, 2014 18:02
estimated height for cell with constraints
+ (CGFloat) estimateHeight:(NSString *)content{
NSAttributedString *bodyText = [NSAttributedString attributedStringWithMarkdownString:content font:MYCellFontDefine];
CGRect rect = [bodyText boundingRectWithSize:CGSizeMake(CELL_WIDTH, FLT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
return CGRectGetHeight(rect);
}
@nenadvulic
nenadvulic / StubbViewController
Last active August 29, 2015 13:57
Fake network data using with OHHTTPStubs.
#import "MyViewController.h"
#import <OHHTTPStubs/OHHTTPStubs.h>
@interface FLUSubscribeViewController(){
id<OHHTTPStubsDescriptor> _stub;
}
@end
@implementation FLUSubscribeViewController
@nenadvulic
nenadvulic / gist:39a52a0116d501114b50
Created June 17, 2014 02:15
TC - apply.tcdisrupt.com/api/saveApp.cfm
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197):197
<br><span style='margin-right: 1em;'>&nbsp;</span> a
t com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493):1493
<br><span style='margin-right: 1em;'>&nbsp;</span>
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:390):390
<br><span style='margin-right: 1em;'>&nbsp;</span> at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:340):340<
br><span style='margin-right: 1em;'>&nbsp;</span> at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575):4575<
br><span style='margin-right: 1em;'>&nbsp;</span> at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400):1400<
br><span style='margin-right: 1em;'>&nbsp;</span> at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQL
@nenadvulic
nenadvulic / UICollectionViewFlowLayout.m
Created March 3, 2016 10:56
UICollectionView snap cell vertically
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity {
CGPoint contentOffset = CGPointZero;
NSInteger itemHeight = 130;
NSInteger padding = 10;
NSInteger index = round(proposedContentOffset.y / (itemHeight + padding));
NSInteger x = (itemHeight + padding) * index;
contentOffset = CGPointMake(proposedContentOffset.x, x);
return contentOffset;
POST /api/v1/memos HTTP/1.1
Host: api-staging.memoriz.io
Content-Type: application/vnd.api+json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Accept: application/vnd.api+json
User-Agent: memoriz/0.1 (iPhone; iOS 9.2; Scale/2.00)
Accept-Language: fr,en
Authorization: Bearer 1ad8bb6890a6c72b67400172af6c18ad4229c6d158a2a3809475531b0a2a451b
Content-Length: 242
POST /api/v1/memos HTTP/1.1
Host: api-staging.memoriz.io
Content-Type: application/vnd.api+json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Accept: application/vnd.api+json
User-Agent: memoriz/0.1 (iPhone; iOS 9.2; Scale/2.00)
Accept-Language: fr,en
Authorization: Bearer f3c35000a4c0318a3c50f6d04161b8a995e94aab7d2de1d9b74e11b169fffba3
Content-Length: 320
This file has been truncated, but you can view the full file.
POST /api/v1/memos/19/assets HTTP/1.1
Host: api-staging.memoriz.io
Content-Type: application/x-www-form-urlencoded
Connection: keep-alive
Accept: */*
User-Agent: memoriz/4 CFNetwork/758.3.15 Darwin/15.4.0
Accept-Language: en-us
Content-Length: 760361
Accept-Encoding: gzip, deflate
{
"car": {
"card_id": "tok_18NKXeIQ1hNzz4uNU7L4rTHC",
"car_id": 1,
"end_date": "2016-06-23 09:16:00",
"start_date": "2016-06-22 09:16:00",
"location": 1
}
}