Skip to content

Instantly share code, notes, and snippets.

View jchudzynski's full-sized avatar

Janusz Chudzynski jchudzynski

View GitHub Profile
@jchudzynski
jchudzynski / MFUtilities.h
Last active December 24, 2015 22:49
Example of Objective-C Class
#import <Foundation/Foundation.h>
#import "MFFraction.h"
@interface MFUtilities : NSObject
{
int count;
}
//main intro
-(double)getValueOfFraction:(MFFraction *)fraction;
-(BOOL)isEqual:(MFFraction *)fractionOne and:(MFFraction *)object;
@jchudzynski
jchudzynski / MyClass.h
Created October 7, 2013 21:52
Objective-C Class Example
//import necessary frameworks
#import <Foundation/Foundation.h>
//public interface
@interface MyClass : SuperclassOfMyclass
{
//public members declarations
int member1;
}
@jchudzynski
jchudzynski / Captcha
Created October 8, 2013 17:15
Instructions for using captcha
1. Copy ajax.cfc to your folder
2. Add the following code to the file's header.
<cfajaxproxy cfc="atcdev.applications.captcha.ajax" jsclassname="proxy" />
<cfinvoke component="ajax" returnvariable="captcha" method="makeRandomString">
<cfset captchaHash = hash(captcha)>
<script type="text/javascript">
<!--
<cfoutput>
@jchudzynski
jchudzynski / WebServicesHelper.m
Last active December 30, 2015 04:48
Contains methods that are making networking calls and parse the response
/*!
@class WebServicesHelper
@abstract
Contains methods that are making networking calls and parse the response
@discussion
*/
@jchudzynski
jchudzynski / WebServicesHelper.h
Created December 3, 2013 21:42
Contains methods that are making networking calls and parse the response
/*!
@class WebServicesHelper
@abstract
Contains methods that are making networking calls and parse the response
@discussion
respond to, e.g., authentication challenges
*/
@jchudzynski
jchudzynski / gist:7794260
Last active December 30, 2015 07:09
WebServicesHelper Example of usage in AppDelegate class
#import "AppDelegate.h"
#import "WebServicesHelper.h"
@interface AppDelegate()
@property (nonatomic,strong)WebServicesHelper * helper;
@end
@implementation AppDelegate
@jchudzynski
jchudzynski / MinValue
Last active December 30, 2015 19:39
Getting a min value of CoreData entity.
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Slide" inManagedObjectContext:[[manager getAppDelegate]managedObjectContext]];
[request setEntity:entity];
// Specify that the request should return dictionaries.
[request setResultType:NSDictionaryResultType];
NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"order"];
// Create an expression to represent the minimum value at the key path 'creationDate'
NSExpression *minExpression = [NSExpression expressionForFunction:@"min:" arguments:[NSArray arrayWithObject:keyPathExpression]];
@jchudzynski
jchudzynski / KVOOperationQueue.m
Last active October 24, 2016 18:17
KVO of NSOperationQueue
@interface KVOOperationQueue()
@property(nonatomic, strong) NSOperationQueue *queue;
@end
@implementation KVOOperationQueue
-(id)init{
self = [super init];
if(self){
filePath = filename;
@jchudzynski
jchudzynski / IsConnected
Created January 13, 2014 16:40
Checks if internet connection is offline.
-(BOOL)checkIfOnline{
NSURL *scriptUrl = [NSURL URLWithString:@"http://google.com/m"];
NSData *data = [NSData dataWithContentsOfURL:scriptUrl];
if (data){
NSLog(@"Device is connected to the internet");
return YES;}
else
NSLog(@"Device is not connected to the internet");
return NO;
@jchudzynski
jchudzynski / XMLParser.m
Last active January 3, 2016 03:49
NSXMLParser Example
// XMLParser.m
// CDT
// Created by Janusz Chudzynski on 1/13/14.
#import "XMLParser.h"
#import "Deck.h"
#import "Question.h"
typedef void (^SuccessBlock)(NSData *);