V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  mmnsghgn  ›  全部回复第 3 页 / 共 23 页
回复总数  454
1  2  3  4  5  6  7  8  9  10 ... 23  
2022-12-18 03:18:19 +08:00
回复了 Richard14 创建的主题 Python Python 的自定义类继承自 str 类的方式?
感觉可以,但没必要

```python
import json


class Read(str):
def __new__(cls, filepath):
with open(filepath, 'r', encoding='utf-8') as f:
# return super(Read, cls).__new__(cls, f.read())
return Read.__make_str(f.read())

@classmethod
def __make_str(cls, value):
return super(Read, cls).__new__(cls, value)

def loads_to_json(self):
return json.loads(self)

def strip(self, char = " "):
return Read.__make_str(super().strip(char))

def replace(self, *args):
return Read.__make_str(super().replace(*args))


# use as str
file_content = Read("file.txt")

print("file_content: " + file_content.strip())

print(json.loads(file_content))

# chaining
jsonContent = Read("file.txt").replace("hell0", "hello").loads_to_json()

print(jsonContent.get("message"))
```

output:

```shell

➜ Downloads python3 v2ex.py
file_content: {"message" : "hell0, world!"}

{'message': 'hell0, world!'}
hello, world!
```
2022-10-28 00:05:28 +08:00
回复了 bananahotell 创建的主题 iPhone 我好像发现了一个秘密
就是个 <input type="file" />


试一试: https://input-file-1e33sa1sll1f.runkit.sh/
2022-09-12 20:08:52 +08:00
回复了 cocong 创建的主题 React export = React; 该怎么理解?
支持原创
2022-08-05 06:05:26 +08:00
回复了 qiubangzhu 创建的主题 程序员 有什么好看的表白网页
2022-07-29 01:17:19 +08:00
回复了 qiubangzhu 创建的主题 程序员 有什么好看的表白网页
https://romantic-words.pages.dev/
以及同意楼上,都是电子垃圾
2022-07-07 21:09:54 +08:00
回复了 morty0 创建的主题 Apple M1 能支持 x86_64 的 docker 吗
2022-07-03 19:04:15 +08:00
回复了 F4NNIU 创建的主题 程序员 以后 web 本地开发就用这个域名了 fastadmin.fbi.com
2022-05-27 03:03:22 +08:00
回复了 fkysly 创建的主题 酷工作 [杭/上/北/广] 字节开发者服务前端团队 React 前端开发招聘
请问在线做题是 LeetCode 题还是前端编码题?
reply #8

```
# https://github.com/davidaurelio/hashids-python
from hashids import Hashids



hashids = Hashids(slat="blablablabla", min_length=8)
hashid = hashids.encode(1)
number = hashids.decode(hashid)

```
2022-05-20 19:36:30 +08:00
回复了 hzlzh 创建的主题 macOS ❤️SetApp 家人们集合啦: MenubarX 入驻啦,求 V 友支持[送福利]
第一批 Menubar X 用户,又是 SetApp 用户,又中奖了 Github 贴纸,再来蹭蹭!
2022-05-10 20:13:06 +08:00
回复了 Livid 创建的主题 macOS 如何能够创建类似 macOS 官方文档这样的 Help Book?
抓包看了一下,是 Help Viewr App 通过网络数据渲染的。App 在 `/System/Library/CoreServices/Help Viewer.app`, 即 #9 说的 com.apple.helpviewer 。

以这本帮助手册为例:

1. 获取手册信息,包含手册的基本信息和目录结构等。

```
https://cds.apple.com/content/services/book?platform=mac&pOSv=12.3&product=mac-help&productVersion=12.3&locale=zh-Hans
```

树形导航是解析其中的目录结构生成的。


2. 当点击某一文章时,会获取文章详情。

```
https://cds.apple.com/content/services/lookup?platform=mac&pOSv=12.3&product=mac-help&productVersion=12.0&locale=zh-Hans&bookid=5e2077d8bc16862b7fd64110d1406f84&topicid=MH43558

```

文章内容是 html 字符串,其中的图片都是网络资源。

CSS 是 `https://support.apple.com/clientside/build/app-apd.css`



全文检索是在本地实现的,在手册信息中 `miscAttributes` 包含了几个索引文件,比如:

```
https://help.apple.com/assets/61D4C1B5425F2576373C512A/61D4C1B7425F2576373C5132/zh_CN/search.helpindex

https://help.apple.com/assets/61D4C1B5425F2576373C512A/61D4C1B7425F2576373C5132/zh_CN/search.cshelpindex

https://help.apple.com/assets/61D4C1B5425F2576373C512A/61D4C1B7425F2576373C5132/zh_CN/searchTree.json

```

搜索了下应该是用 `hiutil` 创建的索引文件。

以上只是手册数据来源,我不熟悉 Apple 平台开发,App 的实现上不太了解。


参考资料:

1. https://apple.stackexchange.com/questions/271501/what-is-hiutil-and-why-is-it-sucking-up-my-cpu

2. 终端 `man hiutil`

3. `.helpindex` 文件格式 https://developer.apple.com/documentation/latentsemanticmapping


这个手册的在线版在 https://support.apple.com/zh-cn/guide/mac-help/welcome/12.0/mac


----

另外,我认为 Apple 的这种在线帮助手册也非常好看:

https://help.apple.com/app-store-connect/#/

并且,这个全文检索也是在浏览器本地完成的,通过一个分词后的索引文件。

```
https://help.apple.com/app-store-connect/zh_CN.lproj/searchTree.json
```
2022-05-01 14:56:39 +08:00
回复了 echo1937 创建的主题 问与答 怎么寻找一个图片的原始出处
2022-04-30 20:12:15 +08:00
回复了 echo1937 创建的主题 问与答 怎么寻找一个图片的原始出处
嘿嘿,楼上比我快,用 Mac 自带的预览拉一下直方图就能看到很明显的水印啦。

https://imgur.com/RpXG6Mr
2022-04-29 20:25:57 +08:00
回复了 YadongZhang 创建的主题 职场话题 Shopee SG 前端面试算法题
好吧,原来是 LeetCode 2248 ,刚提交通过了,😂

https://leetcode.com/problems/intersection-of-multiple-arrays/solution/by-nehzil-9383/
2022-04-29 20:25:15 +08:00
回复了 YadongZhang 创建的主题 职场话题 Shopee SG 前端面试算法题
2022-03-28 01:49:43 +08:00
回复了 Biwood 创建的主题 音乐 一个短篇 - 腰乐队
“请把所有的赞美都献给腰。”
2022-03-24 23:16:58 +08:00
回复了 leomm 创建的主题 优惠信息 腾讯云香港新加坡云服务器约 3 年 133 元-166 元
我要充一亿话费
1  2  3  4  5  6  7  8  9  10 ... 23  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3481 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 38ms · UTC 05:03 · PVG 13:03 · LAX 21:03 · JFK 00:03
♥ Do have faith in what you're doing.