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 / setIcon.sh
Created May 3, 2017 16:00
Set the Finder icon of a single file in macOS
#!/bin/sh
# Sets an icon for a file
# Parameters:
# $1 icon_source - file path to the icon soruce (a .icns file)
# $2 file_path - file path the the destination file to change the icon of
icon_source=$1
file_path=$2
generated_icon=".icon.rsrc"
@joncardasis
joncardasis / BasicAnimation.swift
Last active May 31, 2017 19:52
[Medium Gists] CATransaction Medium Post
let cornerAnimation = CABasicAnimation(keyPath: #keyPath(CALayer.cornerRadius))
cornerAnimation.fromValue = oldValue
cornerAnimation.toValue = newValue
cornerAnimation.duration = 1.0
styledButton.layer.cornerRadius = newValue
styledButton.layer.add(cornerAnimation, forKey: #keyPath(CALayer.cornerRadius))
@joncardasis
joncardasis / Transaction.swift
Created May 31, 2017 19:52
[Medium Gists] CATransation
CATransaction.begin()
CATransaction.setAnimationDuration(0.5)
styledButton.layer.opacity = 0.5
styledButton.layer.backgroundColor = UIColor.white.cgColor
CATransaction.commit()
@joncardasis
joncardasis / CustomTimingFunction.swift
Last active May 31, 2017 20:21
[Medium Gists] Custom CATransaction Timing Function
let timingFunction = CAMediaTimingFunction(controlPoints: 0.65, -0.55, 0.27, 1.55)
//...
CATransaction.setAnimationTimingFunction(timingFunction)
//... Do your UIKit animation
@joncardasis
joncardasis / CommonAnimation.swift
Created May 31, 2017 20:37
[Medium Gists] Common Animation Pattern
UIView.animate(withDuration: 1.0) {
self.button.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
}
@joncardasis
joncardasis / BadAnimation.swift
Last active May 31, 2017 21:08
[Medium Gists] Bad Animation case
let newButtonWidth: CGFloat = 60
UIView.animate(withDuration: 2.0) {
self.styledButton.frame = CGRect(x: 0, y: 0, width: newButtonWidth, height: newButtonWidth)
self.styledButton.center = self.view.center
self.styledButton.layer.cornerRadius = newButtonWidth/2
}
@joncardasis
joncardasis / FavConfigs.md
Created July 3, 2017 15:20
Favorite Configurations

Atom

Favorite Packages

  • MagicPython: Python 3 syntax highlighting support
  • atom-html-preview: Preview html properly
  • markdown-themeable-pdf: For turning markdowns into beautiful pdfs
  • pdf-view: View pdfs inside atom
    apm install MagicPython atom-html-preview markdown-themeable-pdf pdf-view
    
@joncardasis
joncardasis / main.m
Created July 28, 2017 14:21
Command line Cocoa program which overlays a png over another image - great for image banners on app icons
//
// ImageMerger
//
// Created by Cardasis, Jonathan (J.) on 4/15/16.
// Copyright © 2016 Cardasis, Jonathan (J.). All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
@joncardasis
joncardasis / obtain_public_key.md
Created August 10, 2017 19:55
Obtain Public Key from iOS .mobileprovision profile
  1. Install homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
  1. Install XMLStarlet for xml parsing:
brew install xmlstarlet
@joncardasis
joncardasis / ConsoleUser.swift
Created December 5, 2017 16:26
Retrieve the console username of the user running a Swift program
import SystemConfiguration
/**
Retrieve the console username of the user running the program.
Will be the same result as a `whoami` command.
*/
public func systemConsoleUsername() -> String? {
var uid: uid_t = 0
var gid: gid_t = 0