Skip to content

Instantly share code, notes, and snippets.

View gcox's full-sized avatar

George Cox gcox

View GitHub Profile
@TomSoderling
TomSoderling / Disable iOS Simulator Incoming Connections Popup.sh
Last active December 14, 2023 10:26
Bash script for turning off the iOS simulator pop-up message
#!/bin/bash
# Script to disable the iOS Simulator app from showing the "Do you want the application xxxx to accept incoming network connections?" pop-up every time the app is run
echo "> Enter password to temporarily shut firewall off"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
echo "> Add Xcode as a firewall exception"
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/MacOS/Xcode
@irace
irace / TabComponent.swift
Last active December 22, 2020 15:38
Easily roll your own `UITabBarController` alternatives. Here’s all the logic you need without assuming anything about your UI.
/**
* A class that can be part of a tabbed navigational interface (expected to be a `UIViewController` but can also be a
* coordinator that proxies through to an underlying controller).
*/
public protocol TabComponent {
/// The tab metadata
var tabItem: TabItem { get }
var viewController: UIViewController { get }
}
@zpasternack
zpasternack / NSTableView+Reordering.m
Last active October 21, 2018 01:09
Category on NSTableView for animating rows, using old and new sorted arrays as input. Updated to support items having been removed or added.
@implementation NSTableView (Reordering)
- (void) moveRowsWithOldObjects:(NSArray*)oldObjects newObjects:(NSArray*)newObjects
{
NSMutableArray* oldSortedArray = [oldObjects mutableCopy];
NSArray* newSortedArray = newObjects;
[self beginUpdates];
@gcox
gcox / gist:9284624
Last active August 29, 2015 13:56
NSFileManager category for getting a list of all applications
#import <Foundation/Foundation.h>
@interface NSFileManager (ApplicationList)
-(NSArray *)applicationList;
@end
@rdhyee
rdhyee / minecraft_do.yml
Last active June 9, 2020 03:44
Ansible playbook to launch a digitalocean droplet and then configure it to run Minecraft based on instructions from https://www.digitalocean.com/community/articles/how-to-set-up-a-minecraft-server-on-linux Note that some things are hardwired: the name of the droplet, the version of minecraft
# http://www.ansibleworks.com/docs/modules.html#digital-ocean
# Create a new Droplet
# Will return the droplet details including the droplet id (used for idempotence)
- name: launch DO droplet
hosts: local
gather_facts: False
tasks:
- name: pwd
@indragiek
indragiek / gist:4659386
Last active December 11, 2015 20:59
Fix for NSSplitView's non integral drawing/frame calculations
// In an NSSplitView subclass
- (void)drawDividerInRect:(NSRect)rect
{
[super drawDividerInRect:NSIntegralRect(rect)];
}
// In NSSplitViewDelegate implementation
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex
@gcox
gcox / gist:1961202
Created March 2, 2012 20:46
Thread-safe singleton pattern using dispatch_once
@interface Something : NSObject
+(Something *)somethingSingleton;
@end
@implementation Something
+(Something *)somethingSingleton {
@panupan
panupan / respondersview.h
Created September 28, 2011 17:51
NSViewController responder chain integration
//
// RespondersView.h
// RespondersView
//
// Created by Panupan Sriautharawong on 9/13/11.
// Copyright 2011 Panupan.com. All rights reserved.
//
#import <Cocoa/Cocoa.h>