Skip to content

Instantly share code, notes, and snippets.

View gopalkrishnareddy's full-sized avatar

Gopal Krishna Reddy Thotli gopalkrishnareddy

  • Harman India
  • Bangalore
View GitHub Profile
@oliverfoggin
oliverfoggin / MyImageDownloader.h
Created November 7, 2013 09:43
NSURLConnection download with progress callbacks
@protocol MyImageDownloaderDelegate <NSObject>
- (void)downloadFailed;
- (void)imageDownloadFinished:(UIImage *)image;
- (void)progressUpdated:(CGFloat)progress;
@end
@interface MyImageDownloader : NSObject
@igaiga
igaiga / imgge_uploader.m
Created November 10, 2011 05:59
Multipart POST to upload jpeg sample code for iOS
@interface ImageUploader : NSObject {
NSData *theImage;
}
@property (retain) NSData *theImage;
- (void) syncUpload:(NSData *) uploadImage;
@end
#import "ImageUploader.h"
@gopalkrishnareddy
gopalkrishnareddy / universal-framework.sh
Created September 28, 2018 11:10 — forked from Tokuriku/universal-framework.sh
Script to put in an Aggregate Target of a Framework in Xcode 6 to create a Universal Framework
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@gopalkrishnareddy
gopalkrishnareddy / UIWebView+Additions.h
Created March 14, 2019 08:08 — forked from akisute/UIWebView+Additions.h
UIWebView addition to enable/disable scrolling
#import <UIKit/UIKit.h>
@interface UIWebView (Additions)
/*!
@abstract Enable/Disable the receiver from scrolling.
*/
@property (nonatomic, assign) BOOL webViewScrollEnabled;
@dzenbot
dzenbot / -rangesInSubstring:
Last active October 29, 2019 20:05
NSString: Get all matching NSRange of a substring
- (NSArray *)rangesInSubstring:(NSString *)substring
{
NSError *error = NULL;
NSString *regex = [NSString stringWithFormat:@"\\b%@", substring];
NSRegularExpression *regExpression = [NSRegularExpression regularExpressionWithPattern:regex options:NSRegularExpressionCaseInsensitive error:&error];
NSMutableArray *ranges = [NSMutableArray array];
NSArray *matches = [regExpression matchesInString:self options:NSRegularExpressionSearch range:NSMakeRange(0, self.length)];
func usesAMPM() -> Bool {
let locale = NSLocale.currentLocale()
let dateFormat = NSDateFormatter.dateFormatFromTemplate("j", options: 0, locale: locale)!
if dateFormat.rangeOfString("a") != nil {
return true
}
else {
return false
}
}
@Tokuriku
Tokuriku / universal-framework.sh
Last active September 2, 2020 10:59 — forked from cromandini/universal-framework.sh
Script to put in an Aggregate Target of a Framework in Xcode 6 to create a Universal Framework
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@Czajnikowski
Czajnikowski / Example.swift
Last active September 23, 2021 13:48
Solution for propagating changes from nested ObservableObjects
class TrackViewModel {
private let nestedViewModel: PlaybackViewModel
private var propagation: Any?
init(nestedViewModel: PlaybackViewModel) {
self.nestedViewModel = nestedViewModel
propagation = nestedViewModel.propagateWeakly(to: self)
}
exec > /tmp/${PROJECT_NAME}_archive.log 2>&1
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
@epaga
epaga / TappableView.swift
Last active December 13, 2021 17:57
SwiftUI View for getting taps with(!) the tap locations unlike the current tapAction and tapGestures of SwiftUI
// SwiftUI View for getting taps with(!) the tap locations unlike the current tapAction and tapGestures of SwiftUI
// There may be a way easier way to do this, not sure...
/*
Use like so:
TappableView {
(location, taps) in
if taps == 1 {
print("single tap at \(location)")