Skip to content

Instantly share code, notes, and snippets.

@bclubb
bclubb / save.m
Created January 4, 2013 19:39
Saving a file in chunks using a buffer
ALAssetRepresentation *video = [asset defaultRepresentation];
NSUInteger chunkSize = 100 * 1024;
uint8_t *buffer = malloc(chunkSize * sizeof(uint8_t));
long length = [video size];
NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath: videoPath];
if(file == nil) {
[[NSFileManager defaultManager] createFileAtPath:videoPath contents:nil attributes:nil];
file = [NSFileHandle fileHandleForWritingAtPath:videoPath];
@bclubb
bclubb / alphaAlternate.js
Created July 10, 2012 23:31
Alternating background without destroying previous color
$(document).ready(function(){
$(".odd").each(function() {
var backgroundColor = $(this).css('background-color');
var parts = backgroundColor.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
parts.splice(0, 1);
var newBackground = "rgba("+parts.join(",") + ",0.7)";
$(this).css({'background-color' : newBackground});
});
});
#import "EntryHelper.h"
#import "ImageHelper.h"
#import "Image.h"
@implementation EntryHelper
@synthesize entry;
- (NSString *)getEntryDirectoryPath{
if(entryDirectoryPath == nil) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
#import <Foundation/Foundation.h>
#import "Entry.h"
@interface EntryHelper : NSObject {
Entry *entry;
@private
NSString *entryDirectoryPath;
}
@property (nonatomic, retain) Entry *entry;
- (NSString *)getEntryDirectoryPath;
#import "ImageHelper.h"
#import "EntryHelper.h"
@implementation ImageHelper
@synthesize image;
- (UIImage *)getFullScreenImage{
return [UIImage imageWithContentsOfFile:[self getFullScreenImagePath]];
}
#import <Foundation/Foundation.h>
#import "Image.h"
@interface ImageHelper : NSObject{
@private
Image *image;
}
- (UIImage *)getThumbnailImage;
- (UIImage *)getFullScreenImage;
- (UIImage *)getOriginalImage;
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class Entry;
@interface Image : NSManagedObject {
@private
UIBackgroundTaskIdentifier bgTask;
}
@bclubb
bclubb / Image.m
Created October 27, 2011 00:44
Implementation of a fake core data image
//
// Image.m
// journal
//
// Created by Brian Clubb on 2/12/11.
// Copyright (c) 2011 Bubblesort Labs LLC. All rights reserved.
//
#import "Image.h"
#import "Entry.h"
@bclubb
bclubb / i_want_my_ios5.sh
Created June 6, 2011 20:36
Let's you know when the developer site is back up. hopefully. Remember to chmod +x i_want_my_ios5.sh and then run ./i_want_my_ios5.sh from the terminal
#!/bin/sh
while [ "true" ]
do
RESPONSE=$(curl --write-out %{http_code} --silent --output /dev/null http://developer.apple.com/devcenter/ios/index.action)
if [ "$RESPONSE" -ne "302" ]; then
#afplay "Finished.mp3" #uncomment the start of the line and add your own sound if you want something to play
echo "It's up!!!!"
fi
sleep 60
#import "UIView+Screenshot.h"
@implementation UIView (Screenshot)
-(UIImageView *)screenshot{
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();