Skip to content

Instantly share code, notes, and snippets.

@thefotes
thefotes / xop.sh
Created February 23, 2020 19:28
Opens either xcodeproj or xcworkspace in CWD
#!/bin/bash
set -e
xcodeproj=`find . -maxdepth 1 -name "*.xcodeproj"`
proj_name=`echo $xcodeproj | sed 's/.\///g' | sed 's/.xcodeproj//g'`
xcworkspace=`find . -maxdepth 1 -name "$proj_name.xcworkspace"`
if [[ ! -z $xcworkspace && -e $xcworkspace ]]; then
open $xcworkspace
@thefotes
thefotes / iterator.py
Created September 19, 2017 14:50
Lambda function for iterating over a set of items as part of a step function.
#!/usr/bin/env python3
def lambda_handler(event, context):
iterator = event['iterator']
index = iterator['index']
step = iterator['step']
count = iterator['count']
items = iterator['items']
index += step
@thefotes
thefotes / configure_Iterator.py
Created September 19, 2017 14:49
Lambda function for configuring a step function iterator.
#!/usr/bin/env python3
def lambda_handler(event, context):
count = len(event['input_data']['items'])
index = -1
step = 1
items = event['input_data']['items']
return {'index': index, 'count': count, 'step': step, 'items': items}
import Foundation
protocol PJPageControlUsable {
var indicatorType: PJPageControl.Indicator { get }
}
protocol PJPageControlDelegate: class {
//
// PJNotificationCenter.m
// NotificationSample
//
// Created by Peter Foti on 6/21/16.
// Copyright © 2016 Peter Foti. All rights reserved.
//
#import "PJNotificationCenter.h"
#import "PJNotificationKey.h"
@thefotes
thefotes / ow.sh
Created January 25, 2016 18:46
Checks current directory for either .xcworkspace or .xcodeproj, if it finds xcworkspace opens that, otherwise opens xcodeproj
#!/bin/bash
set -e
xcodeproj=`find . -maxdepth 1 -name "*.xcodeproj"`
proj_name=`echo $xcodeproj | sed 's/.\///g' | sed 's/.xcodeproj//g'`
xcworkspace=`find . -maxdepth 1 -name "$proj_name.xcworkspace"`
if [[ ! -z $xcworkspace && -e $xcworkspace ]]; then
open $xcworkspace
@thefotes
thefotes / localized.swift
Created January 17, 2016 13:33
Cleaner localized strings with Swift protocols and enums.
import Foundation
// Localized string struct that has single static method which accepts a `Localizeable` value.
struct LocalizedString {
// Usage: LocalizedString.localizedStringForValue(NavBarTitle.Home)
static func localizedStringForValue<T: Localizeable>(localizeableValue: T) -> String {
return NSLocalizedString(localizeableValue.localizedString, comment: localizeableValue.localizedStringComment)
@thefotes
thefotes / dupeImports.sh
Created June 28, 2015 19:11
Given a path to an Xcode project, loops through all files and checks to see if any files have been imported more than once in the same file.
#!/bin/bash
set -e
read -e -p "Enter path to Xcode project: " FILES
eval FILES=$FILES
find "$FILES" -type f \( -name "*.h" -or -name "*.m" \) | while read -r f;
do
@thefotes
thefotes / NSObject+PropertyDictionary.m
Created April 22, 2015 13:54
Returns dictionary with property names as keys, and their values as the object
// NSObject+PropertyDictionary.m
//
// Created by Peter Foti on 4/22/15.
#import "NSObject+PropertyDictionary.h"
#import <objc/runtime.h>
@implementation NSObject (PropertyDictionary)
- (NSDictionary *)toDictionary
@thefotes
thefotes / LineCount
Created April 14, 2015 14:45
Counts number of files in each subdirectory of the current directory
#!/bin/bash
set -e
for d in */; do
count=$(find $d -type f | wc -l)
if [[ $count -eq 1 ]]; then
result="$d $count"
echo $result >> results.txt
fi