Skip to content

Instantly share code, notes, and snippets.

View xslim's full-sized avatar

Taras Kalapun xslim

View GitHub Profile
@xslim
xslim / gist:788840
Created January 20, 2011 22:39
encode and decode with PBEWithMD5AndDES
/*
Usage
NSString *password = @"1111";
NSString *message = @"xxx";
NSData *inData = [message dataUsingEncoding:NSUTF8StringEncoding];
NSData *encData = [securityUtils encryptPBEWithMD5AndDESData:inData password:password];
NSString *encString = [encData base64EncodedString];
@xslim
xslim / AppDelegate.m
Created February 19, 2011 11:50
Example how I use CoreData & Networking
/*
AppDelegate.m
*/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[NSNotificationCenter defaultCenter] addObserverForName:NSManagedObjectContextDidSaveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note){
[self.managedObjectContext mergeChangesFromContextDidSaveNotification:note];
}];
@xslim
xslim / UIAutomationAddon.js
Created February 22, 2011 22:00
UI Automation sample test file
/*
* Test
*/
function test(title, f, options) {
if (options == null) {
options = {
logTree: true
};
}
@xslim
xslim / gist:851018
Created March 2, 2011 14:32
HTML to NSAttributedString
//
// NSAttributedString+fromHTML.m
// Berlingske
//
// Created by Taras Kalapun on 18.08.10.
// Copyright (c) 2010 Ciklum. All rights reserved.
//
#import "NSAttributedString+fromHTML.h"
@xslim
xslim / gist:873415
Created March 16, 2011 22:05
qCar Server test
#!/usr/bin/env python
import socket
import sys
import random
import struct
import time
# Server example
@xslim
xslim / gist:873494
Created March 16, 2011 22:52
Get max mini-cell width
// Beta !!
- (NSArray *)widthForData:(NSArray *)dataArray
{
if ([dataArray count] < 1) return nil;
CGFloat totalWidth = 0.0f;
UIFont *font = [UIFont systemFontOfSize:12.0f];
@xslim
xslim / NSObject+AssociatedObjects.h
Created May 31, 2011 17:49
Blocks support for RestKit RKClient
#import <Foundation/Foundation.h>
@interface NSObject (AMAssociatedObjects)
- (void)associateValue:(id)value withKey:(void *)key; // Retains value.
- (id)associatedValueForKey:(void *)key;
@end
@xslim
xslim / gist:1016752
Created June 9, 2011 13:44
Xcode Continuous integration build script
#!/bin/bash
SDK='iphoneos'
CONFIGURATION='Release'
IDENTITY="iPhone Developer"
GIT_BINARY='git'
REMOTE_HOST='http://hal.ciklum.net'
#http://github.com/baz/ios-build-scripts/raw/master/generate_manifest.py
MANIFEST_SCRIPT='/usr/local/bin/generate_manifest.py'
WEB_DIR="/Users/$USER/web"
@xslim
xslim / ItemParser.h
Created June 11, 2011 17:19
NSXMLParser + CoreData Sample
#import <Foundation/Foundation.h>
#import "Item.h" // Core Data MO
// Synchronous parser ! Will lock thread !
@interface ItemParser : NSObject <NSXMLParserDelegate>
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; // MOC for newly created MO
@property (nonatomic, retain) Item *currentItem;
@xslim
xslim / CDTableViewController.h
Created June 11, 2011 20:40
NSetchedResultsController TableView subclass
#import <UIKit/UIKit.h>
@interface CDTableViewController : UITableViewController <NSFetchedResultsControllerDelegate> {
NSFetchedResultsController *fetchedResultsController_;
}
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
- (void)reloadData;