Skip to content

Instantly share code, notes, and snippets.

r3econ r3econ

Block or report user

Report or block r3econ

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
@r3econ
r3econ / gist:e044c00f026c3f47610a
Created Jul 3, 2015
NSHTTPCookieStorage (RAFExtensions)
View gist:e044c00f026c3f47610a
@implementation NSHTTPCookieStorage (RAFExtensions)
- (void)logCookies;
{
NSMutableString *descriptions = [NSMutableString string];
for (NSHTTPCookie *cookie in [self cookies])
{
[descriptions appendString:[self cookieDescription:cookie]];
View NSLayoutConstraint+Extensions.h
//
// 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.
//
@r3econ
r3econ / UIView+AnimationExtensions.h
Created Apr 22, 2014
UIView Animation Extensions
View UIView+AnimationExtensions.h
//
// 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.
//
@r3econ
r3econ / gist:9959500
Created Apr 3, 2014
Smooth out the CMMotionManager acceleration readings with Low Pass Filter.
View gist:9959500
- (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);
@r3econ
r3econ / gist:9953196
Created Apr 3, 2014
Posting JSON file using NSURLSession.
View gist:9953196
// 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];
@r3econ
r3econ / HTTPServer.py
Created Apr 2, 2014
HTTP server deamon in Python. Perfect for testing GET/POST requests.
View HTTPServer.py
__author__ = 'Rafał Sroka'
import os
from http.server import BaseHTTPRequestHandler, HTTPServer
# Port on which server will run.
PORT = 8080
class HTTPRequestHandler(BaseHTTPRequestHandler):
@r3econ
r3econ / gist:9923319
Created Apr 1, 2014
Downloading JSON file using NSURLSession.
View gist:9923319
// 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)
@r3econ
r3econ / UIColor+Random.h
Last active Aug 29, 2015
UIColor category for creating a random color.
View UIColor+Random.h
@interface UIColor (Random)
+ (UIColor *)randomColor;
@end
@r3econ
r3econ / ALAssetsLibrary+VideoOrientation.h
Created Mar 25, 2014
ALAssersLibrary category for getting the video's orientation.
View ALAssetsLibrary+VideoOrientation.h
@interface ALAssetsLibrary (VideoOrientation)
+ (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset;
@end
@r3econ
r3econ / UIButton+VerticalLayout.h
Last active Oct 15, 2018
UIButton category for centering title label and image vertically. The text label is placed below the image.
View UIButton+VerticalLayout.h
@interface UIButton (VerticalLayout)
- (void)centerVerticallyWithPadding:(float)padding;
- (void)centerVertically;
@end
You can’t perform that action at this time.