Skip to content

Instantly share code, notes, and snippets.

View nonstriater's full-sized avatar

移动开发小冉 nonstriater

View GitHub Profile
#!/bin/sh
homeDir=$1
#cd /Users/ranwenjie/Desktop/c:c++/Bitcoin-xcode/bitcoin/src
cd $homeDir
# 目录内的源码统计
echo "" > /tmp/1.txt
find . -maxdepth 1 -type d -print0 | while read -d '' -r dir; do
files=("$dir"/*)
@nonstriater
nonstriater / AppDelegate.m
Created March 20, 2017 06:52 — forked from brunojppb/AppDelegate.m
Allow landscape mode in specific ViewControllers
/* Allow Landscape mode for specific ViewControllers */
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
UIViewController* topVC = [self topViewControllerWith: self.window.rootViewController];
if ([topVC respondsToSelector:@selector(canRotate)]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
return UIInterfaceOrientationMaskPortrait;
}
/* get the top ViewController */
@nonstriater
nonstriater / UIAlertViewCrashFix.h
Last active August 29, 2015 14:26 — forked from joshhudnall/UIAlertViewCrashFix.h
A potential fix to a new crash in iOS 8.3 where UIAlertViews will crash because they expect a different auto rotation behavior than what they are getting.
//
// UIAlertViewCrashFix.h
//
// Created by Josh Hudnall on 4/28/15.
//
//
#import <Foundation/Foundation.h>
@interface UIAlertController (CrashFix)
@nonstriater
nonstriater / gist:7940116363de85699722
Created June 14, 2015 08:23
Mobclick 统计越狱/未越狱情况下 Apple Store/盗版市场的统计情况
- (void)umengTrack {
NSString *channelId;
if ([MobClick isJailbroken]) {
if ([MobClick isPirated]) {
// 已破解(越狱)
channelId = @"盗版市场(越狱)";
}else{
// 未破解(越狱)
@nonstriater
nonstriater / iosicon.sh
Last active August 29, 2015 14:18
生成app icon的各个尺寸
#! /bin/bash
#########################
# usage: iosicon.sh 1024-icon.png
#########################
function print_usage(){
echo "################################"
@nonstriater
nonstriater / gist:5a71bba3e6a8aea49840
Created March 11, 2015 07:45
查看app cpu的占用比例
#import <mach/mach.h>
// http://stackoverflow.com/questions/8223348/ios-get-cpu-usage-from-application
float cpu_usage()
{
kern_return_t kr;
task_info_data_t tinfo;
mach_msg_type_number_t task_info_count;
task_info_count = TASK_INFO_MAX;
kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count);
@nonstriater
nonstriater / gist:21f76e9aca81910f0933
Created March 11, 2015 07:44
查看app cpu的占用比例
#import <mach/mach.h>
// http://stackoverflow.com/questions/8223348/ios-get-cpu-usage-from-application
float cpu_usage()
{
kern_return_t kr;
task_info_data_t tinfo;
mach_msg_type_number_t task_info_count;
task_info_count = TASK_INFO_MAX;
kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count);
@nonstriater
nonstriater / gist:eb041f55c181bdd0a7b5
Created March 11, 2015 07:44
查看app cpu的占用比例
#import <mach/mach.h>
float cpu_usage()
{
kern_return_t kr;
task_info_data_t tinfo;
mach_msg_type_number_t task_info_count;
task_info_count = TASK_INFO_MAX;
kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count);
@nonstriater
nonstriater / spy.d
Last active August 29, 2015 14:16 — forked from markd2/spy.d
#!/usr/sbin/dtrace -s
/* Run like:
% sudo csh
# ./spy.d $PROCESS_ID [$INTERESTING_PROBEPROV]
Prints a line of dashes every 5 seconds to delineate different experiments.
*/
#pragma D option quiet
@nonstriater
nonstriater / gist:e817dcc51952384827ae
Created May 4, 2014 06:14
Appirater 打开app时,提醒用户给应用打分
// rate
[Appirater setAppId:kAppStoreID];
[Appirater setOpenInAppStore:YES]; // 设置为NO,in-app方式打开
[Appirater setDaysUntilPrompt:1]; // 1天过后
[Appirater setUsesUntilPrompt:10]; // 使用10次
[Appirater setSignificantEventsUntilPrompt:-1];
[Appirater setTimeBeforeReminding:2];
[Appirater appLaunched:YES];