Skip to content

Instantly share code, notes, and snippets.

View justin's full-sized avatar

Justin Williams justin

View GitHub Profile
@justin
justin / sim.zsh
Last active January 18, 2023 20:21
Convenience wrapper around the simctl command to perform operations related to iOS simulators.
#!/usr/bin/env zsh
#
# Convenience wrapper around the simctl command to perform operations related to iOS simulators.
# Author: Justin Williams (@justin)
#
# Usage: sim <options> <subcommand>
#
# This script is designed to work with ZSH. ymmv with other shells.
set -e
@justin
justin / xcode_switch
Last active July 4, 2019 01:02
Check for the existence of an .xcoderc file in the root of a directory and attempt to switch to that Xcode version + update Carthage
#!/bin/zsh
#
# Check for the existence of an .xcoderc in the root of a project and update the DEVELOPER_DIR
# to point to that specific version of Xcode. Update Carthage dependencies as well.
#
# This is useful for all the switching between Xcode 10.x and 11.x as I am doing presently.
#
# Usage:
# xcode_switch [--no-bootstrap] [version_number]
#

Keybase proof

I hereby claim:

  • I am justin on github.
  • I am justinwme (https://keybase.io/justinwme) on keybase.
  • I have a public key ASDBnz525aVsN7y7rHcRDjMt2ZOyhPTwUniM0mSxrtJpzwo

To claim this, I am signing this object:

import KeychainAPI
let keychain: Keychain = Keychain(service: "com.secondgear.myapp", accessibility: Accessibility.WhenUnlocked)
let userAccount = Account(userName: "[email protected]", secret: "lovesecretsexgod")
keychain.add(userAccount)
let fetchedAccount:Account? = keychain.accountFor("[email protected]")
if (fetchedAccount != nil)
{
fetchedAccount?.secret = "newpassword"
@justin
justin / gist:aafce8a85ee9b0595494
Created June 14, 2014 12:52
The old way of handling orientation and different devices
UIDevice *device = [UIDevice currentDevice];
UIDeviceOrientation currentOrientation = device.orientation;
BOOL isPhone = (device.userInterfaceIdiom == UIUserInterfaceIdiomPhone);
BOOL isTallPhone = ([[UIScreen mainScreen] bounds].size.height == 568.0);
if (UIDeviceOrientationIsPortrait(currentOrientation) == YES)
{
// Do Portrait Things
if (isPhone == YES)
{
// Do Portrait Phone Things
public async void RemoveDevices()
{
CloudTableClient client = account.CreateCloudTableClient();
CloudTable devicesTable = client.GetTableReference("PushNotificationDeviceTable");
//// Good Form
await devicesTable.CreateIfNotExistsAsync();
// Entity Resolver
EntityResolver<PushNotificationDevice> deviceResolver = (pk, rk, ts, props, etag) =>
#import <objc/objc-runtime.h>
#import "UIView+SGAutoLayoutExtensions.h"
@implementation UIView (SGAutoLayoutExtensions)
#ifdef DEBUG
- (NSString *)nsli_description
{
return [self restorationIdentifier] ?: [NSString stringWithFormat:@"%@:%p", [self class], self];
import statusInfo = require('./StatusInfo');
import commentInfo = require('./CommentInfo');
var uuid = require('node-uuid');
/**
Various types of user notifications that we can send.
The numeric values are sent to the client apps (Android, iOS, etc) so be careful changing them
*/
enum NotificationType {
@justin
justin / gist:11116873
Created April 20, 2014 15:29
web.config for carpeaqua
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="false" />
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" responseMode="File" path="404.html" />
</httpErrors>
<rewrite>
<rules>
@justin
justin / gist:8886529
Created February 8, 2014 16:49
How I fixed my weird NSRegularExpression issue.
BOOL RSHasMarkdownLinks(NSString *x)
{
NSString *searchText = x;
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\[([^\\[]+)\\]\\(([^\\)]+)\\)" options:0 error:&error];
NSUInteger numberOfMatches = [regex numberOfMatchesInString:searchText options:0 range:NSMakeRange(0, [searchText length])];
return (numberOfMatches > 0);
}