Skip to content

Instantly share code, notes, and snippets.

View Limon-O-O's full-sized avatar
🍋

Limon Limon-O-O

🍋
View GitHub Profile
@Limon-O-O
Limon-O-O / AVCaptureDevice+FrameRate.swift
Created October 31, 2016 07:48
Control video frame rate with AVFoundation
extension AVCaptureDevice {
/// http://stackoverflow.com/questions/21612191/set-a-custom-avframeraterange-for-an-avcapturesession#27566730
func configureDesiredFrameRate(_ desiredFrameRate: Int) {
var isFPSSupported = false
do {
if let videoSupportedFrameRateRanges = activeFormat.videoSupportedFrameRateRanges as? [AVFrameRateRange] {
@Limon-O-O
Limon-O-O / TransitionCompositionBuilder.swift
Last active July 16, 2023 15:04
Merging videos with cross-fade effect using AVFoundation
//
// TransitionComposition.swift
// MED
//
// Created by Limon on 7/26/16.
// Copyright © 2016 MED. All rights reserved.
//
import AVFoundation
@Limon-O-O
Limon-O-O / CyanifyOperation.swift
Created September 4, 2016 09:33
Defines a subclass of NSOperation that adjusts the color of a video file.
//
// CyanifyOperation.swift
// MED
//
// Created by Limon on 2016/7/19.
// Copyright © 2016年 MED. All rights reserved.
//
import AVFoundation
import Dispatch
@Limon-O-O
Limon-O-O / MergeAssets.swift
Created August 1, 2016 10:04
Merge AVAsset
//
// Segment.swift
// MED
//
// Created by Limon on 6/28/16.
// Copyright © 2016 MED. All rights reserved.
//
import AVFoundation
@Limon-O-O
Limon-O-O / movietransitions.swift
Created July 24, 2016 15:07 — forked from SheffieldKevin/movietransitions.swift
Make a movie with transitions with AVFoundation and swift
//
// main.swift
// mutablecomposition
//
// Created by Kevin Meaney on 24/08/2015.
// Copyright (c) 2015 Kevin Meaney. All rights reserved.
//
import Foundation
@Limon-O-O
Limon-O-O / MediaFormat.md
Created July 2, 2016 14:01
Video file formats supported in iPhone
    import AVFoundation.AVMediaFormat
    enum MediaFormat {
        case MOV
        case MP4
        case M4V

        var filenameExtension: String {
            switch self {
 case .MOV:
@Limon-O-O
Limon-O-O / xcode-auto-version.sh
Created June 27, 2016 06:36 — forked from tpinto/xcode-auto-version.sh
Xcode: Automatic version and build number for iOS apps on Info.plist and Settings.bundle - http://www.tiagopinto.pt/blog/2014/11/10/xcode-version-build-number-ios-info-plist-settings-bundle/
# Tips from: http://xcodehelp.blogspot.ie/2012/05/add-version-number-to-settings-screen.html
# Reference from: https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html
# Get the correct path for the git binary
git=`sh /etc/profile; which git`
# Save paths for the project and target Info.plist
projectPlistPath="${PROJECT_DIR}/${INFOPLIST_FILE}"
targetPlistPath="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
@Limon-O-O
Limon-O-O / FCPrivateBatteryStatus.m
Created March 20, 2016 16:35
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);
@Limon-O-O
Limon-O-O / Matching Optional.md
Last active December 17, 2015 16:49
Matching Optional

假设服务器返回以上的JSON,客户端需要根据文章类型来作不同的布局。

enum Occupation: String {
  case AppSo = "app"
  case Number = "number"
}

let typeString = "mindStore"

switch Occupation(rawValue: typeString) {
@Limon-O-O
Limon-O-O / NSURL Parseer.md
Last active November 23, 2015 14:59
Extension to access the URL Parameters within your NSURL.

Producter Tips

extension NSURL {
    var prt_URLItems: [String: String]? {

        let components = NSURLComponents(URL: self, resolvingAgainstBaseURL: false)

        guard let items = components?.queryItems else {
 return nil