#笔记

防止弱化的self在使用时被提前释放造成crash

 

2017面试题链接:

http://www.jianshu.com/p/f9eb6b315c08

http://www.cocoachina.com/ios/20150803/12872.html

 

苹果加急审核通道: 

https://developer.apple.com/contact/app-store/?topic=expedite (request an expedited app review)

 

iOS系统提示音大全: 

http://iphonedevwiki.net/index.php/AudioServices

AudioServicesPlaySystemSound (1007);

 

清除Xcode->Organizer界面左侧的无用的archive列表

command + shift + G 前往文件夹~/library/Developer/Xcode/products 删除不用的就可以了.

 

环信头像处理:

1.登录或更换头像存储自己的头像在本地

2.消息扩展,发送自己的头像url供另一台设备使用 (<EaseMessageViewController.m>_sendMessage:isNeedUpload:)

3.在收到消息中处理消息扩展,本地存储聊天对象的头像url和下载image存储,对应每个环信用户的id(<EaseMessageViewController.m> didReceviceMessages:)

4.在消息赋值展示的地方判断发送者(展示自己的头像),接收到他人的消息那么头像从本地缓存中获取,如果没有则使用消息扩展中的url(<EaseBaseMessageCell.m> setModel:)

5.会话列表头像展示,从缓存中取,如果没有则从消息扩展中使用url;然后存储最新消息附带的头像信息(EaseConversationListViewController.m)

备注,先修改自己服务器上用户的备注信息,然后在本地存储一份做记录

环信坑:1.发送语音要在主线程更新UI和播放动画 2.EaseUI国际化不起作用,全是英文

 

相册预览 icloud

 

App下载链接拼接:

https://itunes.apple.com/cn/app/idxxxxxxxxx?mt=8

 

iOS真机支持文件路径:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

(比如让 Xcode9.0 支持 iOS11.3真机,只需下载相应的支持文件丢到该目录即可)

 

获取属性

获取属性
unsigned int count;
Ivar *ivars =  class_copyIvarList([UIAlertAction class], &count);
for (int i = 0; i < count; i++) {
    Ivar ivar = ivars[i];
    const char * cName =  ivar_getName(ivar);
    NSString *ocName = [NSString stringWithUTF8String:cName];
    NSLog(@"这里是runtime获取到alertaction的属性  %@",ocName);
}
free(ivars);

系统滤镜

//增强
- (CIImage *)filteredImageUsingContrastFiltersOnImage:(CIImage *)image {
    return [CIFilter filterWithName:@"CIColorControls" withInputParameters:@{@"inputContrast":@(1.1),kCIInputImageKey:image}].outputImage;
}
//灰度
- (CIImage *)filteredImageUsingEnhanceFilterOnImage:(CIImage *)image {
    return [CIFilter filterWithName:@"CIColorControls" keysAndValues:kCIInputImageKey, image, @"inputBrightness", [NSNumber numberWithFloat:0.0], @"inputContrast", [NSNumber numberWithFloat:1.14], @"inputSaturation", [NSNumber numberWithFloat:0.0], nil].outputImage;
}
//自动增强
- (CIImage *)autoAdjustmentFilter:(CIImage *)inputImage {
    NSArray *filters = [inputImage autoAdjustmentFiltersWithOptions:@{kCIImageAutoAdjustRedEye: @(false)}];
    for (CIFilter *filter in filters) {
        [filter setValue:inputImage forKey:kCIInputImageKey];
        inputImage = [filter outputImage];
    }
    return inputImage;
}

Git 配置

git config --global user.name "daitao"
git config --global user.email "daitao@chaorey.com"

ssh-keygen -t rsa -C "daitao@chaorey.com" -b 4096
cat ~/.ssh/id_rsa.pub

UITextField

//UITextField创建后再设置placeholder文字,placeholder文字会比较深。

[self.textField setValue:[UIColor colorWithHexString:@"#c3c3c3"] forKeyPath:@"_placeholderLabel.textColor"];

//设置placeholder颜色需放在设置placeholder文字后面才生效.

