Skip to content

Instantly share code, notes, and snippets.

View tangyumeng's full-sized avatar

tangyumeng tangyumeng

View GitHub Profile
@tangyumeng
tangyumeng / ReverseLinkedList.java
Created November 16, 2019 02:58
ReverseLinkedList
public class ReverseLinkedList {
public static void main(String[] args) {
ListNode head = new ListNode(2);
head.next = new ListNode(4);
head.next.next = new ListNode(6);
head.next.next.next = new ListNode(8);
head.next.next.next.next = new ListNode(10);
ListNode result = ReverseLinkedList.reverse2(head);
System.out.print("Nodes of the reversed LinkedList are: ");
@tangyumeng
tangyumeng / test.m
Created August 10, 2018 09:22
shanshuo
#import "TestViewController.h"
@interface TestViewController ()<TYLabelDelegate>
@property (nonatomic,copy) NSString *text;
@property (nonatomic,copy) NSString *text2;
@property (nonatomic,strong) TYLabel *contentAttributedLabel;
@property (nonatomic,strong) TYTextRender *textRender;
@property (nonatomic,strong) TYTextRender *textRender2;
@property (nonatomic,assign) CGFloat contentHeight;
@tangyumeng
tangyumeng / Calculate
Created July 11, 2018 08:13 — forked from AnYuan/Calculate
TextKit calculate text height
+ (CGSize)rectForAttributedString:(NSAttributedString *)string
size:(CGSize)theSize {
if (!string || CGSizeEqualToSize(theSize, CGSizeZero)) {
return CGSizeZero;
}
// setup TextKit stack
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:theSize];
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:string];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
@tangyumeng
tangyumeng / DeepCopy.h
Created April 5, 2018 10:00 — forked from tommybananas/DeepCopy.h
ARC iOS Category for a NSArray and NSDictionary deep copy implementations
//
// DeepCopy.h
//
//
#import <Foundation/Foundation.h>
// Deep -copy and -mutableCopy methods for NSArray and NSDictionary
@interface NSArray (DeepCopy)
As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation
Strings:
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently.
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo"
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers.
@tangyumeng
tangyumeng / md
Last active February 21, 2018 03:44
ContentCompressionResistancePriority、ContentHuggingPriority
UILabel* leftLabel = [[UILabel alloc] init];
leftLabel.backgroundColor = [UIColor redColor];
[self.view addSubview:leftLabel];
[leftLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
leftLabel.text = @"返程高峰首日全国铁路发送1060万人 同比增长8.3%";
[leftLabel sizeToFit];
UILabel* rightLabel = [[UILabel alloc] init];
rightLabel.backgroundColor = [UIColor greenColor];
@tangyumeng
tangyumeng / iOS 技能图谱.md
Created January 21, 2018 14:56 — forked from tangqiaoboy/iOS 技能图谱.md
iOS 技能图谱

编程语言

  • Swift
  • Objective-C
  • C++/C
  • JavaScript

操作系统

  • Mac OSX
  • iOS
@tangyumeng
tangyumeng / UIView+frameAdjust.h
Created January 21, 2018 14:55 — forked from tangqiaoboy/UIView+frameAdjust.h
Adjust UIView frame category
//
// UIView+frameAdjust.h
// fenbi
//
// Created by Tang Qiao on 12-5-31.
// Copyright (c) 2012年 Fenbi.com . All rights reserved.
//
#import <Foundation/Foundation.h>
package main
import (
"errors"
"log"
)
func handlePanic(f func()) {
defer func() {
if r := recover(); r != nil {
package main
import (
"archive/tar"
"fmt"
"io"
"log"
"os"
)