├── LICENSE
├── README.md
├── guides
├── choosing_a_language.md
└── python_environment_setup.md
└── snippets
└── GCal_recurrence.md
/LICENSE:
--------------------------------------------------------------------------------
1 | Attribution 4.0 International
2 |
3 | =======================================================================
4 |
5 | Creative Commons Corporation ("Creative Commons") is not a law firm and
6 | does not provide legal services or legal advice. Distribution of
7 | Creative Commons public licenses does not create a lawyer-client or
8 | other relationship. Creative Commons makes its licenses and related
9 | information available on an "as-is" basis. Creative Commons gives no
10 | warranties regarding its licenses, any material licensed under their
11 | terms and conditions, or any related information. Creative Commons
12 | disclaims all liability for damages resulting from their use to the
13 | fullest extent possible.
14 |
15 | Using Creative Commons Public Licenses
16 |
17 | Creative Commons public licenses provide a standard set of terms and
18 | conditions that creators and other rights holders may use to share
19 | original works of authorship and other material subject to copyright
20 | and certain other rights specified in the public license below. The
21 | following considerations are for informational purposes only, are not
22 | exhaustive, and do not form part of our licenses.
23 |
24 | Considerations for licensors: Our public licenses are
25 | intended for use by those authorized to give the public
26 | permission to use material in ways otherwise restricted by
27 | copyright and certain other rights. Our licenses are
28 | irrevocable. Licensors should read and understand the terms
29 | and conditions of the license they choose before applying it.
30 | Licensors should also secure all rights necessary before
31 | applying our licenses so that the public can reuse the
32 | material as expected. Licensors should clearly mark any
33 | material not subject to the license. This includes other CC-
34 | licensed material, or material used under an exception or
35 | limitation to copyright. More considerations for licensors:
36 | wiki.creativecommons.org/Considerations_for_licensors
37 |
38 | Considerations for the public: By using one of our public
39 | licenses, a licensor grants the public permission to use the
40 | licensed material under specified terms and conditions. If
41 | the licensor's permission is not necessary for any reason--for
42 | example, because of any applicable exception or limitation to
43 | copyright--then that use is not regulated by the license. Our
44 | licenses grant only permissions under copyright and certain
45 | other rights that a licensor has authority to grant. Use of
46 | the licensed material may still be restricted for other
47 | reasons, including because others have copyright or other
48 | rights in the material. A licensor may make special requests,
49 | such as asking that all changes be marked or described.
50 | Although not required by our licenses, you are encouraged to
51 | respect those requests where reasonable. More_considerations
52 | for the public:
53 | wiki.creativecommons.org/Considerations_for_licensees
54 |
55 | =======================================================================
56 |
57 | Creative Commons Attribution 4.0 International Public License
58 |
59 | By exercising the Licensed Rights (defined below), You accept and agree
60 | to be bound by the terms and conditions of this Creative Commons
61 | Attribution 4.0 International Public License ("Public License"). To the
62 | extent this Public License may be interpreted as a contract, You are
63 | granted the Licensed Rights in consideration of Your acceptance of
64 | these terms and conditions, and the Licensor grants You such rights in
65 | consideration of benefits the Licensor receives from making the
66 | Licensed Material available under these terms and conditions.
67 |
68 |
69 | Section 1 -- Definitions.
70 |
71 | a. Adapted Material means material subject to Copyright and Similar
72 | Rights that is derived from or based upon the Licensed Material
73 | and in which the Licensed Material is translated, altered,
74 | arranged, transformed, or otherwise modified in a manner requiring
75 | permission under the Copyright and Similar Rights held by the
76 | Licensor. For purposes of this Public License, where the Licensed
77 | Material is a musical work, performance, or sound recording,
78 | Adapted Material is always produced where the Licensed Material is
79 | synched in timed relation with a moving image.
80 |
81 | b. Adapter's License means the license You apply to Your Copyright
82 | and Similar Rights in Your contributions to Adapted Material in
83 | accordance with the terms and conditions of this Public License.
84 |
85 | c. Copyright and Similar Rights means copyright and/or similar rights
86 | closely related to copyright including, without limitation,
87 | performance, broadcast, sound recording, and Sui Generis Database
88 | Rights, without regard to how the rights are labeled or
89 | categorized. For purposes of this Public License, the rights
90 | specified in Section 2(b)(1)-(2) are not Copyright and Similar
91 | Rights.
92 |
93 | d. Effective Technological Measures means those measures that, in the
94 | absence of proper authority, may not be circumvented under laws
95 | fulfilling obligations under Article 11 of the WIPO Copyright
96 | Treaty adopted on December 20, 1996, and/or similar international
97 | agreements.
98 |
99 | e. Exceptions and Limitations means fair use, fair dealing, and/or
100 | any other exception or limitation to Copyright and Similar Rights
101 | that applies to Your use of the Licensed Material.
102 |
103 | f. Licensed Material means the artistic or literary work, database,
104 | or other material to which the Licensor applied this Public
105 | License.
106 |
107 | g. Licensed Rights means the rights granted to You subject to the
108 | terms and conditions of this Public License, which are limited to
109 | all Copyright and Similar Rights that apply to Your use of the
110 | Licensed Material and that the Licensor has authority to license.
111 |
112 | h. Licensor means the individual(s) or entity(ies) granting rights
113 | under this Public License.
114 |
115 | i. Share means to provide material to the public by any means or
116 | process that requires permission under the Licensed Rights, such
117 | as reproduction, public display, public performance, distribution,
118 | dissemination, communication, or importation, and to make material
119 | available to the public including in ways that members of the
120 | public may access the material from a place and at a time
121 | individually chosen by them.
122 |
123 | j. Sui Generis Database Rights means rights other than copyright
124 | resulting from Directive 96/9/EC of the European Parliament and of
125 | the Council of 11 March 1996 on the legal protection of databases,
126 | as amended and/or succeeded, as well as other essentially
127 | equivalent rights anywhere in the world.
128 |
129 | k. You means the individual or entity exercising the Licensed Rights
130 | under this Public License. Your has a corresponding meaning.
131 |
132 |
133 | Section 2 -- Scope.
134 |
135 | a. License grant.
136 |
137 | 1. Subject to the terms and conditions of this Public License,
138 | the Licensor hereby grants You a worldwide, royalty-free,
139 | non-sublicensable, non-exclusive, irrevocable license to
140 | exercise the Licensed Rights in the Licensed Material to:
141 |
142 | a. reproduce and Share the Licensed Material, in whole or
143 | in part; and
144 |
145 | b. produce, reproduce, and Share Adapted Material.
146 |
147 | 2. Exceptions and Limitations. For the avoidance of doubt, where
148 | Exceptions and Limitations apply to Your use, this Public
149 | License does not apply, and You do not need to comply with
150 | its terms and conditions.
151 |
152 | 3. Term. The term of this Public License is specified in Section
153 | 6(a).
154 |
155 | 4. Media and formats; technical modifications allowed. The
156 | Licensor authorizes You to exercise the Licensed Rights in
157 | all media and formats whether now known or hereafter created,
158 | and to make technical modifications necessary to do so. The
159 | Licensor waives and/or agrees not to assert any right or
160 | authority to forbid You from making technical modifications
161 | necessary to exercise the Licensed Rights, including
162 | technical modifications necessary to circumvent Effective
163 | Technological Measures. For purposes of this Public License,
164 | simply making modifications authorized by this Section 2(a)
165 | (4) never produces Adapted Material.
166 |
167 | 5. Downstream recipients.
168 |
169 | a. Offer from the Licensor -- Licensed Material. Every
170 | recipient of the Licensed Material automatically
171 | receives an offer from the Licensor to exercise the
172 | Licensed Rights under the terms and conditions of this
173 | Public License.
174 |
175 | b. No downstream restrictions. You may not offer or impose
176 | any additional or different terms or conditions on, or
177 | apply any Effective Technological Measures to, the
178 | Licensed Material if doing so restricts exercise of the
179 | Licensed Rights by any recipient of the Licensed
180 | Material.
181 |
182 | 6. No endorsement. Nothing in this Public License constitutes or
183 | may be construed as permission to assert or imply that You
184 | are, or that Your use of the Licensed Material is, connected
185 | with, or sponsored, endorsed, or granted official status by,
186 | the Licensor or others designated to receive attribution as
187 | provided in Section 3(a)(1)(A)(i).
188 |
189 | b. Other rights.
190 |
191 | 1. Moral rights, such as the right of integrity, are not
192 | licensed under this Public License, nor are publicity,
193 | privacy, and/or other similar personality rights; however, to
194 | the extent possible, the Licensor waives and/or agrees not to
195 | assert any such rights held by the Licensor to the limited
196 | extent necessary to allow You to exercise the Licensed
197 | Rights, but not otherwise.
198 |
199 | 2. Patent and trademark rights are not licensed under this
200 | Public License.
201 |
202 | 3. To the extent possible, the Licensor waives any right to
203 | collect royalties from You for the exercise of the Licensed
204 | Rights, whether directly or through a collecting society
205 | under any voluntary or waivable statutory or compulsory
206 | licensing scheme. In all other cases the Licensor expressly
207 | reserves any right to collect such royalties.
208 |
209 |
210 | Section 3 -- License Conditions.
211 |
212 | Your exercise of the Licensed Rights is expressly made subject to the
213 | following conditions.
214 |
215 | a. Attribution.
216 |
217 | 1. If You Share the Licensed Material (including in modified
218 | form), You must:
219 |
220 | a. retain the following if it is supplied by the Licensor
221 | with the Licensed Material:
222 |
223 | i. identification of the creator(s) of the Licensed
224 | Material and any others designated to receive
225 | attribution, in any reasonable manner requested by
226 | the Licensor (including by pseudonym if
227 | designated);
228 |
229 | ii. a copyright notice;
230 |
231 | iii. a notice that refers to this Public License;
232 |
233 | iv. a notice that refers to the disclaimer of
234 | warranties;
235 |
236 | v. a URI or hyperlink to the Licensed Material to the
237 | extent reasonably practicable;
238 |
239 | b. indicate if You modified the Licensed Material and
240 | retain an indication of any previous modifications; and
241 |
242 | c. indicate the Licensed Material is licensed under this
243 | Public License, and include the text of, or the URI or
244 | hyperlink to, this Public License.
245 |
246 | 2. You may satisfy the conditions in Section 3(a)(1) in any
247 | reasonable manner based on the medium, means, and context in
248 | which You Share the Licensed Material. For example, it may be
249 | reasonable to satisfy the conditions by providing a URI or
250 | hyperlink to a resource that includes the required
251 | information.
252 |
253 | 3. If requested by the Licensor, You must remove any of the
254 | information required by Section 3(a)(1)(A) to the extent
255 | reasonably practicable.
256 |
257 | 4. If You Share Adapted Material You produce, the Adapter's
258 | License You apply must not prevent recipients of the Adapted
259 | Material from complying with this Public License.
260 |
261 |
262 | Section 4 -- Sui Generis Database Rights.
263 |
264 | Where the Licensed Rights include Sui Generis Database Rights that
265 | apply to Your use of the Licensed Material:
266 |
267 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right
268 | to extract, reuse, reproduce, and Share all or a substantial
269 | portion of the contents of the database;
270 |
271 | b. if You include all or a substantial portion of the database
272 | contents in a database in which You have Sui Generis Database
273 | Rights, then the database in which You have Sui Generis Database
274 | Rights (but not its individual contents) is Adapted Material; and
275 |
276 | c. You must comply with the conditions in Section 3(a) if You Share
277 | all or a substantial portion of the contents of the database.
278 |
279 | For the avoidance of doubt, this Section 4 supplements and does not
280 | replace Your obligations under this Public License where the Licensed
281 | Rights include other Copyright and Similar Rights.
282 |
283 |
284 | Section 5 -- Disclaimer of Warranties and Limitation of Liability.
285 |
286 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
287 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
288 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
289 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
290 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
291 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
292 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
293 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
294 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
295 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
296 |
297 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
298 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
299 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
300 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
301 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
302 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
303 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
304 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
305 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
306 |
307 | c. The disclaimer of warranties and limitation of liability provided
308 | above shall be interpreted in a manner that, to the extent
309 | possible, most closely approximates an absolute disclaimer and
310 | waiver of all liability.
311 |
312 |
313 | Section 6 -- Term and Termination.
314 |
315 | a. This Public License applies for the term of the Copyright and
316 | Similar Rights licensed here. However, if You fail to comply with
317 | this Public License, then Your rights under this Public License
318 | terminate automatically.
319 |
320 | b. Where Your right to use the Licensed Material has terminated under
321 | Section 6(a), it reinstates:
322 |
323 | 1. automatically as of the date the violation is cured, provided
324 | it is cured within 30 days of Your discovery of the
325 | violation; or
326 |
327 | 2. upon express reinstatement by the Licensor.
328 |
329 | For the avoidance of doubt, this Section 6(b) does not affect any
330 | right the Licensor may have to seek remedies for Your violations
331 | of this Public License.
332 |
333 | c. For the avoidance of doubt, the Licensor may also offer the
334 | Licensed Material under separate terms or conditions or stop
335 | distributing the Licensed Material at any time; however, doing so
336 | will not terminate this Public License.
337 |
338 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
339 | License.
340 |
341 |
342 | Section 7 -- Other Terms and Conditions.
343 |
344 | a. The Licensor shall not be bound by any additional or different
345 | terms or conditions communicated by You unless expressly agreed.
346 |
347 | b. Any arrangements, understandings, or agreements regarding the
348 | Licensed Material not stated herein are separate from and
349 | independent of the terms and conditions of this Public License.
350 |
351 |
352 | Section 8 -- Interpretation.
353 |
354 | a. For the avoidance of doubt, this Public License does not, and
355 | shall not be interpreted to, reduce, limit, restrict, or impose
356 | conditions on any use of the Licensed Material that could lawfully
357 | be made without permission under this Public License.
358 |
359 | b. To the extent possible, if any provision of this Public License is
360 | deemed unenforceable, it shall be automatically reformed to the
361 | minimum extent necessary to make it enforceable. If the provision
362 | cannot be reformed, it shall be severed from this Public License
363 | without affecting the enforceability of the remaining terms and
364 | conditions.
365 |
366 | c. No term or condition of this Public License will be waived and no
367 | failure to comply consented to unless expressly agreed to by the
368 | Licensor.
369 |
370 | d. Nothing in this Public License constitutes or may be interpreted
371 | as a limitation upon, or waiver of, any privileges and immunities
372 | that apply to the Licensor or You, including from the legal
373 | processes of any jurisdiction or authority.
374 |
375 |
376 | =======================================================================
377 |
378 | Creative Commons is not a party to its public
379 | licenses. Notwithstanding, Creative Commons may elect to apply one of
380 | its public licenses to material it publishes and in those instances
381 | will be considered the “Licensor.” The text of the Creative Commons
382 | public licenses is dedicated to the public domain under the CC0 Public
383 | Domain Dedication. Except for the limited purpose of indicating that
384 | material is shared under a Creative Commons public license or as
385 | otherwise permitted by the Creative Commons policies published at
386 | creativecommons.org/policies, Creative Commons does not authorize the
387 | use of the trademark "Creative Commons" or any other trademark or logo
388 | of Creative Commons without its prior written consent including,
389 | without limitation, in connection with any unauthorized modifications
390 | to any of its public licenses or any other arrangements,
391 | understandings, or agreements concerning use of licensed material. For
392 | the avoidance of doubt, this paragraph does not form part of the
393 | public licenses.
394 |
395 | Creative Commons may be contacted at creativecommons.org.
396 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![CC BY 4.0][cc-by-shield]][cc-by]
2 |
3 | This work is licensed under a
4 | [Creative Commons Attribution 4.0 International License][cc-by].
5 | [![CC BY 4.0][cc-by-image]][cc-by]
6 |
7 | [cc-by]: http://creativecommons.org/licenses/by/4.0/
8 | [cc-by-image]: https://i.creativecommons.org/l/by/4.0/88x31.png
9 | [cc-by-shield]: https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg
10 |
11 | # codingForChemists
12 | Resources for and by the #codingForChemists Discord community!
13 | If you are interested in joining the community, please contact me directly through [my website](https://supersciencegrl.co.uk).
14 |
15 | ### Put your spin on the repo!
16 | - Submit a [**pull request**](https://github.com/supersciencegrl/codingForChemists/pulls) to submit your content to be added to the repo. Content should be suitable for beginner or intermediate-level coders, and aimed at chemists
17 | - The [**Issues**](https://github.com/supersciencegrl/codingForChemists/issues) tab is our wish list. Please submit things you want to see here, or point (with sufficient detail) to any problems in our published content
18 | - Very little in this repo will have been made by me [supersciencegrl](https://github.com/supersciencegrl/)!
19 |
20 | # Contents
21 | ## Guides folder
22 | ### How to choose a language (for chemists and the chemistry-adjacent)
23 | [https://github.com/supersciencegrl/codingForChemists/blob/main/guides/choosing_a_language.md](guides/choosing_a_language.md)
24 |
How to choose a language, for whichever use case(s) you are interested in, for example:
25 | - General purpose programming languages
26 | - Data collection, cleaning, processing, and visualization
27 | - Machine learning and artificial intellignece
28 | - Systems programming & scripting
29 | - Instruments & devices
30 | - Numerical computation
31 | - Web programming
32 | - GUI applications
33 | ### How to install Python and create environments
34 | [https://github.com/supersciencegrl/codingForChemists/blob/main/guides/python_environment_setup.md](guides/python_environment_setup.md)
35 | - Why Python environments?
36 | - Option 1: Installing Anaconda or Miniconda
37 | - Option 2: Installing Python from python.org
38 | - Other options
39 |
--------------------------------------------------------------------------------
/guides/choosing_a_language.md:
--------------------------------------------------------------------------------
1 | # How to Choose a Programming Language
2 | ## For Chemists and the Chemistry-Adjacent
3 |
4 | ### Table of Contents
5 |
6 | - [How to Choose a Programming Language](#how-to-choose-a-programming-language)
7 | - [For Chemists and the Chemistry-Adjacent](#for-chemists-and-the-chemistry-adjacent)
8 | - [Table of Contents](#table-of-contents)
9 | - [Introduction](#introduction)
10 | - [General Purpose Programming Languages](#general-purpose-programming-languages)
11 | - [Data Collection, Cleaning, Processing, and Visualization](#data-collection-cleaning-processing-and-visualization)
12 | - [Machine Learning and Artificial Intelligence](#machine-learning-and-artificial-intelligence)
13 | - [Systems Programming and Scripting](#systems-programming-and-scripting)
14 | - [Instruments and Devices](#instruments-and-devices)
15 | - [Numerical Computation](#numerical-computation)
16 | - [Web Programming](#web-programming)
17 | - [GUI Applications](#gui-applications)
18 | - [Distributing Applications](#distributing-applications)
19 | - [Desktop Applictions](#desktop-applictions)
20 | - [Mobile Applications](#mobile-applications)
21 | - [Conclusion](#conclusion)
22 |
23 |
24 | ### Introduction
25 |
26 | If you are interested in programming,
27 | but don't know where to start,
28 | answering the question "What programming language should I learn?"
29 | is the first obstacle to overcome.
30 |
31 | This is an (opinionated, non-authoritative) guide
32 | to help people answer that question for themselves.
33 | The author will try to make their personal opinions
34 | and lack of knowledge clear as warranted.
35 | Corrections and additions to this guide are welcome!
36 |
37 | This guide will mention the most commonly-encountered languages
38 | that are either particularly useful to chemists,
39 | or are particularly well suited for people just starting to learn programming.
40 |
41 | Whatever language you choose,
42 | once you dive into it you will also learn tools, skills and habits
43 | that are not language-specific.
44 | If you spend some time learning one language, and decide to try another,
45 | you will have the pieces in place to pick up the next language
46 | and start working with it.
47 |
48 | This guide is structured around the likely answers to that question:
49 |
50 | **
Why are you interested in programming?
**
51 |
52 | ### General Purpose Programming Languages
53 |
54 | Most of this guide will be for people that already have some idea
55 | of what they want to do with their new coding superpowers.
56 | However, maybe you just think coding sounds generally useful,
57 | interesting, or fun.
58 | If that is the case,
59 | the author's *opinionated* answer is:
60 |
61 | **[Python.](https://www.python.org/)
**
62 |
63 | Python has been described as being "the second-best language for everything".
64 | In particular, it's a top-tier language for data processing and visualization,
65 | machine learning (ML), and artificial intelligence (AI).
66 | There is a huge ecosystem of scientific and numeric packages for Python as well.
67 |
68 | Plus, (in the author's opinion), Python is easy to pick up
69 | and start doing useful things with.
70 | The language is *expressive*, almost reading like "pseudo-code" at times.
71 | For example, let's say you wanted to tell the computer:
72 |
73 | ```text
74 | "for each name in my list of guests: Amy, Bob, Cathy and Doug,
75 | print "Hi, (name of guest!)"
76 | ```
77 |
78 | This is what it would look like in Python:
79 |
80 | ```python
81 | for name in ['Amy', 'Bob', 'Cathy', 'Doug']:
82 | print(f'Hi, {name}!')
83 | ```
84 |
85 | In contrast, this is what it would look like written in c:
86 |
87 | ```c
88 | #include
89 | #include
90 | int main(void) {
91 | char guests[4][10] = {"Amy", "Bob", "Cathy", "Doug"};
92 | for (int i = 0; i < 4; i++) {
93 | printf("Hello, %s!\n", guests[i]);
94 | }
95 | return EXIT_SUCCESS;
96 | }
97 | ```
98 | >#### When might "Python" not be the best answer?
99 | >
100 | >The following situations can be problematic with Python, to varying degrees.
101 | >
102 | >- Running on multiple CPUs ("multithreading"):
103 | this is possible, but Python has the notorious
104 | [Global Interpreter Lock (GIL)](https://www.python.org/)
105 | that makes this cumbersome.
106 | >- speed-critical applications: Python is a slow language.
107 | However, it can interface with faster languages.
108 | For example, the widely-used `numpy` libary for numerical computation
109 | uses Fortran libraries "under the hood",
110 | and its possible to write Python code
111 | where the faster language is performing most of the work.
112 | However, if you are designing a computer
113 | to perform stock market micro-transactions so fast
114 | that your speed is limited by how long the wire is
115 | between your computer and the stock exchange across the street,
116 | you don't want to be using Python.
117 | >- creating cross-platform desktop applications
118 | that you can distribute to non-programmer friends.
119 | This is doable, especially for small applications,
120 | but can get tricky as your application gets more complicated.
121 | Third-party tools are required
122 | to bundle your python code as a one-file application.
123 | >- writing applications for mobile devices. VERY DIFFICULT.
124 | Possible (e.g. with [kivy](https://kivy.org) or [BeeWare](https://beeware.org), but Here Be Dragons.
125 |
126 | An honorable mention goes to
127 | [the Julia programming language](https://julialang.org).
128 | The author does not have Julia experience,
129 | and the Julia community is much smaller than the Python community.
130 | However, it is a multi-purpose language
131 | that seems particularly well-suited for scientific computing,
132 | data science and visualization, machine learning and numerical computation.
133 | It is also much faster than Python, if computation speed is a concern.
134 |
135 | A final consideration is JavaScript (plus HTML and css), which is useful in many of the contexts listed later in this guide.
136 |
137 | ### Data Collection, Cleaning, Processing, and Visualization
138 |
139 | Python and [R](https://www.tidyverse.org/) are excellent choices.
140 |
141 | An advantage of R is that there is a
142 | "[tidyverse](https://www.tidyverse.org/)" of widely-adopted packages,
143 | where there is a clear favorite way to do something,
144 | such as make a plot or a web application. A disadvantage is that is focused on working with data, so e.g. you wouldn't write a desktop application in R.
145 |
146 | Python has the advantage of being useful in many contexts beyond data science. However, you may find yourself spoiled for choice when selecting tools, e.g. what library to use for plotting graphs.
147 |
148 | Other considerations:
149 |
150 | - Julia
151 | - [SQL (structured query language)](https://en.wikipedia.org/wiki/SQL):
152 | If you find yourself needing to work with databases, adding some SQL knowledge on top of your preferred programming language will be useful.
153 | - See also
154 | [this article on Codecademy](https://www.codecademy.com/resources/blog/data-science-languages/)
155 | describing these and other options.
156 |
157 | ### Machine Learning and Artificial Intelligence
158 |
159 | You will find more ML/AI resources that use Python than any other language. There is a lot to learn in this field, so the author's suggestion is start learning using Python to get up to speed before considering another language.
160 |
161 | ### Systems Programming and Scripting
162 |
163 | If your interest is working with the nuts and bolts of a computer system
164 | (working with files and directories, scheduling automated tasks, etc.),
165 | Python is a great place to start.
166 | There is a popular
167 | [book written about automating tasks with Python](https://automatetheboringstuff.com).
168 | It's a good resource for both learning Python and finding ideas for projects.
169 |
170 | Whatever programming language you choose,
171 | you will need to learn how to use the command line interface
172 | ('CLI'; 'terminal').
173 | On Unix-like systems (macOS; linux) this means learning bash
174 | or a closely-related variant
175 | (Macs recently switched from bash to zsh, but they are mostly the same).
176 | Windows comes with PowerShell, but you can install a bash CLI as well.
177 |
178 | Basic commands such as navigating a directory, creating files and folders,
179 | and running your programs can be learned in minutes.
180 | If you dig deeper, the command line can be extremely powerful.
181 | As a motivational example, here is a one-line command that will:
182 | - recursively search through a tree of nested NMR data folders;
183 | - find the temperature each experiment was run at; and
184 | - save a .csv that lists all NMR jobs and temperatures:
185 |
186 | ```bash
187 | $ grep -r "##\$TE=" --include="*acqus" . | cut -c 3- | sort | sed -e 's/:##\$TE= /,/' > T_pH7.csv
188 | ```
189 |
190 | That may look incomprehensible,
191 | but it's composed from several individual bash commands
192 | that you would learn in any basic bash guide.
193 | With very little bash experience,
194 | the author could accomplish in one terminal command
195 | a task that would require many lines of Python or equivalent code.
196 |
197 | Both Python and Bash are widely used for writing executable "scripts"
198 | to automate common tasks.
199 |
200 | There is a large family of "curly-brace" languages
201 | that are all good "professional programmer" choices for system programming:
202 | c++, Go, Java, Rust, etc.
203 | The author's advice is to avoid languages that are so "low-level"
204 | that you have to constantly consider fussy things, such as:
205 | - where and how variables are stored in memory and accessed;
206 | - how to manage memory allocation;
207 | - determining "which one of these nine types of integers is best
208 | to represent my number?".
209 |
210 | However, if you really want to learn programming
211 | from the viewpoint of a computer scientist or a software engineer,
212 | a language such as c/c++ will make you learn
213 | what goes on "under the hood" of your computer.
214 |
215 | ### Instruments and Devices
216 |
217 | If you want to get started with devices, microcontrollers,
218 | and Internet of Things (IoT) projects, Python is a good choice.
219 | It's the default choice if you are working on a Raspberry Pi.
220 | Many controllers can be programmed with Python
221 | or a subset of Python (e.g. [CircuitPython](https://circuitpython.org)).
222 |
223 | [Arduino microcontrollers](https://www.arduino.cc) use a variant of c++ for their programs, but Python is also supported (via [MicroPython](https://docs.arduino.cc/learn/programming/arduino-and-python)).
224 |
225 | It's not possible to generalize across scientific instrumentation,
226 | but you may find low-level languages like c being used.
227 |
228 | ### Numerical Computation
229 |
230 | Even though Python is a slow language,
231 | it can make use of libraries that run faster code
232 | (e.g. FORTRAN, c) "under the hood".
233 | An example of this is
234 | [the `numpy` library](https://numpy.org) for numerical computation.
235 | With optimization, Python can often be fast enough for your needs.
236 |
237 | There are libraries that can help speed up your Python code,
238 | e.g. by [implementing "just-in-time" compiling](https://numba.pydata.org)
239 | or [GPU acceleration](https://cupy.dev).
240 | There is also a version of Python,
241 | [PyPy](https://www.pypy.org), that runs faster than standard Python.
242 |
243 | If your code needs to run faster than Python is capable of, here are some alternatives to consider:
244 |
245 | - Julia
246 | - MATLAB is widely used by scientists and engineers,
247 | but it's proprietary.
248 | If your workplace has bought a license for it,
249 | and you do a lot of numerical work (e.g. linear algebra),
250 | it can be very useful.
251 | - You could consider the "curly-brace" languages such as c/c++,
252 | but the learning curve will be steeper.
253 | If others in your field use one of these languages,
254 | it may be worth it.
255 |
256 | ### Web Programming
257 |
258 | If your primary interest in things Web-related
259 | (creating web pages, webservers, online databases etc.),
260 | JavaScript (JS) is ubiquitous in Web programming.
261 | It is also a great choice for a first language to learn.
262 | It can be used for both "front-end" web development
263 | (writing JS/HTML/CSS code for display in a web browser),
264 | and in "back-end" development (setting up a web server).
265 | Most beginners will be interested in the front-end work of creating a website, and let a web hosting service take care of the back end.
266 |
267 | Python is also a good choice, especially for back-end work[^1].
268 | Popular web frameworks include Flask, Django, and FastAPI.
269 | For example,
270 | if you have data in a database
271 | that you want to make available over the internet,
272 | you can use one of these frameworks
273 | to create a web API (Application Programming Interface)
274 | that will let people around the world access and use your data.
275 |
276 | [^1]: A promising new development is PyScript,
277 | first announced at PyCon US 2022.
278 | PyScript is a Python interpreter plus some of the most popular libraries,
279 | bundled together and compiled into Web Assembly language (WASM).
280 | There are other languages also finding their way into the browser via WASM,
281 | such as Rust.
282 |
283 | If you are not programming in a language that is native to mobile devices
284 | (e.g Swift for iOS or Java for Android),
285 | another way to get your program onto users' phones
286 | is to create a web application.
287 | Then, any device with a web browser would have access to your app.
288 |
289 | ### GUI Applications
290 |
291 | If you want to create an application with a graphical user interface (GUI),
292 | many languages will allow you to do this, including Python.
293 | If your *primary* interest in programming
294 | is that you want to create a desktop or mobile application, read on.
295 |
296 | #### Distributing Applications
297 |
298 | Some desktop programs come bundled in a single file.
299 | For example,
300 | you might download the file and drag it to your Applications folder,
301 | and then double-click it to run.
302 | Other programs run an installer
303 | to set up the required files on your user's system.
304 | If you are not a professional programmer,
305 | the one-file app is probably easier,
306 | and certainly safer for your intended user.
307 | However, some languages make bundling your program
308 | as a one-file desktop application easier than others.
309 |
310 | If you want to create a mobile application,
311 | you first have to consider if you want to target iOS, android, or both.
312 | Then, you have to consider the limitations of developing on that platform.
313 | For example, on iOS you will need to create a developer account.
314 | If you want other people to use your application on their iPhone,
315 | you'll need to pay Apple money and get a digital signature for verification.
316 |
317 | #### Desktop Applictions
318 |
319 | If you want to create an application
320 | that has the native look and feel of your favorite operating system
321 | (macOS or Windows),
322 | your main choices are Swift on macOS and C# ("C-sharp") on Windows.
323 | The author doesn't have much experience with these languages.
324 | However, C# and Microsoft's .NET platform make cross-platform
325 | and mobile apps possible as well,
326 | whereas Swift's primary focus is macOS applications[^2].
327 |
328 | [^2]: The author has a bias against heavy investment in a language
329 | that can depends on a parent company for its existence.
330 | For example, Apple could decide that they're dropping Swift
331 | as the preferred language for their platforms.
332 | Java's corporate sponsor, Oracle,
333 | has engaged in shady practices in the past, including
334 | [update installer that would try to install unwanted applications ('bloatware' or 'crapware) on its users' systems](https://www.zdnet.com/article/a-close-look-at-how-oracle-installs-deceptive-software-with-java-updates/).
335 | Visual Basic 6 (VB6) was very popular,
336 | allowing scientists, business people and hobbyists to create
337 | their own Windows applications.
338 | Microsoft's shift to the .NET platform
339 | effectively orphaned any development of VB6 programs.
340 | Using one of these languages can still be the right choice for you,
341 | but go in with eyes open.
342 |
343 | If you are also interested in web programming as well,
344 | [Electron apps written with JavaScript](https://www.electronjs.org)
345 | are a great solution.
346 | The author wrote this guide using Microsoft's VS Code,
347 | which is an Electron app.
348 | Other examples of Electron apps that you may be familiar with include:
349 | Discord, Dropbox, Slack, GitHub Desktop, and Microsoft Teams.
350 |
351 | Simple desktop applications in Python are not too difficult,
352 | but as the complexity goes up you may run into difficulties.
353 | You will need to choose a GUI framework and learn how to use it,
354 | and then you will need to use a tool to create the one-file application bundle.
355 | These applications basically copy an entire Python environment into the bundle,
356 | so a Python app tends to take up much more memory on a hard drive
357 | than a similar program written in a compiled language.
358 |
359 | In the less-beginner-friendly category, Java and c++ are commonly used to write cross-platform applications.
360 |
361 | #### Mobile Applications
362 |
363 | The author doesn't recommend first-time programmers learning a language focused on mobile development. That said:
364 |
365 | - For iOS, Swift is the language of choice.
366 |
367 | - For android:
368 | - Java is the historical choice
369 | - Kotlin has become very popular for android development
370 | - other c++-like languages are also supported
371 |
372 | ### Conclusion
373 |
374 | The journey of a thousand miles starts with a single step.
375 | This guide hopefully helps you take a step in the right direction.
376 | Even if you decide that a programming language is not for you,
377 | hopefully your interest in programming is now kindled,
378 | and the guide can help you retrace your steps and set out again. 😄
379 |
--------------------------------------------------------------------------------
/guides/python_environment_setup.md:
--------------------------------------------------------------------------------
1 | # Creating a Python Environment
2 |
3 | ## Contents
4 |
5 | - [Creating a Python Environment](#creating-a-python-environment)
6 | - [Contents](#contents)
7 | - [Introduction](#introduction)
8 | - [Why Python Environments?](#why-python-environments)
9 | - [Option 1: Installing Anaconda or Miniconda](#option-1-installing-anaconda-or-miniconda)
10 | - [Creating and Using a `conda` Environment](#creating-and-using-a-conda-environment)
11 | - [Installing Packages Into Your `conda` Environment](#installing-packages-into-your-conda-environment)
12 | - [Option 2: Installing Python from python.org](#option-2-installing-python-from-pythonorg)
13 | - [Creating and Using a `venv` Virtual Environment](#creating-and-using-a-venv-virtual-environment)
14 | - [Installing Packages Into Your `venv` Environment](#installing-packages-into-your-venv-environment)
15 | - [Other Options](#other-options)
16 |
17 | ## Introduction
18 |
19 | The goal is to enable you to create a python "environment"
20 | for each of your projects,
21 | tailored to its requirements.
22 |
23 | This guide will be opinionated.
24 | If you want to use another method than one described here,
25 | my advice would be to use that one method consistently.
26 | If you start using multiple methods,
27 | you run the risk of becoming XKCD \#1987:
28 |
29 | 
30 |
31 | This guide is focused on macOS and Windows installations.
32 | Linux can be trickier.
33 | One warning for Linux users:
34 | If you want to create virtual environments using `venv`,
35 | as described in this guide,
36 | some Linux distributions don't include `venv` with python,
37 | and you'll have to install it separately.
38 |
39 | ## Why Python Environments?
40 |
41 | You may think,
42 | "my computer already has Python on it. Why can't I just use that?"
43 | The problem is that this "system Python" is used by your operating system,
44 | and if you try to customize it by installing Python packages
45 | something might break.
46 | It's Python's extensibility
47 | that makes it so powerful and so widely useful,
48 | so it is highly likely that you will want
49 | to install additional libraries at some point.
50 |
51 | For example, if you want to do data analysis and visualization,
52 | you are very early on going to be installing libraries
53 | such as `pandas` and `matplotlib`.
54 | If you are following a tutorial,
55 | and at some point it the instructions say something like:
56 |
57 | ```bash
58 | pip install pandas
59 | ```
60 |
61 | or
62 |
63 | ```bash
64 | conda install pandas
65 | ```
66 |
67 | you will want to make sure you are installing these
68 | into a Python environment of your own, separate from system Python.
69 |
70 | At this point, if you started searching online
71 | how to go about downloading Python
72 | and creating environments,
73 | you'd probably find many, conflicting, recommendations on how to do this.
74 | I will recommend two methods in this guide:
75 |
76 | 1. Installing Anaconda (or miniconda),
77 | and managing virtual environments with `conda`.
78 | This is probably the best solution for people,
79 | particularly those with scientific interests, to get started.
80 | If you're interested in programming for data analysis and visualization,
81 | you can also obtain R this way.
82 | An Anaconda installation also makes it easy to start using Jupyter Notebooks,
83 | which are a great way to start learning Python interactively.
84 | 2. Installing Python directly from python.org,
85 | and creating virtual environments with `venv`.
86 | This is a minimalist approach.
87 |
88 | ## Option 1: Installing Anaconda or Miniconda
89 |
90 | A full Anaconda installs a lot of stuff on your computer
91 | that you may not need.
92 | However, if you're just starting out in programming,
93 | this is the easiest option.
94 | If hard drive space is a concern, you can install miniconda instead.
95 | [This guide](https://docs.anaconda.com/free/anaconda/getting-started/distro-or-miniconda/)
96 | on the Anaconda web site summarizes how to choose between the two.
97 |
98 | [Caltech's Be/Bi103 course](https://bebi103a.github.io/lessons/00/index.html)
99 | (Introduction to Data Analysis in the Biological Sciences)
100 | has great guides for setting up a python environment via Anaconda.
101 | The key steps are summarized below.
102 |
103 | 1. Download the
104 | [Anaconda](https://www.anaconda.com/download/)
105 | or [miniconda](https://docs.conda.io/en/latest/miniconda.html)
106 | installer and run it.
107 |
108 | - choose "Install for Me Only" if you are given that option
109 | - you may be prompted to install a (free) JetBrains IDE
110 | such as PyCharm or DataSpell.
111 | Unless you know you want to use it, skip this—
112 | you can always install it later if you want.
113 | 2. Open a command-line interface (CLI).
114 | - On macOS or Linux,
115 | where a bash-like command line is standard,
116 | a command prompt ending in "`$`"
117 | precedes the cursor where you start typing.
118 | Its exact text will be specific to your computer
119 | and where you opened the CLI from.
120 | However, your prompt should include "`(base)`",
121 | which indicates which conda environment you're currently using
122 | (here, the default "base" environment).
123 | For the terminal commands below,
124 | "`(environmentname)$`" represents the command prompt
125 | (and is not part of the commands you are entering in the CLI).
126 | - Windows users should use the "Anaconda Prompt" as the CLI.
127 | This is similar to Windows' "command prompt" CLI,
128 | but with redirections ("PATH") to conda libraries
129 | automatically set up for you.
130 | You can enter "anaconda prompt" into the Windows search bar
131 | to find this application.
132 | 3. Update your base conda installation and environment.
133 | It is a good idea to run the following commands
134 | not only after the initial installation,
135 | but every few weeks-to-months[^1].
136 |
137 | [^1]: When the author returned to his office computer
138 | after COVID remote working ended,
139 | its `conda` was so far out of date
140 | that `conda update conda` would no longer work.
141 | The `conda` updater needed a newer version of python, which could not be updated using the old `conda` version—Catch 22.
142 | A complete uninstall and reinstall of Anaconda was required.
143 |
144 | ```bash
145 | (base)$ conda update conda
146 | ```
147 | Follow the prompts to update conda itself, and then:
148 | ```bash
149 | (base)$ conda update --all
150 | ```
151 | and follow the prompts to update all the installed libraries.
152 |
153 | ### Creating and Using a `conda` Environment
154 |
155 | Although you can work from the base conda environment,
156 | for your own projects you will want to create an isolated environment.
157 | You'll be able to install only what you need for that project,
158 | and you can specify the versions of all the libraries to avoid conflicts.
159 | It is very easy to create environments with conda,
160 | and switch between environments as needed.
161 |
162 | A detailed guide can be found on the
163 | [Anaconda website](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).
164 | To get started, here are the most useful commands:
165 |
166 | - `conda create` is used to create a new environment.
167 | For example,
168 | if you were taking the Be/Bi 103 course
169 | and wanted to create an environment for it,
170 | you could do the following:
171 | ```bash
172 | (base)$ conda create --name bebi103
173 | ```
174 | However, that course requires that Python 3.9 is used,
175 | to make sure that all their code runs as originally written.
176 | Most likely, when you downloaded conda,
177 | you chose the most recent python for the base conda environment.
178 | If you know you need a specific python version,
179 | include it when you create the environment:
180 | ```bash
181 | (base)$ conda create --name bebi103 python=3.9
182 | ```
183 | You can also add specific packages that you want via this command, but it's not necessary. Installing packages is covered in the next section.
184 | - `conda env list` will list all your environments, e.g.:
185 | ```bash
186 | (base)$ conda env list
187 | # conda environments:
188 | #
189 | base * /Users/myname/opt/anaconda3
190 | bebi103 /Users/myname/opt/anaconda3/envs/bebi103
191 | ```
192 | The asterisk indicates the current active environment, which is still `base`.
193 | Note the location of your new environment inside the `/envs` folder.
194 | Every conda environment you create will be in a subfolder of `/envs`.
195 | - `conda activate` is used to switch to another environment, e.g.:
196 | ```bash
197 | (base)$ conda activate bebi103
198 | (bebi103)$
199 | ```
200 | - `conda list` will list all the packages installed in the active environment.
201 |
202 | - To deactivate the environment and return to using your base conda python:
203 | ```bash
204 | (bebi103)$ deactivate
205 | (base)
206 | ```
207 | - If you are already in your base conda environment, and you `deactivate`,
208 | you may exit conda completely.
209 | You'll no longer see an environment name in parentheses,
210 | and you'll be using whatever the non-conda default python is.
211 | If you didn't intend to do this,
212 | you can use `conda activate base` to go back.
213 |
214 |
215 | ### Installing Packages Into Your `conda` Environment
216 |
217 | An important difference when using conda environments is that,
218 | as much as possible,
219 | packages should **not** be installed using a `pip install`-like command,
220 | which is normally how Python packages are installed.
221 | For the packages you want to install,
222 | search online for installation instructions
223 | and see if there is a conda option.
224 |
225 | If there is,
226 | often `conda install {packagename}` works,
227 | but sometimes a specific "channel" must be listed
228 | for conda to find the package.
229 | For example, to install `pandas`,
230 | [follow the online instructions](https://anaconda.org/anaconda/pandas)
231 | to install it from the "anaconda" channel:
232 | ```bash
233 | (bebi103)$ conda install -c anaconda pandas
234 | ```
235 |
236 | Some packages do not have a conda installer.
237 | To "pip install" packages into your environment:
238 |
239 | 1. Make sure `pip` is installed in your current environment
240 | (and not just the base environment), e.g.
241 | ```bash
242 | (current_environment)$ conda install -n bebi103 pip
243 | ```
244 | This will install `pip` specifically to the bebi103 environment,
245 | regardless of whatever `current_environment` may be active.
246 | 2. To install a python package into your current environment:
247 | ```
248 | python -m pip install name_of_package
249 | ```
250 | **Note the use of `python -m`.**
251 | If you just `pip install` a package,
252 | [it may not get installed where you intended](https://snarky.ca/why-you-should-use-python-m-pip/).
253 |
254 | You can always find out which python interpreter you're currently using
255 | by entering `which python`(macOS/linux) or `where python`(Windows)
256 | in the command line.
257 | Then, `python -m pip install` will install packages to that environment.
258 |
259 | ## Option 2: Installing Python from python.org
260 |
261 | [This guide](https://pythontest.com/python/installing-python-3-11/) from Brian Okken covers the basic installation:
262 | 1. Go to [python.org](https://www.python.org/).
263 | 2. Hover over "Downloads". If you want the most recent release of Python,
264 | a button for its download will appear in the popup window.
265 | If you want to install a different Python version,
266 | or additional Python versions,
267 | you can click on "view the full list of downloads",
268 | and download a specific version from their list.
269 | 3. Run the installer.
270 | - **Windows users**: Check out Okken's guide.
271 | Specifically, don't click too quickly through the installer dialog.
272 | When you reach “Advanced Features”,
273 | check the box for “Add Python to environment variables”.
274 |
275 | ### Creating and Using a `venv` Virtual Environment
276 | A new user searching online can find many, conflicting ways
277 | to create a virtual environment.
278 | The current standard method is to
279 | [use the `venv` command](https://docs.python.org/3/library/venv.html).
280 | Ignore any guides that use the `virtualenv` command instead—
281 | these are out of date.
282 |
283 | Whereas conda environments can be used across projects,
284 | it is most common to include venv environments
285 | either in the top level of your project folder,
286 | or one folder above it.
287 | The former seems to be more common.
288 | So, if your project's code is contained in the directory `my_awesome_project`:
289 |
290 | 1. Open a terminal with `my_awesome_project` as the current working directory.
291 | For example, on macOS/linux using a bash terminal
292 | you can switch to that directory using `cd`,
293 | then double-check that you are in the right place using `pwd`:
294 | ```bash
295 | $ cd ~/my/path/to/my_awesome_project
296 | $ pwd
297 | /Users/myname/my/path/to/my_awesome_project
298 | ```
299 | 2. From the command line, enter:
300 | ```bash
301 | python -m venv .venv
302 | ```
303 | This creates a folder named .venv within my_awesome_project
304 | that contains your virtual environment.
305 | This would use your default python version.
306 | If you want to use another installed python version for a project,
307 | you can specify it like:
308 | ```bash
309 | python3.9 -m venv .venv
310 | ```
311 | > Naming the environment `.venv` or `.env` is a common convention,
312 | > but you can use whatever name you want.
313 | > Note that file names that begin with "."
314 | > are often hidden from you by default.
315 | > It's a way of denoting files
316 | > that you usually don't want to modify directly,
317 | > e.g. critical system files are often named this way
318 | > to protect them from accidental corruption by users.
319 | > To see hidden folders using your OS's file browser,
320 | > see [this guide](https://www.sonarworks.com/support/sonarworks/360003040160-Troubleshooting/360003204140-Troubleshooting/5005750481554-How-to-show-hidden-files-Mac-and-Windows-).
321 | > To include hidden files when using `ls` from a bash command line,
322 | > use `ls -a`.
323 |
324 | 3. Activate the virtual environment:
325 | assuming a virtual environment folder named `.venv`
326 | (as in the previous step):
327 | macOS:
328 | ```bash
329 | $ source .venv/bin/activate
330 | ```
331 |
332 | Windows cmd.exe command line:
333 | ```cmd
334 | $ .venv\Scripts\activate.bat
335 | ```
336 |
337 | Windows Powershell:
338 | ```powershell
339 | $ .venv\Scripts\Activate.ps1
340 | ```
341 |
342 | Note: if PowerShell gives an error message saying running scripts is disabled,
343 | enter the following command in PowerShell[^2]:
344 |
345 | [^2]: See [the python venv documentation]() for details.
346 |
347 | ```powershell
348 | $ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
349 | ```
350 | To deactivate the environment and return to using your system python:
351 | ```bash
352 | deactivate
353 | ```
354 |
355 | ### Installing Packages Into Your `venv` Environment
356 |
357 | To "pip install" packages into your environment:
358 |
359 | 1. Activate the environment as described in the previous section.
360 | 2. Check that you are using the python inside your virtual environment,
361 | using `which python`(macOS) or `where python`(Windows).
362 | 3. To install a python package into your current environment:
363 | ```
364 | python -m pip install name_of_package
365 | ```
366 | **Note the use of `python -m`.**
367 | If you just `pip install` a package,
368 | [it may not get installed where you intended](https://snarky.ca/why-you-should-use-python-m-pip/).
369 |
370 | ## Other Options
371 |
372 | - On macOS, homebrew can be used to install Python.
373 | However, the author thinks that combining homebrew python installation
374 | with other methods such as (Ana)conda can lead to XKCD #1987.
375 | - Power users, especially those writing python packages,
376 | can look at pyenv or asdf.
377 | The author strongly recommends
378 | [*Publishing Python Packages*](https://www.manning.com/books/publishing-python-packages)
379 | by Dane Hillard to see an example
380 | of a publishing toolset that includes asdf.
381 |
--------------------------------------------------------------------------------
/snippets/GCal_recurrence.md:
--------------------------------------------------------------------------------
1 | # GCal event recurrence
2 | ### This is an example method for quickly adding recurrence to existing Google Calendar url invitations, created for Dr Jennifer Polk!
3 |
4 | **Original url**
5 |
6 | https://calendar.google.com/calendar/event?action=TEMPLATE&tmeid=MzBtNzNpZWhoYWxzM3B2OWttMGVnanZkZW9fMjAyMzA2MTdUMjAwMDAwWiBqZW5uaWZlci5wb2xrQG0&tmsrc=jennifer.polk%40gmail.com&scp=ALL
7 |
8 | **New url**
9 |
10 | https://calendar.google.com/calendar/event?action=TEMPLATE&tmeid=MzBtNzNpZWhoYWxzM3B2OWttMGVnanZkZW9fMjAyMzA2MTdUMjAwMDAwWiBqZW5uaWZlci5wb2xrQG0&tmsrc=jennifer.polk%40gmail.com&scp=ALL&recur=RRULE:FREQ=DAILY;UNTIL=20230620
11 |
12 | **What has been added?**
13 |
14 | The url remains as before, except a 'recur' parameter has been added to the end. This looks as such
15 | `&recur=RRULE:FREQ=DAILY;UNTIL=20230620`. The RRULE parameter follows strict guidelines, which can be found [here](https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.5.3).
16 |
17 | Some of the most simple cases contain `FREQ=DAILY`, `FREQ=WEEKLY`, `FREQ=MONTHLY`.
18 | Any more complex repeat can also be made, for example "every other month on the second Friday of the month" - see the above link for details which include the `INTERVAL`, `BYDAY`, and `BYMONTHDAY` parameters.
19 | The `UNTIL` parameter takes a date in YYYYMMDD format, at minimum. A specific time and timezone can be added in **T**HHMMSS**Z** format (eg: "T000000Z", where "Z" indicates the UTC timezone, but it seems this superfluous detail is not required by Google Calendar.
20 |
--------------------------------------------------------------------------------