三毛笔记,记录我的编程成长之路,同时分享各种网络资源、羊毛福利,收集各种有趣实用的软件和APP,发现一些稀奇古怪的的网站,折腾一些有趣实用的教程,关注互联网最新资讯动态,探索新领域,发现新美好,分享小快乐。
冒泡排序在所有排序算法中最简单,然而,从运行时间的角度看,冒泡排序是最差的一个。function swap(array, a, b) { const temp = array[a] array[a] = array[b] array[b] = temp } function bubbleSort(array) { const { length } = array for (let i = 0; i < length; i++) { for (let j = 0; j < length - 1 - i; j++) { if (array[j] > array[j + 1]) { swap(array, j, j + 1) } } } console.log(array) } bubbleSort([1, 3, 5, 2, 0])选择排序一种原址比较排序算法。选择排序大致思路是找到数据结构中的最小值并将其放置在第一位,接着找到第二小的值并将其放在第二位,以此类推。function s
logo边框一款为图片添加logo、描述边框的程序。给logo加个水印,逼格瞬间就上来了。更好玩、更好用的图片边框工具,灵感来源依然是小米 12 系列手机的徕卡水印标。logo边框这个程序,所用到的优秀开源库:vue:一款优秀的前端框架naive ui:优秀的vue3组件库dayjs:轻量的时间处理库exif-parser:前端解析图片的exif信息的函数库file-saver:大文件下载库jszip:好用的前端构建zip包库网站地址logo边框:https://xxbiji.gitee.io/logo-frame-web/home类似网站bingoicon:http://bingoicon.com/
集合结构集合是由一组无序且唯一(即不能重复)的项组成的。class MySet { items = {} add(element) { if (!this.has(element)) { this.items[element] = element return true } return false } delete(element) { if (this.has(element)) { delete this.items[element] return true } return false } has(element) { return element in this.items } clear() { this.items = {} } size() { return Object.keys(this.items).length } values() { return Object.valu
数组结构参考:https://aboss.top/post/173/栈结构栈(stack)又名堆栈,是一种运算受限的线性表,限定仅在表尾进行插入和删除操作。这一端被称为栈顶,相对地,把另一端称为栈底。向一个栈插入新元素称作进栈,从一个栈删除元素称作出栈。特点:后进先出,即 Last in First out (LIFO)。class Stack { #items = [] //# 符号声明私有属性,ES13 新特性 pop() { return this.#items.pop() //出栈 } push(data) { return this.#items.push(data) //进栈 } peek() { return this.#items.at(-1) //栈顶 } isEmpty() { return this.#items.length === 0 } size() { return this.#items.length } clear() { this.#items
Linux Mint终端输入命令apt i,按Tab键无法自动补全install,这很不方便。修改bash在终端输入命令sudo vi /etc/bash.bashrc,编辑enable bash completion in interactive shells这一项配置,将其注释全部去掉。找到下面这几行:#if ! shopt -oq posix; then # if [ -f /usr/share/bash-completion/bash_completion ]; then # . /usr/share/bash-completion/bash_completion # elif [ -f /etc/bash_completion ]; then # . /etc/bash_completion # fi #fi去掉前面的#号:if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-complet
在Linux Mint下,用Vim编辑器编辑文本时,会遇到退格键和上下左右方向键不能正常使用的情况:退格键不能删除前面的字符,方向键不能移动光标,而是出现A、B、C、D每个字符一行。这种情况是因为Linux Mint默认安装vim-tiny简易版本,所以出现了错误。解决方法其实很简单,进入/etc/vim目录,修改vimrc.tiny文件。sudo vi /etc/vim/vimrc.tiny把set compatible改为set nocompatible,关闭兼容模式。compatible是兼容的意思,nocompatible是不兼容,Vim是Vi的扩展,nocompatible是指Vim在工作的时候不需要考虑和Vi兼容。并在后面加一句set backspace=2,设置Backspace可以删除任意字符。可以顺便设置一下行号显示等等,最终效果如下所示:" 关闭兼容模式 set nocompatible " 设置Backspace可以删除任意字符 set backspace=2 " 显示行号 set number " 设置Tab键为4个空格
易笺一个开源免费的在线TXT阅读器,页面非常简洁,百兆文件秒开,中英文小说名、作者名自动识别等等,没有任何设置,纯粹是为了阅读,开发者的初衷是开发一款能看200MB+日志文件的阅读器,后来写着写着就成了看小说的了。网站地址易笺:https://reader.yijian.app/
BlackHole一个开源免费且高颜值的音乐播放器,简约无广告,目前聚合Saavn、Spotify、YtMusic和YouTube平台音乐,支持从Spotify和YouTube导入播放列表,支持15+音乐语言,最佳流媒体质量支持320kbps aac,软件使用Flutter开发制作,支持安卓、iOS(ipa安装包)和macOS系统。下载地址BlackHole:https://github.com/Sangwan5688/BlackHole
位图和矢量图位图,又称像素图,就像我们常见的JPEG和PNG图片,是由一个个像素点组成的。每个像素点都有自己的颜色,组合在一起就形成了我们看到的图片。当你放大一张位图图片时,你会看到越来越大的像素方块,因为像素是固定的,无法提供更多的细节,这就是我们常说的“像素化”。矢量图,是由数学公式描述的图形,如直线、曲线、多边形等。它可以无限放大而不会失真,因为无论放大多少倍,都是清晰的线条和形状,没有“像素化”的问题。Vectorizer AI一个免费在线将位图图像转换为矢量图像工具,使用人工智AI能将JPEG和PNG位图转换为SVG矢量,可无限量放大,目前支持的最大图像像素大小为2万像素,最大图像文件大小为30MB,测试期间可免费使用。试了一下效果非常不错,直接在浏览器即可完成,非常方便。网站地址Vectorizer AI:https://vectorizer.ai/
REST Client插件可以帮助我们在日常的接口开发过程中简化接口的请求调试方式,并加速开发进程。安装插件点击VS Code左边栏的【扩展】选项卡,在搜索框中输入【REST Client】,找到REST Client后点击安装即可。新建文件文件以http或rest为后缀名,如demo.http或demo.rest。插件用法简单用法GET https://api.uomg.com/api/rand.qinghua打完命令后,上面会出现Send Request字样,点击后,右边会出现发送请求后的返回结果。当需要多个请求时,用###隔开,可以在其后添加注释:GET https://api.uomg.com/api/rand.qinghua ### POST请求 POST https://api.uomg.com/api/rand.qinghua变量文件变量可以在http文件任意位置定义文件变量,它们可以在整个文件的任何请求中引用。例如:@hostname = api.uomg.com GET https://{{hostname}}/api/rand.qinghua定义变量使用 @ 符号
因为Typecho的机制,页面、附件都要占cid。而且点击一次创建文章cid就会增加一次,即使你没有书写内容,那个cid也被认为已经使用了,所以下一次生成的cid就会跳过那个,造成不连续。虽然不影响什么,也无关紧要,但是对于有强迫症的人来说,真的是无法忍受,看到了非得给改一下不可。特别提醒:请在PHP 7以上版本的服务器上执行。本操作涉及数据库,请提前做好备份工作。文章cid将以下代码保存为php文件并上传至网站根目录,在浏览器地址栏访问一下即可。<?php /** * Typecho重新排列文章cid让他连续 */ // 设置数据库参数 $hostname_blog = "localhost"; $database_blog = "数据库名"; $username_blog = "数据库用户名"; $password_blog = "数据库密码"; // 连接到数据库 $blog = mysqli_connect($hostname_blog, $username_blog, $password
删除安装文件Typecho成功安装后,删除根目录下的install.php文件、install文件夹。修改后台地址将根目录下的admin文件夹改名为黑客猜不到的名字,例如google,防止黑客穷举密码。然后修改根目录下config.inc.php文件中后台路径配置:// admin directory (relative path) define('__TYPECHO_ADMIN_DIR__', '/google/');之后访问后台就用你的域名/google/,原来的你的域名/admin/则不能访问。修改文件权限屏蔽usr、var目录下php文件的访问可阻止黑客访问到他上传的php木马。这里利用Rewrite伪静态机制来做,以Apache服务器为例,同时屏蔽config.inc.php和.htaccess的访问。屏蔽原理是把要屏蔽的请求重定向到首页文件,首页文件会被当成文章名来解析,没有同名文章就会返回404未找到。所以就算黑客上传了木马也只会得到404未找到的响应。新建.htaccess文件添加以下内容,上传到typecho博客根目录。<IfModule mod_rewrite
找台词一个影视台词搜索引擎,可搜索查找电视剧、电影台词的网站,根据台词即可搜索电视剧、电影名称,例如输入“我爱你”,即可找到所有拥有“我爱你”这句台词的电视剧或者电影,而且还会展现该台词出现的具体时间和上下文关联台词,而且还拥有字幕提取工具方便你将字幕格式文件轻松转换为TXT文件,不过需要联系站长,其他的功能都可以免费使用,是剪辑师神器。网站地址找台词:https://zhaotaici.cn/类似网站英语台词社:https://www.taicishe.com/
从WordPress转到Typecho,首先要建立Typecho博客,建好后,首要的就是导入数据,这里选用Wordpress To Typecho插件直接将WordPress文章、评论、分类、标签等全部导入Typecho。数据迁移下载插件Wordpress To Typecho,并上传到 /usr/plugins 目录下。这个插件是Typecho官方2014年前发布的,插件版本为(v1.0.3 Beta),仅适用于WordPress 2.7,但实际上WordPress 6.3也能用。登录Typecho后台,进入菜单【控制台】→【插件】,将Wordpress to Typecho插件启用进入该插件的 设置 界面,填好WordPress所在数据库的地址、端口、用户名、密码、数据库名称、表前缀,并【保存设置】进入菜单【控制台】→【从Wordpress导入数据】,此时会看到导入提示界面,点击按钮【开始数据转换】即可当系统提示转换成功后,数据就全部迁移到了Typecho完成后,可以禁用或删除这个插件如果转换失败,系统会给出失败原因,很多情况是因为数据库设置错误导致的,只需重新设置 WordPre
Musicca一个广受全球用户喜爱的音乐学习平台之一,使用免费且充满乐趣音乐学习方式帮助全球用户学习音乐。网站提供课程、练习和互动工具,鼓励音乐学习者在校和家中都能按照自己的节奏来学习,帮助学习者理解音乐、学会读谱和演奏乐器,而且通过在学习过程中加入游戏的元素,使学习音乐的过程变得有趣。除此之外网站还提供大量的在线虚拟音乐工具,例如钢琴、吉他、贝斯等等,可以在线模拟真实的乐器使用。网站地址Musicca:https://www.musicca.com/zh
本地开发环境下载并安装Local:https://localwp.com/打开 Local,点击「+ Create a new site],输入网站名称(例如:test),点击「Continue」->「Continue」,输入用户名、密码、邮箱,点击「Add Site」,稍等片刻,网站就安装完成了。点击「Open site」,即可打开网站。可能出现打不开网站的情况。如果之前安装过 VMware Workstation,端口 443 会存在冲突。打开「服务」应用,找到「VMware Workstation Server」,右键「属性],启动类型改为「手动」。创建新主题在网站上右键「Go to site folder」,打开网站文件路径,进到test/app/public/wp-content/themes,新建文件夹(例如:mytheme),进入 mytheme/,新建文件 index.php、style.css,所有主题都需要这两个文件。在文件style.css写入:/* Theme Name: My Theme Author: GAGA Version:
安装Beautiful Souppip install beautifulsoup4 pip install lxml # 安装解析器lxml使用 Beautiful SoupBeautiful Soup 将复杂的 HTML 文档转换成一个复杂的树形结构,每个节点都是 Python 对象,所有对象可以归纳为 4 种:Tag,NavigableString,BeautifulSoup,Comment。TagTag 就是 HTML 中的标签。首先,用 HTML 创建一个 Beautiful Soup 对象。soup = BeautifulSoup(html, 'lxml') head = soup.head # 提取 head 标签 title = soup.title # 提取 title 标签 p = soup.p # 提取 p 标签标签有两个重要的属性:name 和 attrs。name = soup.p.name attrs = soup.p.attrs # 标签的所有属性是一个字典NavigableString获取标签内部的文字,用 .string 即可,例如:title = s
Python 3.3版本之后自带venv,可直接代替virtualenv。通过使用虚拟环境,可以:避免库和依赖项之间的冲突测试不同版本的库而不会影响系统范围的 Python 安装维护干净、有序的开发环境与其他人合作,同时确保库版本一致使用 Python 虚拟环境创建虚拟环境:python -m venv myenv。此命令会在当前目录中创建一个名为“myenv”的虚拟环境。-m 选项指定运行的是venv模块,最后的myenv是创建的虚拟环境路径。在 Windows 上:激活虚拟环境:.\myenv\Scripts\activate退出虚拟环境:deactivate最佳实践和建议当进入虚拟环境时,请牢记以下最佳做法:为每个项目创建一个虚拟环境:每当启动一个新项目时,就创建一个新的虚拟环境。这可确保工作空间干净且隔离。使用需求文件:要记录和管理项目的依赖项,请创建一个 requirements.txt 文件。可以使用pip freeze > requirements.txt生成它,然后使用pip install -r requirements.txt将它们安装在新环境中。激活和停用:
Python中单线程的异步编程模型称为协程。一般情况下,当程序处于IO操作的时候,线程都会处于阻塞状态。线程是CPU控制的,而协程是程序自身控制的,属于程序级别的切换,操作系统完全感知不到,因而更加轻量级。协程:当程序遇见了IO操作的时候,可以选择性的切换到其他任务上。在单线程条件下,微观上协程是一个任务一个任务的进行切换,宏观上看是多个任务一起在执行(多任务异步操作)。要用在异步IO编程中依赖的库必须支持异步IO特性。asyncio是Python 3.4之后引入的标准库,内置对异步IO的支持。其编程模型是一个消息循环,从asyncio模块中直接获取一个EventLoop的引用,然后把需要执行的协程扔到EventLoop中执行,就实现了异步IO。import asyncio # 导入异步编程库 import time async def func1(): print("李小龙") await asyncio.sleep(5) print("李小龙") async def func2(): print(&quo
对操作系统来说,一个任务就是一个进程(Process),比如打开一个浏览器就是启动一个浏览器进程,打开两个记事本就启动了两个记事本进程。有些进程不止同时干一件事,比如Word,它可以同时进行打字、拼写检查、打印等事情。在一个进程内部,要同时干多件事,就需要同时运行多个“子任务”,我们把进程内的这些“子任务”称为线程(Thread)。进程之间是内存隔离的,即不同的进程拥有各自的内存空间。这就类似于不同的公司拥有不同的办公场所。线程之间是内存共享的,线程是属于进程的,一个进程内的多个线程之间是共享这个进程所拥有的内存空间的。这就好比,公司员工之间共享公司的办公场所。进程multiprocessing模块是跨平台版本的多进程模块,提供了一个Process类来代表一个进程对象。import os from multiprocessing import Process # 子进程要执行的代码 def run_proc(name): print("子进程 %s (%s)" % (os.getpid(), name)) print("父进程 %s&qu
很多时候,数据读写不一定是文件,也可以在内存中读写。StringIOStringIO顾名思义就是在内存中读写str。要把str写入StringIO,我们需要先创建一个StringIO,然后,像文件一样写入即可:from io import StringIO s = "abcdefg123" sio = StringIO(s) # sio就是可变字符串 print(sio.getvalue()) # abcdefg123 sio.seek(7) # 指针移动到索引7这个位置 sio.write("666") print(sio.getvalue()) # abcdefg666要读取StringIO,可以用一个str初始化StringIO,然后,像读文件一样读取:f = StringIO("hello\nworld") while True: s = f.readline() if s == "": break print(s.strip())BytesIOS
三毛
头发渐少,仅剩三根