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 / 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 / jailbreak_protect.c
Last active August 28, 2025 11:56
iOS - Prevent debugger attachment in a jailbroken environment. Obfuscated by assembly and symbol mangling.
//
// jailbreak_protect.c
//
// Created by Jonathan Cardasis (C) on 10/11/19.
// Copyright © 2019 Jonathan Cardasis (C). All rights reserved.
//
// Source: https://medium.com/@joncardasis/mobile-security-jailbreak-protection-84aa0fbc7b23
// Simply include this file in your project and ensure the file's Target Membership
// is set to your app.
@joncardasis
joncardasis / jb_protect_all_archs.h
Last active August 23, 2021 11:32
jb_protect for all device architectures
//
// jailbreak.h
// jailbreak-protect
//
// Created by Jonathan Cardasis (C) on 10/11/19.
// Copyright © 2019 Jonathan Cardasis (C). All rights reserved.
//
#ifndef jailbreak_h
#define jailbreak_h
@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 / 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 / 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 / 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 \
@joncardasis
joncardasis / UIViewController+StatusBar.swift
Created July 10, 2018 19:12
A swizzling method which introduces a `statusBarStyle` to control the display of the status bar on a view controller.
//
// UIViewController+StatusBar.swift
// StatusBarTesApp
//
// Created by Jonathan Cardasis (C) on 7/10/18.
// Copyright © 2018 Jonathan Cardasis. All rights reserved.
//
import UIKit
@joncardasis
joncardasis / ColladaAnimationForXcode.py
Last active September 15, 2025 05:03
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