Skip to content

Instantly share code, notes, and snippets.

Morgan Dock mmdock

  • San Francisco, CA
Block or report user

Report or block mmdock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mmdock
mmdock / Jailbroken.swift
Created Jul 12, 2019
iOS Simple Jailbroken Test
View Jailbroken.swift
///Discussion:
///In theory, if app is able to have visibility of a file outside the app's environment then it is jailbroken.
///For this test, we will be checking for common files found from various ways of jailbreaking an iOS device.
///As a final test: try writing outside of the app's sandbox.
func isJailbroken() -> Bool{
#if targetEnvironment(simulator)
return false
#else
let fm = FileManager.default
@mmdock
mmdock / prep.py
Last active Jun 18, 2019
A simple file to parse out the value strings from a given key:value separated localization file (assuming 1 per line) using a given separator character. Basically a line splitter for a given file.
View prep.py
#!/usr/bin/env python
import codecs
import optparse
import os
import re
"""
This small script extracts values from a simple key:value localization file.
"""
@mmdock
mmdock / xcsetup
Created Apr 29, 2019
simple script to setup a new environment for Xcode (with maybe an existing repo)
View xcsetup
xcode-select --install
which -s brew
if [[ $? != 0 ]]; then
# Install Homebrew
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "installed Homebrew"
else
sudo brew update
@mmdock
mmdock / difflocal.py
Created Mar 21, 2019
Script to help me compare two .strings files. Use during Xcode build phase to ensure localizations contain all keys
View difflocal.py
#!/usr/bin/env python
import codecs
import optparse
import os
import re
"""
This small script compares Cocoa / iOS development Localizable.strings files.
These are usually UTF-16 and difficult to compare. In addition to that,
the order of the contents of the files varies per export, making diff very
View ImageUploadExample.java
public static String getPath(Context context, Uri uri) {
final boolean needToCheckUri = Build.VERSION.SDK_INT >= 19;
String selection = null;
String[] selectionArgs = null;
// Uri is different in versions after KITKAT (Android 4.4), we need to
// deal with different Uris.
if (needToCheckUri && DocumentsContract.isDocumentUri(context.getApplicationContext(), uri)) {
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
View Refresh Pods
#!/bin/bash
killall "Xcode"
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.5.3
rm -rf Pods/
pod cache clean --all
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
open MyApp.xcworkspace
You can’t perform that action at this time.