如何存储您的个人代码段数据库以便在任何地方使用它(工作等)?

时间:2021-05-02 04:16:10

I've read the several discussions about storing code snippets but I did't find the info that I'm looking for, so let's define it:

我已经阅读了有关存储代码片段的几个讨论,但我找不到我正在寻找的信息,所以让我们定义它:

  • At home, I have several side projects, most of them quite small, one large, and numerous little examples that demonstrate a specific language feature (for example, some template trick in C++).
  • 在家里,我有几个辅助项目,其中大多数都很小,一个很大,还有许多演示特定语言功能的小例子(例如,C ++中的一些模板技巧)。

  • Since I think that these examples will be useful to be available when I'm at work for a reference instead of trying to remember the exact details of this or that particular snippet that was tried and worked at home, I want to have it available for example on a USB flash drive.
  • 因为我认为这些示例在我工作时可用于参考而不是试图记住在家中尝试和工作的这个或那个特定片段的确切细节是有用的,我想让它可用于USB闪存盘上的示例。

  • The problem is that most of the snippets/small programs/examples are organized, written, compiled and tested in Visual Studio, it will be duplication if I have to put them in some code snippet organizer application. I can copy to the flash drive the source of the Visual Studio solution with all the examples, but it is not so convenient for searching compared with a dedicated snippet repository organizer. Or maybe I can change this if I write better comments and description of the examples, and that will do the job.
  • 问题是大多数片段/小程序/示例都是在Visual Studio中组织,编写,编译和测试的,如果我必须将它们放在一些代码片段管理器应用程序中,它将是重复的。我可以使用所有示例将Visual Studio解决方案的源代码复制到闪存驱动器中,但与专用代码段存储库管理器相比,搜索不太方便。或者,如果我写出更好的评论和对示例的描述,我可以改变这一点,并且可以完成这项工作。

Any ideas, best practices, solutions, and experience with similar stuff are appreciated.

任何想法,最佳实践,解决方案和类似的经验都值得赞赏。

6 个解决方案

#1


6  

I keep everything in a source control repository, indexed by language. As I learn new languages, I translate some of my old useful stuff into the new language to learn how to do things in the new language.

我将所有内容保存在源代码控制存储库中,并按语言编制索引。当我学习新语言时,我将一些旧的有用的东西翻译成新语言,以学习如何用新语言做事。

#2


5  

I store my code within an online source repository - code.google.com, and use the web front-end to browse for the interesting bits.

我将我的代码存储在一个在线源代码库 - code.google.com中,并使用Web前端浏览有趣的位。

Since it's on google, it's easy to search too..

由于它在谷歌上,它也很容易搜索..

All you'd need to do is organise the code into folders for each language, area, etc, and have them all within the same repository.

您需要做的就是将代码组织到每种语言,区域等的文件夹中,并将它们全部放在同一个存储库中。

The only downside is that if you want to keep your snippets secret, then this won't work. Obviously, you'll need to be online to access this way, but you can easily do an SVN update intermittently to refresh any local offline copies you may need.

唯一的缺点是,如果你想保密你的片段,那么这将无法工作。显然,您需要联机才能以这种方式访问​​,但您可以轻松地间歇性地进行SVN更新,以刷新您可能需要的任何本地脱机副本。

#3


4  

I find a Wiki is the perfect tool for keeping bits of info and code snippets.

我发现Wiki是保存信息和代码片段的完美工具。

#4


1  

Not so much for snippets, but for common libraries that I've either collected or developed myself, I keep a folder called "_lib". Whenever I need something from that folder (eg: jquery.js, a CSS reset), I just symlink that directory into my working folder and hey presto! Alternatively, I just use svn:externals to bring it in to other projects.

对于片段而言并非如此,但对于我自己收集或开发的常见库,我保留了一个名为“_lib”的文件夹。每当我需要该文件夹中的某些内容时(例如:jquery.js,CSS重置),我只需将该目录符号链接到我的工作文件夹中即可!或者,我只使用svn:externals将其引入其他项目。

#5


0  

I work in Visual Studio at home and at work.

我在家里和工作中使用Visual Studio。

