Skip to content

Instantly share code, notes, and snippets.

View karosLi's full-sized avatar
🎯
Focusing

Karosli karosLi

🎯
Focusing
View GitHub Profile
@karosLi
karosLi / command.txt
Created November 2, 2023 06:24 — forked from nrk/command.txt
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
@karosLi
karosLi / UIImage_ImageHelper.h
Created February 2, 2023 10:17 — forked from JoeOsborn/UIImage_ImageHelper.h
A UIImage to BGRA8 conversion category
/*
* The MIT License
*
* Copyright (c) 2011 Paul Solt, PaulSolt@gmail.com
* Modifications Copyright (c) 2011 Joe Osborn, josborn@universalhappymaker.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@karosLi
karosLi / Notes.md
Created September 28, 2022 03:53 — forked from mhamilt/Notes.md
Metal Compute Shader Example in Swift and Objective C

Notes

Create a command line target in xcode either in Swift or Obj-C. add a metal file to the project and copy and paste the respective code into each file.

@karosLi
karosLi / Makefile
Created September 28, 2022 03:52 — forked from wakita/Makefile
Metal compute shader example
SDK = xcrun -sdk macosx
all: compute.metallib compute
compute.metallib: Compute.metal
# Metal intermediate representation (.air)
$(SDK) metal -c -Wall -Wextra -std=osx-metal2.0 -o /tmp/Compute.air $^
# Metal library (.metallib)
$(SDK) metallib -o $@ /tmp/Compute.air

Understanding UIViewController Rotation

Problem

To enable the rotation of a single view controller used to display the preview of Images/Videos. It is intuitive to allow user to rotate there device and screen changes accordingly, so it feels pleasant. But to achieve this, we need to enable the (almost) all Supported Device orientations.

Ex: `Portrait`, `LandscapeLeft`, `LandscapeRight`.
@karosLi
karosLi / delete_git_submodule.md
Created May 7, 2022 16:13 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@karosLi
karosLi / frameworks_blogpost_merge_script.sh
Created March 11, 2022 10:14 — forked from kientux/frameworks_blogpost_merge_script.sh
Merge simulator and device dynamic frameworks into one
# Merge Script
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.
FRAMEWORK_NAME="${PROJECT_NAME}"
@karosLi
karosLi / GLKMathUtils
Created December 20, 2021 11:44 — forked from AyadiMehdi/GLKMathUtils
GLKMathProject and GLKMathUnproject
GLKVector3 GLKMathProject(GLKVector3 object, GLKMatrix4 model, GLKMatrix4 projection, int *viewport) {
assert(viewport);
GLKVector4 v4 = GLKVector4MakeWithVector3(object, 1.0);
GLKVector4 v = GLKMatrix4MultiplyVector4(model, v4);
v = GLKMatrix4MultiplyVector4(projection, v);
v.v[3] = 1.0/v.v[3];
v.v[0] *= v.v[3];
v.v[1] *= v.v[3];
@karosLi
karosLi / SheetModalPresentationController.swift
Created January 16, 2021 09:57 — forked from vinczebalazs/SheetModalPresentationController.swift
A presentation controller to use for presenting a view controller modally, which can be dismissed by a pull down gesture. The presented view controller's height is also adjustable.
import UIKit
extension UIView {
var allSubviews: [UIView] {
subviews + subviews.flatMap { $0.allSubviews }
}
func firstSubview<T: UIView>(of type: T.Type) -> T? {
allSubviews.first { $0 is T } as? T