Skip to content

Instantly share code, notes, and snippets.

View jparishy's full-sized avatar

Julius Parishy jparishy

View GitHub Profile
@jparishy
jparishy / gist:50e141e012f01dc6532e
Last active December 2, 2016 09:32
WIP: Swift Optionals for Objective-C Developers

Swift Optionals for the Objective-C Developer

This is Part 1 of a series of articles advocating Swift to the often stubborn Objective-C developer.

Some time has passed since WWDC 2014 and the reveal of the Swift programming language. The hype has settled and most of us have gotten on with our lives continuing to write our code in Objective-C, toying with Swift in our free time or using it for small modules within our production code. There have indeed been some early adopters writing new apps from scratch in the language, but I imagine that has more to do with the ability to announce the fact rather than any benefit to the programmer or business. After quite some fanfare, nothing has really changed.

I believe this is a good thing. Objective-C has been validated as a production-ready programming language for decades. Swift... not so much. It was necessary for Apple to release Swift when they did in order to garner the interest of the community and incorporate feedback. Creating a programming language i

//
// FunctionPointer.h
// AudioServicesTest
//
// Created by Julius Parishy on 11/9/14.
// Copyright (c) 2014 Julius Parishy. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
@jparishy
jparishy / gist:b9179ad63518fc6d4d5b
Created October 20, 2014 16:30
Inverted rounded rect mask for a view (content in the middle shown, outside part of rounded rect is set to white)
- (void)configureInvertedRoundedRectMaskForView:(UIView *)view
{
const CGFloat cornerRadius = 5.0f;
const CGRect rect = CGRectInset(view.bounds, 10.0f, 0.0f);
UIBezierPath *rectPath = [UIBezierPath bezierPathWithRect:view.bounds];
UIBezierPath *roundedRectPath = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:cornerRadius];
[rectPath appendPath:roundedRectPath];
@jparishy
jparishy / gist:1eaca3e8bcc89e120e89
Created September 11, 2014 01:20
Category on UIView for adding constraints for a subview that fills itself with specific insets
@implementation UIView (LECommonLayoutConstraints)
- (void)le_addContraintsForFilledView:(UIView *)view insets:(UIEdgeInsets)insets
{
NSDictionary *metrics = @{
@"left" : @(insets.left),
@"top" : @(insets.top),
@"right" : @(insets.right),
@"bottom" : @(insets.bottom)
};
#if DEBUG
#define UIViewSetLayoutDebuggingIdentifier(view, identifier) \
[view setValue:identifier forKey:@"_layoutDebuggingIdentifier"]
#else
#define UIViewSetLayoutDebuggingIdentifier(view, identifier)
#endif
@jparishy
jparishy / SwiftData.swift
Created August 21, 2014 03:10
Core Data in Swift
//
// main.swift
// SwiftData
//
// Created by Julius Parishy on 8/20/14.
// Copyright (c) 2014 le. All rights reserved.
//
import Foundation
import CoreData
@jparishy
jparishy / Example.swift
Last active August 29, 2015 14:02
Abusing Swift Enums for easier JSON parsing
/*
data.json
[
{
"name": {
"first": "Julius",
"last": "Parishy"
},
"hobbies": [
"programming",
@jparishy
jparishy / main.js
Created February 6, 2014 16:27
Chrome Extension for switching between header (.h) and source files (.m,.mm,.c,.cpp) on GitHub with the Xcode Shortcut Ctrl+Command+Up
chrome.commands.onCommand.addListener(function(command) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var current = tabs[0];
var url = current.url;
var ext = url.substring(url.lastIndexOf("."));
if(ext === ".h")
require 'sinatra'
require 'RMagick'
def delay(fps)
(100.0 / fps)
end
post '/gifify' do
content_type "image/gif"
@jparishy
jparishy / gist:7953819
Created December 14, 2013 00:00
Watcher
//
// main.m
// FSEventsTest
//
// Created by Julius Parishy on 8/20/13.
// Copyright (c) 2013 Fitocracy. All rights reserved.
//
#import <Foundation/Foundation.h>