Skip to content

Instantly share code, notes, and snippets.

Chris Bruce chrisabruce

Block or report user

Report or block chrisabruce

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chrisabruce
chrisabruce / model_helpers.go
Created Feb 22, 2017
What a Lovely Helper...
View model_helpers.go
package models
import (
"time"
)
func nowFunc() time.Time {
return time.Now()
}
View gist:3535003
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:0];
NSLog(@"%i", [sectionInfo numberOfObjects]);
View gist:198556
- (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];
View gist:9583
% 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.
View gist:9339
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);
You can’t perform that action at this time.