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 / Storing-Images-On-Github.md
Last active February 2, 2024 02:30
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 / MenuBarOptionKeyListener.swift
Created January 5, 2018 17:35
Showing/Hiding Menu Bar Items If OPTION is held down (Swift macOS AppKit)
class AppDeleatate: NSObject, NSApplicationDelegate {
fileprivate var optionalMenuItems = [NSMenuItem]()
//...
func applicationDidFinishLaunching(_ aNotification: Notification) {
//...
let specialItem = NSMenuItem(title: MenuBarItemLabelText.specialItem, action: #selector(doNeatAction), keyEquivalent: "")
specialItem.isHidden = true
optionalMenuItems.append(specialItem)
@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 / UIFont+BestFit.swift
Last active May 11, 2023 03:20
Swift Dynamic Font Size for Bounds
extension UIFont {
/**
Will return the best font conforming to the descriptor which will fit in the provided bounds.
*/
static func bestFittingFontSize(for text: String, in bounds: CGRect, fontDescriptor: UIFontDescriptor, additionalAttributes: [NSAttributedStringKey: Any]? = nil) -> CGFloat {
let constrainingDimension = min(bounds.width, bounds.height)
let properBounds = CGRect(origin: .zero, size: bounds.size)
var attributes = additionalAttributes ?? [:]
@joncardasis
joncardasis / WebServer.py
Created February 7, 2017 21:08
A simple and quick HTTP web server in Python
"""
Author: Jonathan Cardasis
"""
import socket
import signal # Allow socket destruction on Ctrl+C
import sys
import time
import threading
@joncardasis
joncardasis / jailbreak_protect.c
Last active December 1, 2022 02:33
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 / 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 / SkeletonView.tsx
Last active July 20, 2022 23:38
Simple SkeletonView react-native component (react-native-reanimated v1.9.0)
import React, { useCallback, useMemo, useRef, useState } from 'react';
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import Animated, {
block,
Clock,
cond,
Easing,
eq,
set,
@joncardasis
joncardasis / usePromise.ts
Created September 21, 2021 16:33
usePromise React hook with TypeScript. React-ify promise resolutions
import { useCallback, useState, useRef, useEffect } from 'react';
const usePromise = <T, U extends any[]>(operation: (...args: U) => Promise<T>) => {
const [data, setData] = useState<T>();
const [error, setError] = useState<Error>();
const [loading, setLoading] = useState(false);
const mounted = useRef<boolean>(true);
useEffect(
() => () => {
@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