Skip to content

Instantly share code, notes, and snippets.

View joncardasis's full-sized avatar
Hold on a sec. My pour over is on its second bloom.

Jon Cardasis joncardasis

Hold on a sec. My pour over is on its second bloom.
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 / Storing-Images-On-Github.md
Last active November 13, 2024 21:29
Storing Images and Demos in your Repo

Storing Images and Demos in your Repo

In this quick walkthough you'll learn how to create a separate branch in your repo to house your screenshots and demo gifs for use in your master's readme.

How to

1. Clone a fresh copy of your repo

In order to prevent any loss of work it is best to clone the repo in a separate location to complete this task.

2. Create a new branch

Create a new branch in your repo by using git checkout --orphan assets

@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 / CreditCardGenerator.playground
Created August 15, 2016 19:32
A Swift playground to generate valid credit card numbers for testing.
import Foundation
enum CreditCardType{
case Visa
case Visa13Digit
case MasterCard
case Discover
case AmericanExpress
case DinersClubUSA
case DinersClubCanada
@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 / 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 / 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; }