Skip to content

Instantly share code, notes, and snippets.

View Akhrameev's full-sized avatar

Pavel Akhrameev Akhrameev

  • Picsart
  • Yerevan, Armenia
View GitHub Profile
@Akhrameev
Akhrameev / UIImageMetalExtensions.swift
Last active October 23, 2020 10:28 — forked from akesson/UIImageMetalExtensions.swift
[iOS] Extension for creating UIImage from Metal texture
// http://blog.human-friendly.com/drawing-images-from-pixel-data-in-swift
// https://github.com/FlexMonkey/MetalReactionDiffusion/blob/1ea9aa4a841d20e0b247505fdf716cd5fe1a01fd/MetalReactionDiffusion/ViewController.swift
public struct PixelData {
var a:UInt8 = 255
var r:UInt8
var g:UInt8
var b:UInt8
}
class UDvars {
var AppLaunch: Int = UserDefaults.standard.object(forKey: "AppLaunch") as? Int ?? 0 {
didSet {
UserDefaults.standard.set(AppLaunch, forKey: "AppLaunch")
}
}
var Bool: Bool = UserDefaults.standard.object(forKey: "Bool") as? Bool ?? false {
didSet {
@Akhrameev
Akhrameev / OSTypedEnum.swift
Created June 26, 2020 11:12 — forked from danielpi/OSTypedEnum.swift
Extension to AVCaptureVideoDataOutput and an enum to represent OSType CVPixelFormatType data
extension AVCaptureVideoDataOutput {
var availableVideoCVPixelFormatTypedEnums: [OSTypedEnum] {
let availablePixelFormatDescriptions: Array<OSType> = self.availableVideoCVPixelFormatTypes as! Array<OSType>
let availablePixelFormats: Array<OSTypedEnum> = availablePixelFormatDescriptions.map { OSTypedEnum(rawValue: $0)! }
return availablePixelFormats
}
}
enum OSTypedEnum: OSType {
case monochrome1 = 1
@Akhrameev
Akhrameev / part1.m
Created May 16, 2018 12:12 — forked from enigmaticape/part1.m
You want to use NSObject performSelector with multiple parameters, but you can't ? (1)
- ( id ) methodWithOneParam:( id ) theParam {
// Do amazing stuff
return @"Srsly, Amazing!";
}
- ( id ) methodWithFirst:( id ) firstParam
andSecond:( id ) secondParam
{
// Do doubly amazing stuff
@Akhrameev
Akhrameev / HKWUIDeviceHardware.h
Created December 19, 2017 15:55 — forked from jamesstout/HKWUIDeviceHardware.h
Determine iOS device being used and other device info
//
// HKWUIDeviceHardware.h
//
#import <Foundation/Foundation.h>
@interface HKWUIDeviceHardware : NSObject
- (NSString *) platform2;
- (NSString *) platformString;
@Akhrameev
Akhrameev / iOS 7 dynamic font mappings
Created November 15, 2017 07:37 — forked from nuthatch/iOS 7 dynamic font mappings
What is UIFontTextStyleHeadline *really*? Dump out preferredFontForTextStyle for UIFontTextStyleHeadline, UIFontTextStyleSubheadline, UIFontTextStyleBody, UIFontTextStyleFootnote, UIFontTextStyleCaption1, UIFontTextStyleCaption2 to examine the font name, weight, and point size.
+ (void)describePreferredFonts
{
static NSArray *textStyles;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
textStyles = @[UIFontTextStyleHeadline,
UIFontTextStyleSubheadline,
UIFontTextStyleBody,
UIFontTextStyleFootnote,
UIFontTextStyleCaption1,
@Akhrameev
Akhrameev / AVAsset+VideoOrientation.h
Created October 19, 2016 05:04 — forked from luca-bernardi/AVAsset+VideoOrientation.h
Find the video orientation of an AVAsset. (Useful if you need to send the video to a remote server)
//
// AVAsset+VideoOrientation.h
//
// Created by Luca Bernardi on 19/09/12.
// Copyright (c) 2012 Luca Bernardi. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
typedef enum {
LBVideoOrientationUp, //Device starts recording in Portrait
- (UIView *) huntedSubviewWithClassName: (NSString *) className
{
if ([[[self class] description] isEqualToString: className])
{
return self;
}
for (UIView *subview in self.subviews)
{
UIView *huntedSubview = [subview huntedSubviewWithClassName: className];
@interface UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path;
@end
@implementation UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path {
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
@Akhrameev
Akhrameev / NSNotificationCenter+AllObservers.h
Last active August 29, 2015 14:02 — forked from 0xced/NSNotificationCenter+AllObservers.m
removeObserver swizzling added + SWIZZLE_NSNOTIFICATIONCENTER + separate .h and .m files
#import <Foundation/Foundation.h>
@interface NSNotificationCenter (AllObservers)
- (NSSet *) my_observersForNotificationName:(NSString *)notificationName;
@end