自定制UIAlertController  KVC

attributedTitle
attributedMessage
titleTextColor

制作加密压缩包

zip -e  test.zip  test.txt
zip -er test.zip  Desktop/test/

使用fcrackzip暴力破解.zip

-D 表示要使用字典破解
-p 表示要使用那个字典破解
-b 表示使用暴利破解的方式
-c 'aA1' 表示使用大小写字母和数字混合破解的方式
-l 1-10 表示需要破解的密码长度为1到10位
-u 表示只显示破解出来的密码,其他错误的密码不显示出


$ fcrackzip -b -c ‘aA1’ -l 1-10 -u test.zip
$ fcrackzip -D -p dic.txt -u test.zip

终端命令

终端切入root系统:
1. sudo su  
2. sudo -i

切回普通用户:
1. ctrl + d  或者 logout   
2. exit

获取根目录下文件的大小
du -sh *

获取目录下文件的大小
du -d 1 -h


查询程序行数:
find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" -or -name "*.rss" ")" -print | xargs wc -l

查看安装的JDK版本和安装目录 
/usr/libexec/java_home -V

启动黑域
adb shell sh /data/data/me.piebridge.brevent/brevent.sh

给相应的文件夹添加操作权限
sudo chown -R $USER /usr/local   


撤销commit但是还未push的提交 
git reset HEAD~

Redis 操作

启动redis服务
redis-server

设置密码
config set requirepass 123456

查询密码
config get requirepass

验证权限
auth 123456

设置通知??参数
config set notify-keyspace-events Egx

以上设置重启后失效,另外一种方法就是在redis.conf中加入对应字段
1378 requirepass 123456
1379 notify-keyspace-events Egx

然后指定配置文件启动redis服务
redis-server /usr/local/redis-5.0.2/redis.conf

mongodb操作

brew services start/stop mongodb  启动/关闭
mongo 进入图形化界面
brew services list 查看homebrew安装的服务情况

登入mysql

mysql -u root -p

Vue 使用iView引入less文件进行主题切换报错

观察安装的less版本,如果是3.x那么考虑将其作降级处理 npm install less@2.7.3 --save-dev
然后重启服务

mybatis使用问题记录

xml中 #{} 会自动拼接前后引号形成字符串,${} 会保持变量原来的值常用于id和数字类型

