Skip to content

alexpetros/copy-this-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy This Code

Don't add it to your package.json. Don't credit me. Just copy the code into your project if you think it's useful.

Make sure to use GitHub permalinks if sharing; I plan to keep the repo up indefinitely but files might move around.

Rationale

This repo serves two purposes: one personal and the other pedagogical.

First, it reflects my understanding of the best way to do various common tasks, originally in JavaScript but now in a bunch of languages. I am often surprised at how easy it is to implement a lot of the things that we routinely turn to libraries for. I'm creating a little space for myself to save these snippets so that I can refer to them.

The second purpose is to challenge myself and, eventually, others, to better develop a sense of when it is worth learning how something is done versus accepting someone's interface for doing it. To use escaping HTML as an example: you can accept Jinja or Spring's interface that "makes HTML safe" for you, or you can learn what it means to safely template HTML yourself, and in the process learn exactly how an XSS attack works.

If you copy one of these files and then I learn I was wrong about something, you have inherited that mistake and the need to correct it, as my update will not save you. On the other hand, the process of reading and copying code forces you to accept responsibility for it in a way that importing a library does not; you're better equipped to fill the gaps than if you'd simply taken my word for it that I, as a publisher on the Node Package Manager repository, know what I'm doing.

I will probably share links to this repo with people, but it's not intended to be a definitive archive of anything at this point. Use at your own risk.

Licensing

All code in this repo is licensed under the 0-clause BSD license. Sometimes code is noted as being shared by someone else; if it's included here, they have agreed that it can be shared under the same terms.

About

Code snippets of varying utility, for your use

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published