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 / 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
@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 / 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 / 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 / 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 / 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 / StructExtension.swift
Created November 3, 2016 06:19
Struct Extension
import AVFoundation
public typealias AOIBaseType = AOIBaseProtocol
public protocol AOIBaseProtocol {
associatedtype T
var aoi: T { get }
static var aoi: T.Type { get }
}
@Limon-O-O
Limon-O-O / ATS.swift
Created November 27, 2016 03:53
Disables ATS in debug builds
#Disables ATS in debug builds.
INFOPLIST="${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}"
case "${CONFIGURATION}" in
"Release"|"Adhoc")
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads NO" "${INFOPLIST}"
;;
"Debug")
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES" "${INFOPLIST}"
;;
esac
@Limon-O-O
Limon-O-O / version_compare.sh
Created February 18, 2017 04:15
Compare versions in Bash
#!/bin/bash
# -*- tab-width: 2; encoding: utf-8 -*-
## @file version_compare
## Compare [semantic] versions in Bash, comparable to PHP's version_compare function.
# ------------------------------------------------------------------
## @author Mark Carver <mark.carver@me.com>
## @copyright MIT
## @version 1.0.0
## @see http://php.net/manual/en/function.version-compare.php
@Limon-O-O
Limon-O-O / releasePod.sh
Last active February 27, 2017 16:19
Release pod
#!/bin/bash
BGreen='\033[1;32m'
Default='\033[0;m'
podName=""
version=""
podspecFilePath=""
homepage=""
httpsRepo=""