Skip to content

Instantly share code, notes, and snippets.

View ytlvy's full-sized avatar

Yt ytlvy

View GitHub Profile
#define NSNullObjects @[@"",@0,@{},@[]]
@interface NSNull (InternalNullExtention)
@end
@implementation NSNull (InternalNullExtention)
@ytlvy
ytlvy / DeviceUID.m
Created August 11, 2015 02:01 — forked from miguelcma/DeviceUID.m
iOS Unique Device ID that persists between app reinstalls
/* DeviceUID.h
#import <Foundation/Foundation.h>
@interface DeviceUID : NSObject
+ (NSString *)uid;
@end
*/
// Device.m
@ytlvy
ytlvy / xcplugin_update.sh
Last active October 7, 2015 11:14 — forked from alexlee002/xcplugin_update.sh
Auto update Xcode plugins to support new version of Xcode
#!/bin/sh
PLUGINS_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
XCODE_INFO_PATH=$(xcode-select -p)
XCODE_INFO_PATH=$(dirname "$XCODE_INFO_PATH")/Info
DVTPlugInCompatibilityUUID=$(defaults read "$XCODE_INFO_PATH" DVTPlugInCompatibilityUUID)
for plugin in "$PLUGINS_DIR"/*.xcplugin; do
plugin_info_path="$plugin/Contents/Info"
if [[ -f "$plugin_info_path.plist" ]]; then
@ytlvy
ytlvy / Singleton_Template.h
Last active September 20, 2015 12:32 — forked from alexlee002/Singleton_Template.h
A safe Objective-C singleton implementation. All instance method such as [[Singleton alloc] init], [[Singletion allocWithZone:zone] init]; [Singleton sharedInstance] are return the same instance and you can call them multi-times.
//
// Singleton_Template.h
//
// Created by Alex Lee on 3/11/15.
//
#undef AS_SINGLETON
#define AS_SINGLETON \
+ (instancetype)sharedInstance; \
@ytlvy
ytlvy / remove-bottom-line-navbar.md
Last active September 22, 2015 09:51 — forked from vinhnx/remove-bottom-line-navbar.md
remove 1px bottom line of the navigation bar

If you just want to use a solid navigation bar color and have set this up in your storyboard, use this code in your AppDelegate class to remove the 1 pixel border via the appearance proxy:

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
                                  forBarPosition:UIBarPositionAny
                                      barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];

swift

@ytlvy
ytlvy / NSString+UCS2Encoding.m
Last active October 8, 2015 13:55 — forked from shenqiliang/gist:9303513
baseband_contacts
#import <Foundation/Foundation.h>
#import <termios.h>
#import <time.h>
#import <sys/ioctl.h>
//UCS2编码支持
@implementation NSString(UCS2Encoding)
- (NSString*)ucs2EncodingString{
NSMutableString *result = [NSMutableString string];
@ytlvy
ytlvy / baseband-sms
Created September 22, 2015 14:15 — forked from shenqiliang/baseband-sms
利用iPhone基带发送短信息
#import <Foundation/Foundation.h>
#import <termios.h>
#import <time.h>
#import <sys/ioctl.h>
@implementation NSString(UCS2Encoding)
- (NSString*)ucs2EncodingString{
NSMutableString *result = [NSMutableString string];
@ytlvy
ytlvy / baseband
Created September 22, 2015 14:15 — forked from shenqiliang/baseband
#import <Foundation/Foundation.h>
#import <termios.h>
#import <time.h>
#import <sys/ioctl.h>
NSString *sendATCommand(NSFileHandle *baseBand, NSString *atCommand){
NSLog(@"SEND AT: %@", atCommand);
[baseBand writeData:[atCommand dataUsingEncoding:NSASCIIStringEncoding]];
NSMutableString *result = [NSMutableString string];
NSData *resultData = [baseBand availableData];
@ytlvy
ytlvy / PSPDFUIKitMainThreadGuard.m
Created September 23, 2015 01:34 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
#!/usr/bin/python
'''
The MIT License (MIT)
Copyright (c) 2014 Fabian Guerra Soto @fabiangrra
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