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 / ColladaAnimationForXcode.py
Last active August 10, 2021 09:31
Convert Collada (.DAE) animation files for Xcode Scenekit Animation use by removing unnecessary data.
#!/usr/local/bin/python
# Jonathan Cardasis, 2018
#
# Cleans up a collada `dae` file removing all unnessasary data
# only leaving animations and bone structures behind.
# Combines multiple animation sequences into a single animation
# sequence for Xcode to use.
import sys
import os
import re
@joncardasis
joncardasis / optimizeImage.sh
Created April 5, 2019 20:28
Compresses and optimizes png image sizes for a given file or directory via pngquant.
#!/bin/bash
# Compresses and optimizes png image sizes for a given file or directory.
# @author: Jonathan Cardasis
CHECK_MARK="\033[0;32m\xE2\x9C\x94\033[0m"
PNGQUANT_BINARY_URL="https://pngquant.org/pngquant.tar.bz2"
optimize() {
ORIGINAL_PATH="$1"
NEW_PATH="$ORIGINAL_PATH.new"
@joncardasis
joncardasis / jsBundleCache.sh
Created July 23, 2019 21:11
Detect if a jsbundle is dirty and needs to be rebuilt or if just the source code needs to be rebuilt
#!/bin/bash -e
# Check if JS code in a provided root folder has been changed.
# **SHOULD BE RUN WITH XCODE ENV VARIABLES**
#
# Creates a 'jsbundle-hashtable' in xcode product build directory to determine if
# the jsBundle needs to be rebuilt based on src directory hash value.
print_usage() {
printf "Usage: "
printf " %-20s %s\n" "--lookup-hash <target_name>" "Return hash value for <target_name> in table. Otherwise nothing is returned."
@joncardasis
joncardasis / build_universal_fat_framework.sh
Last active March 2, 2020 17:14
Build universal ios fat framework
#!/bin/bash
#
# Builds the a framework for both the 64bit iOS architecture and
# a 64bit simulator architecture, combining the two into a single FAT framework.
#
set -e -o pipefail
print_available_options() {
printf "Usage: ./build_universal_ios_framework.sh -workspace <workspacepath> -target <targetname> -configuration <configurationname> -destination <destinationpath>\n\n"
printf "Options:\n"
@joncardasis
joncardasis / UIFont+BestFit_DEPRECATED.swift
Last active January 31, 2020 22:19
[DEPRECATED] Swift Dynamic Font Size for Bounds
import UIKit
extension UIFont {
/**
Will return the best approximated font size which will fit in the bounds.
If no font with name `fontName` could be found, nil is returned.
*/
static func bestFitFontSize(for text: String, in bounds: CGRect, fontName: String) -> CGFloat? {
var maxFontSize: CGFloat = 32.0 // UIKit best renders with factors of 2
@joncardasis
joncardasis / FVPasswordManager.py
Created May 3, 2018 20:17
A python script to check if a FileVault password has ever been used on macOS before.
import os, sys
import re
import base64
import hashlib
import plistlib
from binascii import unhexlify
class FVPasswordManager(object):
PL_SALTED_HASH_ARRAY_KEY = 'SALTED-SHA512-PBKDF2'
@joncardasis
joncardasis / useOrientation.ts
Last active December 4, 2019 19:05
Simple React Native rotation lock with React Hooks
/**
1. Install and configure `react-native-orientation-locker`.
2. In both the iOS and Android projects, set the allowed platform orientations to everything except upside down.
*/
import { useEffect } from 'react';
import Orientation, { OrientationType } from 'react-native-orientation-locker';
export function useLockOrientationPortrait() {
Orientation.lockToPortrait();
@joncardasis
joncardasis / build_openssl.sh
Created January 26, 2018 15:11
Shell Script to Build i386 and x86 flavors of OpenSSL for macOS. Will create a standalone "OpenSSL" folder with binaries, headers, and license.
#!/bin/bash
# Jonathan Cardasis - 2018
# Builds OpenSSL libssl and libcrypto for macOS
# binary distribution (i386 and x86).
VERSION="1.1.0g"
VERSION_SHA256_CHECKSUM="de4d501267da39310905cb6dc8c6121f7a2cad45a7707f76df828fe1b85073af"
####################################
curl -O https://www.openssl.org/source/openssl-$VERSION.tar.gz
@joncardasis
joncardasis / get-ip.sh
Created February 4, 2019 19:05
Gets the machine's IP address
#!/bin/bash
IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\ -f2 | awk 'NR==1{print $1}')
@joncardasis
joncardasis / gource.sh
Created January 29, 2019 21:59
gource - generate gource video for git repo
# Install ffmpeg
brew install ffmpeg
# Install gource
brew install gource
# Generate video
gource \
--hide filenames \
--seconds-per-day 0.1 \