Skip to content

Instantly share code, notes, and snippets.

View sundeepgupta's full-sized avatar

Sundeep Gupta sundeepgupta

View GitHub Profile
@sundeepgupta
sundeepgupta / create-fat-framework.sh
Last active September 16, 2024 07:56
Script to create a universal or "fat" binary for an iOS framework.
#!/bin/bash
# Adapted from http://stackoverflow.com/questions/24039470/xcode-6-ios-creating-a-cocoa-touch-framework-architectures-issues/26691080#26691080
# and https://gist.github.com/cromandini/1a9c4aeab27ca84f5d79
# Create a new aggregate target.
# For the automatically generated scheme, change its build config to "release".
# Ensure this target's "product name" build setting matches the framework's.
# Add a run script with `source "${PROJECT_DIR}/path_to_this_script`
@sundeepgupta
sundeepgupta / remap_keys.md
Created May 1, 2024 21:11
How to remap keys in macOS Sonoma
  1. Go to https://hidutil-generator.netlify.app/ to create the ~/Library/LaunchAgents/com.local.KeyRemapping.plist file.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.local.KeyRemapping</string>
@sundeepgupta
sundeepgupta / animated-ellipsis.swift
Created March 2, 2017 19:35
Swift Animating Ellipsis Loader
class LoadingLabel: UILabel {
var timer: Timer?
let states = [".", "..", "..."]
var currentState = 0
func start() {
stop(withText: "")
timer = Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(update), userInfo: nil, repeats: true)
timer?.fire()
@sundeepgupta
sundeepgupta / thin-frameworks.sh
Created February 23, 2017 13:58
Bash script to thin fat iOS frameworks. Strips non-valid architectures from fat framework binaries.
# Adapted from https://github.com/realm/realm-cocoa/blob/master/scripts/strip-frameworks.sh
# This script strips all non-valid architectures from dynamic libraries in
# the application's `Frameworks` directory which is required for App Store submission.
#
# The following environment variables are required:
#
# BUILT_PRODUCTS_DIR
# FRAMEWORKS_FOLDER_PATH
# VALID_ARCHS
@sundeepgupta
sundeepgupta / Bash Prompt with Git Status Info
Created June 24, 2014 18:17
Bash Prompt with Git Status Info
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@sundeepgupta
sundeepgupta / thread-safe-dependency-injection.swift
Created April 13, 2017 15:38
Swift thread-safe dependency injection
import Foundation
protocol HatType { }
class Hat: HatType {
init() {
print("real hat 1")
}
}
@sundeepgupta
sundeepgupta / normal.swift
Last active June 4, 2018 20:24
FlatMap Article - Normal Operation
project.addDeveloper(jim) // Jim started coding...
jim.pushCommit("1") // CI is building Commit(author: "Jim", hash: "1").
project.addDeveloper(anna) // Anna started coding...
jim.pushCommit("2") // CI is building Commit(author: "Jim", hash: "2").
anna.pushCommit("3") // CI is building Commit(author: "Anna", hash: "3").
jim.pushCommit("4") // CI is building Commit(author: "Jim", hash: "4").
@sundeepgupta
sundeepgupta / project-completion.swift
Last active May 18, 2018 13:36
FlatMap Article - Project Completion
project.addDeveloper(jim) // Jim started coding...
project.stop()
project.addDeveloper(bob)
bob.pushCommit("1")
jim.pushCommit("2") // CI is building Commit(author: "Jim", hash: "2").
@sundeepgupta
sundeepgupta / developer-completions.swift
Last active May 18, 2018 13:36
FlatMap Article - Developer Completions
project.addDeveloper(jim) // Jim started coding...
project.addDeveloper(anna) // Anna started coding...
jim.stopCoding()
anna.stopCoding()
jim.pushCommit("1")
project.addDeveloper(bob) // Bob started coding...
bob.pushCommit("2") // CI is building Commit(author: "Bob", hash: "2").
@sundeepgupta
sundeepgupta / ci-completion.swift
Last active May 17, 2018 14:29
FlatMap Article - CI Completion
project.addDeveloper(jim) // Jim started coding...
project.addDeveloper(anna) // Anna started coding...
project.stop()
jim.stopCoding()
anna.stopCoding() // CI stopped.
project.addDeveloper(bob)
bob.pushCommit("1")
jim.pushCommit("2")