Skip to content

Instantly share code, notes, and snippets.

@nileshpunjabi
nileshpunjabi / rotate_video.m
Last active October 16, 2018 12:41
Rotate Landscape video
//setting up the first video based on previous recording
CMTimeRange videoDuration = CMTimeRangeMake(kCMTimeZero, [self.previousRecording duration]);
AVAssetTrack *clipVideoTrack = [[self.previousRecording tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
AVAssetTrack *clipAudioTrack = [[self.previousRecording tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
[compositionVideoTrack insertTimeRange:videoDuration ofTrack:clipVideoTrack atTime:nextClipStartTime error:nil];
[compositionAudioTrack insertTimeRange:videoDuration ofTrack:clipAudioTrack atTime:nextClipStartTime error:nil];
//our first track instruction - set up the instruction layer, then check the orientation of the track
//if the track is in landscape-left mode, it needs to be rotated 180 degrees (PI)
AVMutableVideoCompositionLayerInstruction *firstTrackInstruction =
@Nyx0uf
Nyx0uf / gist:217d97f81f4889f4445a
Last active November 15, 2020 22:31
UIImage scale using vImage
-(UIImage*)mmg_imageScaledToFitSize:(CGSize)fitSize
{
// Create a vImage_Buffer from the CGImage
CGImageRef sourceRef = self.CGImage;
vImage_Buffer srcBuffer;
vImage_CGImageFormat format = {
.bitsPerComponent = 8,
.bitsPerPixel = 32,
.colorSpace = NULL,
.bitmapInfo = (CGBitmapInfo)kCGImageAlphaFirst,
@dulacp
dulacp / Overlay_iOS_app_version_on_icon_README.md
Last active November 19, 2017 11:18
Overlay the iOS application version on top of the icon

Usage

Requirements

Install the two dependencies, ImageMagick and Ghostscript.

$ brew install imagemagick
$ brew install ghostscript
@wangkuiyi
wangkuiyi / pre-commit-clang-format
Last active August 19, 2021 14:04
Git pre-commit hook that invokes clang-format to reformat C/C++/Objective-C source code.
#!/bin/bash
# git pre-commit hook that runs an clang-format stylecheck.
# Features:
# - abort commit when commit does not comply with the style guidelines
# - create a patch of the proposed style changes
# modifications for clang-format by rene.milk@wwu.de
# This file is part of a set of unofficial pre-commit hooks available
# at github.
@arturlector
arturlector / ios-questions-interview.md
Last active February 25, 2024 18:44
Вопросы на собеседование iOS разработчика.

Вопросы на собеседование iOS разработчика (дополненное издание):

General:

  • Что такое полиморфизм?

  • Что такое *инкапсуляция? Что такое *нарушение инкапсуляции?

  • Чем абстрактный класс отличается от интерфейса?

  • Расскажите о паттерне MVC. Чем отличается пассивная модель от активной?

@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active April 8, 2024 18:07
The best FRP iOS resources.

Videos

@palmerc
palmerc / blur.m
Last active October 10, 2017 02:38
vImage Blur Example
- (UIImage *)boxblurImage:(UIImage *)image boxSize:(int)boxSize
{
CGImageRef originalImageRef = image.CGImage;
CGColorSpaceRef originalColorSpace = CGColorSpaceRetain(CGImageGetColorSpace(originalImageRef));
if (_pixelBuffer == NULL) {
_pixelBuffer = malloc(CGImageGetBytesPerRow(originalImageRef) * CGImageGetHeight(originalImageRef));
}
vImage_CGImageFormat inputImageFormat =
@phatmann
phatmann / ImageAttachment
Created March 22, 2015 22:23
NSTextAttachment that scales and aligns image
// Created by Tony Mann on 3/22/15.
// Copyright (c) 2015 7Actions. All rights reserved.
//
// Adapted from http://ossh.com.au/design-and-technology/software-development/implementing-rich-text-with-images-on-os-x-and-ios/
import UIKit
class ImageAttachment: NSTextAttachment {
var verticalOffset: CGFloat = 0.0
@figgis
figgis / Makefile
Last active April 8, 2020 08:15
ffmpeg qp values
# use pkg-config for getting CFLAGS and LDLIBS
FFMPEG_LIBS= libavdevice \
libavformat \
libavfilter \
libavcodec \
libswresample \
libswscale \
libavutil \
CFLAGS += -Wall -g