Skip to content

Instantly share code, notes, and snippets.

View ytlvy's full-sized avatar

Yt ytlvy

View GitHub Profile
@ytlvy
ytlvy / 0_reuse_code.js
Created October 7, 2015 11:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ytlvy
ytlvy / theos_64
Created October 7, 2015 10:50
theos 支持arm64的标准makefile写法
ARCHS = armv7 armv7s arm64
TARGET = iphone:8.4:7.0
#TARGET = iPhone:latest:7.0
#ARCHS这些定义一定要放到include之上
include theos/makefiles/common.mk
TWEAK_NAME = test
test_FILES = Tweak.xm
test_FRAMEWORKS = UIKit
@ytlvy
ytlvy / processInfo.m
Created October 7, 2015 09:44
OS X获取当前运行的所有进程信息
//
// main.m
// process
//
// Created by piao on 15/8/13.
// Copyright (c) 2015年 piao. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <sys/sysctl.h>
#!/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
@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.
@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 / 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 / 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 / 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 / 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; \