I basically have all my code snippets in a folder that is synced to my Live Mesh. I then have each folder added to VS to enable it to auto-detect new snippets. Works like a charm for me :)

我基本上将所有代码片段都放在一个与我的Live Mesh同步的文件夹中。然后,我将每个文件夹添加到VS,以使其能够自动检测新的代码段。像我的魅力对我来说:)

So, I create a snippet in Snippy, save it to my synced folder. Boom, works in VS with no additional configuration at all :)

因此,我在Snippy中创建了一个片段,将其保存到我的同步文件夹中。 Boom,在VS中工作,没有任何额外的配置:)

#6


0  

Check out Snippets — code snippets manager that is available on Mac and Windows, supports sync and it's free. There is a feature called Distributors that allows you to re-use code snippets in your IDE or code editor natively. Here is a list of currently supported IDEs.

查看Snippets - Mac和Windows上提供的代码片段管理器,支持同步,它是免费的。有一个名为Distributors的功能,允许您在IDE或代码编辑器中本地重用代码片段。以下是当前支持的IDE列表。

#1


6  

I keep everything in a source control repository, indexed by language. As I learn new languages, I translate some of my old useful stuff into the new language to learn how to do things in the new language.

我将所有内容保存在源代码控制存储库中,并按语言编制索引。当我学习新语言时,我将一些旧的有用的东西翻译成新语言,以学习如何用新语言做事。

#2


5  

I store my code within an online source repository - code.google.com, and use the web front-end to browse for the interesting bits.

我将我的代码存储在一个在线源代码库 - code.google.com中,并使用Web前端浏览有趣的位。

Since it's on google, it's easy to search too..

由于它在谷歌上,它也很容易搜索..

All you'd need to do is organise the code into folders for each language, area, etc, and have them all within the same repository.

您需要做的就是将代码组织到每种语言,区域等的文件夹中,并将它们全部放在同一个存储库中。

The only downside is that if you want to keep your snippets secret, then this won't work. Obviously, you'll need to be online to access this way, but you can easily do an SVN update intermittently to refresh any local offline copies you may need.

唯一的缺点是,如果你想保密你的片段,那么这将无法工作。显然,您需要联机才能以这种方式访问​​,但您可以轻松地间歇性地进行SVN更新,以刷新您可能需要的任何本地脱机副本。

#3


4  

I find a Wiki is the perfect tool for keeping bits of info and code snippets.

我发现Wiki是保存信息和代码片段的完美工具。

#4


1  

Not so much for snippets, but for common libraries that I've either collected or developed myself, I keep a folder called "_lib". Whenever I need something from that folder (eg: jquery.js, a CSS reset), I just symlink that directory into my working folder and hey presto! Alternatively, I just use svn:externals to bring it in to other projects.

对于片段而言并非如此,但对于我自己收集或开发的常见库,我保留了一个名为“_lib”的文件夹。每当我需要该文件夹中的某些内容时(例如:jquery.js,CSS重置),我只需将该目录符号链接到我的工作文件夹中即可!或者,我只使用svn:externals将其引入其他项目。

#5


0  

I work in Visual Studio at home and at work.

我在家里和工作中使用Visual Studio。

I basically have all my code snippets in a folder that is synced to my Live Mesh. I then have each folder added to VS to enable it to auto-detect new snippets. Works like a charm for me :)

我基本上将所有代码片段都放在一个与我的Live Mesh同步的文件夹中。然后,我将每个文件夹添加到VS,以使其能够自动检测新的代码段。像我的魅力对我来说:)

So, I create a snippet in Snippy, save it to my synced folder. Boom, works in VS with no additional configuration at all :)

因此,我在Snippy中创建了一个片段,将其保存到我的同步文件夹中。 Boom,在VS中工作,没有任何额外的配置:)

#6


0  

Check out Snippets — code snippets manager that is available on Mac and Windows, supports sync and it's free. There is a feature called Distributors that allows you to re-use code snippets in your IDE or code editor natively. Here is a list of currently supported IDEs.

查看Snippets - Mac和Windows上提供的代码片段管理器,支持同步,它是免费的。有一个名为Distributors的功能,允许您在IDE或代码编辑器中本地重用代码片段。以下是当前支持的IDE列表。