This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation NSHTTPCookieStorage (RAFExtensions) | |
- (void)logCookies; | |
{ | |
NSMutableString *descriptions = [NSMutableString string]; | |
for (NSHTTPCookie *cookie in [self cookies]) | |
{ | |
[descriptions appendString:[self cookieDescription:cookie]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Rafal Sroka | |
// | |
// License CC0. | |
// This is free and unencumbered software released into the public domain. | |
// | |
// Anyone is free to copy, modify, publish, use, compile, sell, or | |
// distribute this software, either in source code form or as a compiled | |
// binary, for any purpose, commercial or non-commercial, and by any means. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Rafal Sroka | |
// | |
// License CC0. | |
// This is free and unencumbered software released into the public domain. | |
// | |
// Anyone is free to copy, modify, publish, use, compile, sell, or | |
// distribute this software, either in source code form or as a compiled | |
// binary, for any purpose, commercial or non-commercial, and by any means. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CMAcceleration)smoothOutAcceleration:(CMAcceleration)acceleration | |
{ | |
static CGFloat x0 = 0; | |
static CGFloat y0 = 0; | |
static CGFloat z0 = 0; | |
const NSTimeInterval dt = (1.0 / 20); | |
const double RC = 0.3; | |
const double alpha = dt / (RC + dt); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// URL of the endpoint we're going to contact. | |
NSURL *url = [NSURL URLWithString:@"http://localhost:8080/my.json"]; | |
// Create a simple dictionary with numbers. | |
NSDictionary *dictionary = @{ @"numbers" : @[@1, @2, @3] }; | |
// Convert the dictionary into JSON data. | |
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:dictionary | |
options:0 | |
error:nil]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Rafał Sroka' | |
import os | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
# Port on which server will run. | |
PORT = 8080 | |
class HTTPRequestHandler(BaseHTTPRequestHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a sample URL. | |
NSURL *url = [NSURL URLWithString:@"http://www.bbc.co.uk/tv/programmes/genres/drama/scifiandfantasy/schedules/upcoming.json"]; | |
// Create a download task. | |
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url | |
completionHandler:^(NSData *data, | |
NSURLResponse *response, | |
NSError *error) | |
{ | |
if (!error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UIColor (Random) | |
+ (UIColor *)randomColor; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ALAssetsLibrary (VideoOrientation) | |
+ (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset; | |
@end |
NewerOlder