Skip to content

Instantly share code, notes, and snippets.

View chrisabruce's full-sized avatar
💭
Rust'ing away.

Chris Bruce chrisabruce

💭
Rust'ing away.
View GitHub Profile
@chrisabruce
chrisabruce / model_helpers.go
Created February 22, 2017 04:05
What a Lovely Helper...
package models
import (
"time"
)
func nowFunc() time.Time {
return time.Now()
}
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:0];
NSLog(@"%i", [sectionInfo numberOfObjects]);
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
//NSLog(responseString);
NSError *error;
SBJSON *json = [[SBJSON new] autorelease];
% Save request body to file.
save_data(Req, Type) ->
Filename = generate_filename(Req, Type),
Length = list_to_integer(Req:get_header_value("content-length")),
{ok, FileIo} = file:open(Filename, [raw, write]),
write_data(FileIo, Req, Length),
file:close(FileIo),
{ok, Filename}.
% Writes Chunked Data to file.
save_data(FileIo, Req, Length) when Length > 0 ->
case Length of
Length when Length < ?CHUNKSIZE ->
Chunk = Req:recv(Length);
_ ->
Chunk = Req:recv(?CHUNKSIZE)
end,
file:write(FileIo, Chunk),
Length1 = Length - size(Chunk),
save_data(FileIo, Req, Length1);