Skip to content

Instantly share code, notes, and snippets.

View joncardasis's full-sized avatar
🔬
📱 Probing iOS internals...

Jon Cardasis joncardasis

🔬
📱 Probing iOS internals...
View GitHub Profile
@joncardasis
joncardasis / SetNetworkInterfaceProxies.sh
Created July 15, 2016 19:07
Bash script to set network proxies for network interfaces in OSX
#!/bin/bash
# Set automatic network proxies in System Preferences
# The specified proxy url below will be set for both the Ethernet and Wi-Fi interfaces
PROXY_URL="http://www.example.com/proxy.js" #automatic-proxy url
###########
LISTED_NETWORK_SERVICES=$(networksetup -listallnetworkservices | sed '/An asterisk ([*]) denotes that a network service is disabled./d; s/^[*]//')
IFS=$'\n' SERVICES=($LISTED_NETWORK_SERVICES) #Separate string into array of services
@joncardasis
joncardasis / SetupGithubAccess.sh
Created July 15, 2016 19:45
Setup script for cloning git submodules through an enterprise proxy
#!/bin/bash
# Sets up and configured Git to work with an enterprise proxy for
# cloning submodules through the git/https protocol. Tunnels all git
# traffic through the proxy to allow for these commands.
#Set proxies:
http_proxy="proxy.example.com:83"
http_proxy_port="83" #specifically specify the port only
https_proxy="proxy.example.com:83"
@joncardasis
joncardasis / xcode_edit_provisioning.rb
Last active September 21, 2016 14:16
Replace Xcode Build Settings for Mobile Provisioning using Xcodeproj
#!/usr/bin/ruby
#
# Usage:
# ./{program} {filepath} {provisioning profile}
# Example: ./{program} path/to/project/myapp.xcodeproj EB75C687-2F3E-4D57-B895-0F515DA178CC
#
require 'xcodeproj'
project_path = ARGV[0]
@joncardasis
joncardasis / VMWareRetinaDisplayFix.sh
Created October 5, 2016 16:21
VMWare Fusion OSX Retina Display Settings Fix
#!/bin/bash
# Problem : OSX in VMWare displays at too high a resolution
# Fix : Enable custom resolution setting for a screen size in perferences
#
# Run this script to turn on display settings in system preferences to allow OSX in VMWare to display
# at a proper resolution for the screensize
sudo defaults write /Library/Preferences/com.apple.windowserver.plist DisplayResolutionEnabled -bool true
echo "Reboot this VM and select the proper display setting in System Preferences."
@joncardasis
joncardasis / Logging.swift
Created October 24, 2016 21:09
A simple and quick logging file for Swift
//
// Logging.swift
// JCLogging-Swift
//
// Created by Cardasis, Jonathan (J.) on 8/29/16.
// Copyright © 2016 Jonathan Cardasis. All rights reserved.
//
import Foundation
@joncardasis
joncardasis / SetEnterpriseSSHProxy.sh
Created December 2, 2016 17:17
Set SSH Enterprise Proxies
#!/bin/bash
# This program configures your ssh configuration file to
# allow all ssh traffic to pass though a specified proxy.
#Install corkscrew - Enables TCP traffic through a proxy
brew install corkscrew
#Ensure corkscrew was installed
hash corkscrew 2>/dev/null || { echo >&2 "corkscrew was not properly installed from homebrew. Ensure it is properly linked."; exit 1; }
@joncardasis
joncardasis / String+Levenshtein.swift
Last active December 12, 2016 19:24
Levenshtein Algorithm in Swift 3 - Calculates the number of differences between two strings
extension String{
private func min(numbers: Int...) -> Int {
return numbers.reduce(numbers[0], {$0 < $1 ? $0 : $1})
}
func distanceFrom(string: String) -> Int{
let x = Array(self.utf16) //convert to a unicode 16 format for comparison
let y = Array(string.utf16)
//Create the Levenshtein 2d matrix, which has an extra preceeding row and column
@joncardasis
joncardasis / iOS-CI.md
Last active March 27, 2017 17:53
Common Issues and Resolutions to iOS CI

iOS-CI Troublshooting and Tricks

Neat Bash Snippits

Retrieve the latest simulator sdk

LATEST_SIMULATOR_SDK=$(xcodebuild -showsdks | grep "Simulator - iOS" | grep -o '\d*\.\d*' | head -n 1)

Change Jenkins from a LaunchDaemon to a LaunchAgent

This will allow Jenkins to run windowed processes like the iOS Simulator. Stop the Jenkins service and move to launch agents:

@joncardasis
joncardasis / LinguisticsFix.md
Last active April 24, 2017 15:57
Fix GitHub Displaying Incorrect Languages in Repo

Fix Linguistics in Your Repo

Sometimes GitHub will mismark your repo's languages.

I had a C++ project displaying that a large portion was Objective-C because of a single header file from SQLite3.h.

Step 1:

Create a .gitattributes file in your root. Mine looks like this:

@joncardasis
joncardasis / GitFix.md
Last active May 1, 2017 16:28
A list of git commands that I found very helpful and should remember.

Rewriting Commit History

This will rewrite the branch's commit history and is useful for combining users if two emails were used for a single user at any point.

Note: Since this edits all history, everyone will need to re-clone the repo in order to get the correct history on their local machines.

A list of users who committed can be viewed via git shortlog -s -n.

$ git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "jonViaDesktop@localhost" ];
 then