Skip to content

Instantly share code, notes, and snippets.

View nvkiet's full-sized avatar

Kiet Nguyen - CoFounder & CEO at GrabLingo.com nvkiet

View GitHub Profile

#Users Resources

GET users/me

##Description Get my User object


Parameters

@nvkiet
nvkiet / UIImagePickerController.markdown
Last active November 11, 2015 05:54
UIImagePickerController
+ (UIImagePickerController *)tp_getCameraPickeWithParentViewController:(id<UINavigationControllerDelegate, UIImagePickerControllerDelegate, TPOverlayCameraViewDelegate>)parentViewController {
    
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
        imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePickerController.delegate = parentViewController;
        imagePickerController.showsCameraControls = NO;
        
@nvkiet
nvkiet / UIViewAnimation.markdown
Last active October 25, 2015 16:21
UIView Animation
[UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:10.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        self.view.superview.top -= FilterViewHeight;
    } completion:^(BOOL finished) {
        self.isShown = YES;
        if ([self.delegate respondsToSelector:@selector(filterViewControllerDidShow:)]) {
            [self.delegate filterViewControllerDidShow:self];
        }
 }];
@nvkiet
nvkiet / gist:29e4d5b5bef0865ee159
Created September 24, 2015 07:53
UIAlertController TextAlignment
if #available(iOS 8.0, *) {
let alertController = UIAlertController(title: "Terms & Conditions", message: kTermsAndConditions, preferredStyle: .Alert)
let OKAction = UIAlertAction(title: "OK", style: .Cancel) { (action) in
alertController.dismissViewControllerAnimated(true, completion: nil)
}
alertController.addAction(OKAction)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.Left
@nvkiet
nvkiet / createPDFfromUIView
Created May 18, 2015 07:50
createPDFfromUIView
- (void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
// Creates a mutable data object for updating with binary data, like a byte array
NSMutableData *pdfData = [NSMutableData data];
// Points the pdf converter to the mutable data object and to the UIView to be converted
UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
@nvkiet
nvkiet / UITableViewCell with UITextView height in iOS 7?
Created May 8, 2015 11:25
UITableViewCell with UITextView height in iOS 7?
http://stackoverflow.com/questions/18368567/uitableviewcell-with-uitextview-height-in-ios-7
- (void)textViewDidChange:(UITextView *)textView {
if ([textView getContentHeight] > 31) {
self.noteHeightLayoutConstraint.constant = [textView getContentHeight] + 20;
[self.tableView beginUpdates];
[self.tableView endUpdates];
[self scrollToCursorForTextView:textView];
}
@nvkiet
nvkiet / reloadInputViews
Created May 4, 2015 17:27
reloadInputViews
It's worth noting that if you want a currently-focused field to update the keyboard type immediately, there's one extra step:
// textField is set to a UIKeyboardType other than UIKeyboardTypeEmailAddress
[textField setKeyboardType:UIKeyboardTypeEmailAddress];
[textField reloadInputViews];
@nvkiet
nvkiet / GestureRecognizerTableView
Created May 4, 2015 14:56
GestureRecognizerTableView
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
SmoothLineView *smoothLineView = (SmoothLineView *)[self.tableFooterView viewWithTag:SMOOTH_LINE_VIEW_TAG];
CGRect smoothLineViewFrame = [smoothLineView convertRect:self.tableFooterView.bounds toView:self];
CGPoint touchedPoint = [gestureRecognizer locationInView:self];
BOOL result = !CGRectContainsPoint(smoothLineViewFrame, touchedPoint);
return result;
}
@nvkiet
nvkiet / SendFormDataByUsingAFNetworking
Created April 28, 2015 06:55
SendFormDataByUsingAFNetworking
- (void)sendEmailWithReferral:(Referral *)referral completionBlock:(NetworkCompletionBlock)completion {
[[NetworkHelper sharedInstance] updateEmailAuthorizationForRequestHeader];
NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey];
NSString *message = [NSString stringWithFormat:@"Hi %@\nI found this interesting. You can join %@ and get discount at http://quickref.io/app/%@?code=%@", referral.name, appName, kGroupID, referral.code];
[[NetworkHelper sharedInstance] POST:@"https://api.mailgun.net/v3/quickref.io/messages" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFormData:[@"[email protected]" dataUsingEncoding:NSUTF8StringEncoding] name:@"from"];
[formData appendPartWithFormData:[referral.consentEmail dataUsingEncoding:NSUTF8StringEncoding] name:@"to"];
[formData appendPartWithFormData:[message dataUsingEncoding:NSUTF8StringEncoding] name:@"text"];