Skip to content

Instantly share code, notes, and snippets.

Avatar
😎

Li Lin allenlinli

😎
View GitHub Profile
View gist:1ff3815da751c00fdba03383d2408b5a
[NSTimer scheduledTimerWithTimeInterval:0.5 repeats:YES block:^(NSTimer * _Nonnull timer) {
struct task_basic_info info;
mach_msg_type_number_t size = TASK_BASIC_INFO_COUNT;
kern_return_t kerr = task_info(mach_task_self(),
TASK_BASIC_INFO,
(task_info_t)&info,
&size);
if( kerr == KERN_SUCCESS ) {
NSLog(@"Memory in use (in bytes): %lu", info.resident_size);
NSLog(@"%f", ((CGFloat)info.resident_size));
View gist:0537d7ce7104769ed97756fe78606a69
[NSTimer scheduledTimerWithTimeInterval:0.5 repeats:YES block:^(NSTimer * _Nonnull timer) {
struct task_basic_info info;
mach_msg_type_number_t size = TASK_BASIC_INFO_COUNT;
kern_return_t kerr = task_info(mach_task_self(),
TASK_BASIC_INFO,
(task_info_t)&info,
&size);
if( kerr == KERN_SUCCESS ) {
NSLog(@"Memory in use (in bytes): %lu", info.resident_size);
NSLog(@"%f", ((CGFloat)info.resident_size));
@allenlinli
allenlinli / openx_bash_for_ios
Created Jun 11, 2020 — forked from johngraham262/openx_bash_for_ios
A simple bash script that will open a `.xcworkspace` if it exists in the current directory, otherwise a `.xcodeproj` if it exists, otherwise nothing. It will print the name of the file that is being opened. When using Cocoapods with iOS apps, a second file is created with the `MyProject.xcworkspace` name, alongside the `MyProject.xcproject` file…
View openx_bash_for_ios
# Add the following lines of code to your `~/.bash_profile`,
# and then run `source ~/.bash_profile` to be able to execute
# this from the command line.
openx() {
fileToOpen='';
for file in `find . -maxdepth 1 -name *.xcworkspace`; do
fileToOpen=$file
done
@allenlinli
allenlinli / gist:f9e8f901334a2d41219f7a1213934662
Created Sep 18, 2019 — forked from leovandriel/gist:3775603
Xcode Run Script for building static framework for Cocoa Touch iOS
View gist:f9e8f901334a2d41219f7a1213934662
# Xcode Run Script for building iOS static framework.
# Requires a preconfigured Cocoa Touch Static Library.
# Usage:
# 1. Open project > Add Target > iOS Aggregate > Finish
# 2. Add Build Phase > Add Run Script > Paste
# 3. Manually assign PROJECT, TARGET, HEADERS, PRODUCT, OUTPUT
# 4. Run outputs to ${SRCROOT}/build
#
# License: Public Domain
# Author: Leonard van Driel, 2012
@allenlinli
allenlinli / gist:ea76565d14d6bcbf00c97d2a2a34f54a
Created May 18, 2018
ECClient init as a signalingDelegate
View gist:ea76565d14d6bcbf00c97d2a2a34f54a
// ECSingalingChannel.m
- (void)onSocketSignalingMessage:(NSDictionary *)msg type:(NSString *)type {
if (!signalingDelegate) {
signalingDelegate = [_roomDelegate clientDelegateRequiredForSignalingChannel:self];
[signalingDelegate setStreamId:message.streamId];
[signalingDelegate setPeerSocketId:message.peerSocketId];
[self setSignalingDelegate:signalingDelegate];
}
}
View gist:8b2a214d8c8c7f9693f9fc15351187ea
Hi [~bevan] [~pia] [~peteru], here I record three video, they are:
Test Case 01 - SignupLoginView
TestCase 02 TSItemView on credit card page
Test Case 03 - signup error
And I wrote test cases that I will put in Confluence to share with whoever needs it.
## Test Cases
- [ ] sign up view
- [ ] **signup successful**
View Retry code 2
static NSInteger const maxRetryCountForFetchingTicket = 10;
- (void)_handleFetchTicketFailWithError:(NSError *)inError petID:(NSString *)inPet
{
if ([inError code] == KKInvalidSessionError) {
//error handling
return;
}
retryCount ++;
@allenlinli
allenlinli / Retry
Created Nov 18, 2016
Retry in Swift
View Retry
//
// ViewController.swift
// PlayRetry
//
// Created by Li Lin on 18/11/16.
// Copyright © 2016 Li Lin. All rights reserved.
//
import UIKit
View WatchConnectivitySingletonDemo.swift
//
// WatchSessionManager.swift
// WatchConnectivityDemo
//
// Created by Natasha Murashev on 9/3/15.
// Copyright © 2015 NatashaTheRobot. All rights reserved.
//
import WatchConnectivity
@allenlinli
allenlinli / gist:d9a9400fda28809c914c87bfa50575e0
Last active Oct 12, 2016
Please read the README in front of this code.
View gist:d9a9400fda28809c914c87bfa50575e0
/*
README:
Updated on 13/Oct. I can use self.favoriteList in .m file. Then we can use custom getter here.
1. The implemetation I did for the first time was correct. I used "@property (atomic) NSMutableArray<NSString *> *favoriteList;" in @interface Booking() and it works.
2. I don't need "//@synthesize favoriteList = _favoriteList;" for creating setter and getter, becuase Xcode will create them automaticlly now.
3. I think my implementation is better than having a "@property (atomic) NSMutableArray<NSString *> *favoriteList2;" in .m. Becuase having a favoriteList2 may confuse people. The cons of my implementation is that you may create custom getter and setter so you don't want to use _favoriteList, but for this simple example it should be fine.
*/
//