模糊查询写法   like ‘%${name}%’    或者  like CONCAT('%',#{name},'%')

desc  rank 作为表字段名会与关键字冲突,查询时需使用 `desc`  `rank`

入参为时间戳(1552509966000) 时使用Date类型接收,xml中使用#{}

mysql时区问题

SHOW VARIABLES LIKE '%time_zone%';

SET GLOBAL time_zone = '+8:00';

SET time_zone = '+8:00';

FLUSH PRIVILEGES;

小程序setData高级操作

  toggleSeleted(ev) {

    var index = ev.currentTarget.dataset.index;

    var seletedKey = 'items[' + index + '].selected';

    this.setData({

      [seletedKey]: ! this.data.items[index].selected

    })

  },

旧项目libstdc++链接库不存在的问题

Xcode升级到Xcode10.0后,由于去掉陈旧的libstdc++库替换为libc++,libc++相对是苹果最新版的C++库,经过优化并全面支持C++11

将 libstdc++、libstdc++.6、libstdc++6.0.9拷贝到Xcode的如下目录:

1.真机环境:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/

2.模拟器环境:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/

Tomcat设置默认访问根目录

修改tomcat目录下 /conf/server.xml文件,在<Host></Host>中添加Context配置行

然后关闭重启tomcat服务生效

 ./shutdown.sh  
 ./startup.sh

 

 

 

 

 

import time import requests import execjs import json import csv # 请求头,使用之前需要修改cookie headers = { "accept": "application/json, text/plain, */*", "accept-language": "zh-CN,zh;q=0.9,en;q=0.8", "cache-control": "no-cache", "content-type": "application/json;charset=UTF-8", "dnt": "1", "origin": "https://www.xiaohongshu.com", "pragma": "no-cache", "priority": "u=1, i", "referer": "https://www.xiaohongshu.com/", "sec-ch-ua": &#39;"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"&#39;, "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": &#39;"Windows"&#39;, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site", "cookie": &#39;abRequestId=fc407090-4e7e-5e1f-93b0-8209b8665521; webBuild=4.72.0; a1=19835d363feuz8nyapsd4pjsfc4a0g3cgt5hnelpc50000413673; webId=342b472e8fc57b329f677750f4a9d13d; gid=yjYq2fq2qdk8yjYq2fqKq9d1id7uYIv0UMf42USUVMiS4x2808kqSI8884yqKWq8SyiKDWWW; web_session=040069b3361c451229121a31b53a4b5dc86ab9; xsecappid=xhs-pc-web; unread={%22ub%22:%2268775a1a0000000012030bc2%22%2C%22ue%22:%2268676f48000000002400d176%22%2C%22uc%22:29}; websectiga=2a3d3ea002e7d92b5c9743590ebd24010cf3710ff3af8029153751e41a6af4a3; sec_poison_id=e0007eda-445f-441d-92b6-8980f6a9731c; loadts=1753257365205&#39;, "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" } # 加载js文件,用于js逆向获取签名 xhs_sign_obj = execjs.compile(open(&#39;xhs.js&#39;, encoding=&#39;utf-8&#39;).read()) # 后续记录爬取的笔记数量,达到数量后停止爬取 note_count = 0 # 向csv文件写入表头,笔记数据csv文件 header = ["笔记标题", "用户名", "笔记内容", "笔记标签"] f = open(f"result.csv", "w", encoding="utf-8-sig", newline="") writer = csv.DictWriter(f, header) writer.writeheader() # 保存笔记数据 def sava_data(note_data, note_num): &#39;&#39;&#39; 保存笔记数据 :param note_data: 一片笔记的详细数据 :param note_num: 要爬取的笔记数量 &#39;&#39;&#39; # 笔记标签需要额外处理 tag_list = note_data[&#39;note_card&#39;][&#39;tag_list&#39;] tag_content = "" if len(tag_list) > 0: for tag in tag_list: tag_content += tag[&#39;name&#39;] + "\n" # 要保存的选项 data_dict = { "笔记标题": note_data[&#39;note_card&#39;][&#39;title&#39;].strip(), "用户名": note_data[&#39;note_card&#39;][&#39;user&#39;][&#39;nickname&#39;].strip(), "笔记内容": note_data[&#39;note_card&#39;][&#39;desc&#39;].strip().replace(&#39;\n&#39;, &#39;&#39;), "笔记标签": tag_content } # 笔记数量+1 global note_count note_count += 1 print(f"当前笔记数量: {note_count}\n", f"笔记标题:{data_dict[&#39;笔记标题&#39;]}\n", f"用户名:{data_dict[&#39;用户名&#39;]}\n", f"笔记内容:{data_dict[&#39;笔记内容&#39;]}\n", f"笔记标签: {tag_content}\n", ) writer.writerow(data_dict) # 笔记数量达到要求后停止爬取 if note_count >= note_num: print("爬取完毕") f.close() exit() def get_note_info(note_id, note_num, xsec_token): &#39;&#39;&#39; 获取笔记的详细信息 :param note_id: 笔记id :param note_num: 要爬取的笔记数量 :param xsec_token: 用于请求笔记详细信息 &#39;&#39;&#39; note_url = &#39;https://edith.xiaohongshu.com/api/sns/web/v1/feed&#39; # 参数 data = { "source_note_id": note_id, "image_scenes": [ "CRD_PRV_WEBP", "CRD_WM_WEBP" ], "xsec_token": xsec_token } # 更新请求头,得到签名 sign_header = xhs_sign_obj.call(&#39;sign&#39;, &#39;/api/sns/web/v1/feed&#39;, data, headers.get(&#39;cookie&#39;, &#39;&#39;)) headers.update(sign_header) # 请求数据,得到json数据 data = json.dumps(data, separators=(&#39;,&#39;, &#39;:&#39;), ensure_ascii=False) response = requests.post(note_url, headers=headers, data=data.encode(&#39;utf-8&#39;)) json_data = response.json() try: # 每一篇笔记的详细数据 note_data = json_data[&#39;data&#39;][&#39;items&#39;][0] except: print(f&#39;笔记 {note_id} 不允许查看&#39;) return # 保存笔记数据 sava_data(note_data, note_num) def keyword_search(keyword, note_num): &#39;&#39;&#39; 搜索关键词,处理搜索到的多篇笔记 :param keyword: 关键词 :param note_num: 要爬取的笔记数量 &#39;&#39;&#39; api = &#39;/api/sns/web/v1/search/notes&#39; search_url = "https://edith.xiaohongshu.com/api/sns/web/v1/search/notes" page_count = 20 # 爬取的页数, 一页有 20 条笔记 最多只能爬取220条笔记 for page in range(1, page_count): # 排序方式 general: 综合排序 popularity_descending: 热门排序 time_descending: 最新排序 params = { "ext_flags": [], "image_formats": ["jpg", "webp", "avif"], "keyword": keyword, "note_type": 0, "page": page, "page_size": 20, &#39;search_id&#39;: xhs_sign_obj.call(&#39;searchId&#39;), "sort": "general" } # 更新请求头,得到签名 sign_header = xhs_sign_obj.call(&#39;sign&#39;, api, params, headers.get(&#39;cookie&#39;, &#39;&#39;)) headers.update(sign_header) # 请求数据,得到json数据 data = json.dumps(params, separators=(&#39;,&#39;, &#39;:&#39;), ensure_ascii=False) # 响应数据 response = requests.post(search_url, headers=headers, data=data.encode(&#39;utf-8&#39;)) # 将数据转化为json格式 json_data = response.json() try: # 多篇笔记 notes = json_data[&#39;data&#39;][&#39;items&#39;] except: print(&#39;================爬取完毕================&#39;.format(page)) break for note in notes: note_id = note[&#39;id&#39;] xsec_token = note[&#39;xsec_token&#39;] if len(note_id) != 24: continue # 获取笔记的详细信息 get_note_info(note_id, note_num, xsec_token) def main(keyword: str = "北京", note_num: int = 5, user_cookie: str = ""): &#39;&#39;&#39; 功能主函数 :param keyword: 关键词 :param note_num: 笔记数量 :param user_cookie: 用户cookie &#39;&#39;&#39; # 修改请求头中的用户cookie global headers headers["cookie"] = user_cookie keyword_search(keyword, note_num) if __name__ == "__main__": # 手动输入参数 # keyword = input("关键词:") # 搜索的关键词 # note_num = int(input("笔记数量:")) # 搜索的笔记数量 # user_cookie = input("用户cookie:") # 用户cookie # 测试时使用预设参数 keyword = "河北" note_num = 5 user_cookie = "abRequestId=fc407090-4e7e-5e1f-93b0-8209b8665521; webBuild=4.72.0; a1=19835d363feuz8nyapsd4pjsfc4a0g3cgt5hnelpc50000413673; webId=342b472e8fc57b329f677750f4a9d13d; gid=yjYq2fq2qdk8yjYq2fqKq9d1id7uYIv0UMf42USUVMiS4x2808kqSI8884yqKWq8SyiKDWWW; web_session=040069b3361c451229121a31b53a4b5dc86ab9; xsecappid=xhs-pc-web; unread={%22ub%22:%2268775a1a0000000012030bc2%22%2C%22ue%22:%2268676f48000000002400d176%22%2C%22uc%22:29}; websectiga=2a3d3ea002e7d92b5c9743590ebd24010cf3710ff3af8029153751e41a6af4a3; sec_poison_id=e0007eda-445f-441d-92b6-8980f6a9731c; loadts=1753257365205", main(keyword, note_num, user_cookie) 修改我的代码
最新发布
07-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值