npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ramdisk-macos

v0.1.4

Published

Create ram disk on MacOS

Downloads

9

Readme

#Ram Disk 内存盘

开启 XCode 的内存盘模式,让开发更流畅,支持自动备份

开发真的是很伤 ssd 硬盘,ssd 的寿命大家都知道的,一年不如一年,我就觉得自从用上了xcode ,我的Macbook 就”嘎噔”一下卡了起来,虽不知道真正原因是什么,反正网上教程都是说,用内存盘来加速,就试了下,xcode 在编译时确实快了许多。

所以在网上找了些脚本,自己又整理了一下,实现了在关机时自动备份到硬盘的功能,方便使用。

安装

已将它上传到 npmjs 上,方便安装

npm install -g ramdisk-macos

这里是 Github 地址 https://github.com/wl879/ramdisk-macos

使用

在终端运行 ramdisk 会逐步提示如何配置的

ramdisk create

1

帮肋如下:

 Options:
    +create                 create ram disk
    +remove                 remove ram disk
    +list                   list links
    +stat                   look stat
    -h, --help              look help

源码分析

开机挂载

会生成 mount.sh 脚本,并加入到开机启动,实现方法如下

sudo defaults write com.apple.loginwindow LoginHook mount.sh

生成 backup.sh 脚本,在关机时运行

sudo defaults write com.apple.loginwindow LogoutHook backup.sh

####挂载 RamDisk

diskutil erasevolume HFS+ $NAME `hdiutil attach -nomount ram://$SIZE`

其中 $NAME 是挂载名称, $SIZE 是划分的容量,单位是字节。

备份与还原

备份与还原使用的是 rsync 命令, 会在关机时执行一次。其中,备份有两种策略。

**第一种 **需要 link 的文件,会呆存在 ramdisk 中的 links 文件夹中。拿 xcode 举例:

硬盘中

~/Library/Developer/Xcode -> /Volumes/Ramdisk/links/Xcode.ramdiskback
~/Library/Developer/Xcode.ramdiskback  # 会与内存盘中 links/Xcode.ramdiskback 同步

内存盘中

/Volumes/Ramdisk/links/Xcode.ramdiskback # 与硬盘中 Xcode.ramdiskback 同步

第二种 存放在内存盘中的内容,会在关机时同步到用户预先设定好的文件夹中,**注意:**这只会在关机时执行,所以并不安全