Skip to content

Instantly share code, notes, and snippets.

View iHTCboy's full-sized avatar
:octocat:
Coding

iHTCboy iHTCboy

:octocat:
Coding
View GitHub Profile
@iHTCboy
iHTCboy / Download-m3u8-File
Created July 26, 2019 04:05
Download m3u8 File for Python
import os
import requests
# 下载m3u8格式的视频
def download_m3u8(video_download_url, multimedia_path):
print("start download video")
all_content = requests.get(video_download_url).text # 获取M3U8的文件内容
file_line = all_content.split("\n") # 读取文件里的每一行
length = len(file_line)
print('video length:', length)
@iHTCboy
iHTCboy / 使用shell脚本批量查询或替换文本内容
Last active October 23, 2019 08:51
使用shell脚本批量查询或替换文本内容
[使用脚本批量替换文本内容 - 技术小黑屋](https://droidyue.com/blog/2019/10/13/replace-text-in-multiple-files-using-shell-script/)
----
很多时候,我们需要进行多个文件的查找并替换,虽然IDE有这样的可视化功能,但是偏爱终端的人还是想要尝试用脚本实现一把。如下是一个简单的脚本来实现多文件的查找替换处理。
脚本内容
#!/bin/sh
################################################################
//获取当前屏幕显示的viewcontroller
- (UIViewController *)getCurrentVC
{
UIViewController *result = nil;
UIWindow * window = [[UIApplication sharedApplication] keyWindow];
if (window.windowLevel != UIWindowLevelNormal)
{
@iHTCboy
iHTCboy / macOS 常用的目录路径
Last active November 12, 2019 08:27
Mac common path
### QuickLook
~/Library/QuickLook/
### macOS mobileprovision
~/Library/MobileDevice/Provisioning\ Profiles/
@iHTCboy
iHTCboy / svg转png
Created November 17, 2019 08:53
svg top png
```
const svg=`<svg version="1.1" baseProfile="full" width="300" height="200"
xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="red" />
<circle cx="150" cy="100" r="80" fill="green" />
<text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text></svg>`
svgToPng(svg,(imgData)=>{
const pngImage = document.createElement('img');
document.body.appendChild(pngImage);
pngImage.src=imgData;
@iHTCboy
iHTCboy / 查找域名对应的所有IP.txt
Created December 5, 2019 04:00
查找域名对应的所有IP
➜ ~ nslookup -q=TXT _netblocks.google.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
_netblocks.google.com text = "v=spf1 ip4:35.190.247.0/24 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 ip4:209.85.128.0/17 ip4:216.58.192.0/19 ip4:216.239.32.0/19 ~all"
Authoritative answers can be found from:
@iHTCboy
iHTCboy / 读取 iOS 应用中的证书信息
Created January 14, 2020 10:00
读取 iOS 应用中的证书信息
static NSString *bundleTeamIdentifier(void)
{
NSString *mobileProvisionPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"embedded.mobileprovision"];
FILE *fp=fopen([mobileProvisionPath UTF8String],"r");
char ch;
if(fp==NULL) {
printf("file cannot be opened/n");
return NULL;
}
NSMutableString *str = [NSMutableString string];
@iHTCboy
iHTCboy / js代码语法高亮
Created January 19, 2020 07:13
js代码语法高亮
<!-- js代码语法高亮
<link rel="stylesheet" href="//cdn.bootcss.com/highlight.js/9.15.8/styles/monokai-sublime.min.css">
<script src="//cdn.bootcss.com/highlight.js/9.15.8/highlight.min.js"></script>
<script>
// hljs.initHighlightingOnLoad();
$(document).ready(function () {
$('pre code').each(function (i, block) {
$(this).removeClass();
hljs.highlightBlock(block);
});
@iHTCboy
iHTCboy / Python download file
Created February 5, 2020 07:12
Python download file
import requests
url='https://ihtcboy.com/htc.pdf'
r = requests.get(url, stream=True)
with open('C:/Users/HTC/myfile.pdf', 'wb') as f:
f.write(r.content)
@iHTCboy
iHTCboy / Python读取文件和保存内容到文件
Created March 18, 2020 08:42
Python读取文件和保存内容到文件
import re
dump_file_path = '/Users/iHTCboy/Downloads/file.txt'
# 读取 dump 文件内容
with open(dump_file_path, mode='r', encoding="utf8", errors="ignore" ) as flip:
dump = flip.read()
# 正则匹配
pattern = r'@interface (.+) :'