summaryrefslogtreecommitdiffstats
path: root/.md/thoughts/syntax
diff options
context:
space:
mode:
authormjfernez <mjf@mjfer.net>2021-12-22 16:40:46 -0500
committermjfernez <mjf@mjfer.net>2021-12-22 16:40:46 -0500
commitd0595724cd13a2274e34a813119cf457a796af75 (patch)
tree90a3b6d44ff929c47f05b354a5f682f6df6e30f1 /.md/thoughts/syntax
parent3e87511c9ded4663150d6c4c4a1d829b53a16ed4 (diff)
downloadsite-files-d0595724cd13a2274e34a813119cf457a796af75.tar.gz
Table of Contents! Adds some works in progress
This commit adds a table of contents generated in the panupdate script. It also changes some links on the homepage to conform with removing '/site' as the parent directory
Diffstat (limited to '.md/thoughts/syntax')
-rw-r--r--.md/thoughts/syntax/.description1
-rw-r--r--.md/thoughts/syntax/my-worst-habit.md56
-rw-r--r--.md/thoughts/syntax/random-python-idiosyncrasies.md107
3 files changed, 164 insertions, 0 deletions
diff --git a/.md/thoughts/syntax/.description b/.md/thoughts/syntax/.description
new file mode 100644
index 0000000..425358c
--- /dev/null
+++ b/.md/thoughts/syntax/.description
@@ -0,0 +1 @@
+Language on languages
diff --git a/.md/thoughts/syntax/my-worst-habit.md b/.md/thoughts/syntax/my-worst-habit.md
new file mode 100644
index 0000000..2f760e1
--- /dev/null
+++ b/.md/thoughts/syntax/my-worst-habit.md
@@ -0,0 +1,56 @@
+Overuse of parentheses, by far.
+
+Why is this a bad thing? Parentheses, as read by most readers, tend to
+contain additional *superfluous* information when read. So naturally,
+the mind tends to pay less attention to what's inside (or at least my
+mind does). I also believe it represents some repressed psychological
+trauma, since a Professor once circled how many times I abused the
+double dash, "--", and I haven't quite felt comfortable using it
+since--unless it feels right.
+
+The punctuation works in that last example, but relying on it leads to
+bad habits, and usually, sentences that droll on for far longer than
+welcome. Consider the following example from Naked Lunch:
+
+```
+Doc Browbeck was party inna second part. A retired abortionist and junk
+pusher (he was a veterinarian actually) recalled to service during the
+manpower shortage. Well, Doc had been in the hospital kitchen all
+morning goosing the nurses and tanking up on coal gas and Klim -- and
+just before the operation he sneaked a double shot of nutmeg to nerve
+himself up.
+
+(In England and especially in Edinburgh the citizens bubble coal gas
+through Klim -- a horrible form of powdered milk tasting like rancid
+chalk -- and pick up on the results. They hock everything to pay the
+gas bill, and when the man comes around to shut it off for the
+non-payment, you can hear their screams for miles. When a citizen is
+sick from needing it he says "I got the klinks" or "That old stove
+climbing up my back."
+
+Nutmeg. I quote from the author's article on narcotic drugs in the
+British Journal of Addiction (see Appendix): "Convicts and sailors
+sometimes have recourse to nutmeg. About a tablespoon is swallowed
+with water. Result vaguely similar to marijuana with side effects of
+headache and nausea. There are a number of narcotics of the nutmeg
+family in use among the Indians of South America. They are usually
+administered by sniffing a dried powder of the plant. The medicine
+men take these noxious substances and go into convulsive states. Their
+twitchings and mutterings are thought to have prophetic significance.")
+```
+
+This is the only example I know that dares to put parentheses within
+parentheses, unless we're counting math textbooks. In a way it works,
+since if information is ever *superfluous*, the history of sailors
+getting high on nutmeg fits that bill. An academic reader might easily
+pick up on that, but to everyone else, I think a full paragraph of text
+in parentheses signals the reader to scroll down in the hopes that the
+story continues.
+
+But just in case you think I'm just picking on William S.
+Burroughs, here's an example I regrettably wrote to a ... recently:
+
+...
+
+It's a habit I can't break. So please, if you are a caring reader, do
+complain when I overuse parentheses. I deserve it.
diff --git a/.md/thoughts/syntax/random-python-idiosyncrasies.md b/.md/thoughts/syntax/random-python-idiosyncrasies.md
new file mode 100644
index 0000000..be3f1f8
--- /dev/null
+++ b/.md/thoughts/syntax/random-python-idiosyncrasies.md
@@ -0,0 +1,107 @@
+# Coding Style Guide
+
+The purpose of this document is twofold:
+1) To ensure that anyone who might like to make my code better understands
+ why I write python the way I do
+2) to ensure *I* adhere to my own style because I'm terribly inconsistent
+
+Being terribly inconsistent, the guidelines are not set in stone and if
+you have a good argument for doing things a particular, I don't really care.
+
+*BUT* first and foremost, *code must comply with PEP8 first*. This is easy
+to automate. I like coala since it's friendly but there' plenty of advanced
+linters out there.
+
+That aside, I have the following idiosyncracies:
+
+## 1) *Strings* are *double-quoted*. *Keys* and *chars* are *single-quoted*.
+
+This is really just because I like how C does it. And Cpython's C-based so
+why not?
+
+Like so:
+
+```code
+string = "This is a phrase"
+word = "word"
+cur_char = 'a'
+newline = '\n' # note, two characters, but it's still ONE char out
+# keys are single-quoted to avoid confusion
+dictionary = { 'key' "1245dqw3w431", 'return': newline }
+```
+
+The only exception is for strings with quotes in them (anything to avoid
+escapes, really)
+
+```code
+quoted_string = (
+ '"You miss 100% of the shots you don't take - Wayne Gretsky"'
+ ' - Michael Scott'
+)
+```
+
+That brings me to my next point.
+
+## 2) Long strings belong in parentheses
+
+As in:
+```code
+longboi = (
+ "This is a really long string usefull when making help menus. Be\n"
+ "sure to leave s space at the end of each line, or add a new line\n"
+ "when needed.\n\n"
+
+ "Try your best to keep formatting accurate like this."
+)
+```
+
+## 3) Tabs are four spaces and spaces are *ALWAYS* prefered to tabs
+
+Again, see PEP8.
+
+## 4) Always add spaces between arithmetic, but never for brackets
+
+It's a pain to read:
+
+```code
+1/(2*sqrt(pi))*exp(x**2)
+```
+
+Do this
+
+```code
+1 / (2 * sqrt(pi)) * exp(x ** 2)
+```
+
+The same goes for logic operators
+
+```code
+true & false ^ true
+```
+
+## 5) EVERYTHING should be snake_case
+
+This is python. Unless there's a compatibility thing (like a library's
+code was written that way, or it matches an API variable), snake_case
+is preferred.
+
+```code
+user_input = int(input()) # variable
+MAX_INPUT = 1000 # constant
+def judge_input(_input, _max): # function
+ if _max > _input:
+ print("Too big!")
+
+judge_input(user_input, MAX_INPUT
+class Input_Judger: # a class
+ # etc etc
+```
+
+Example exception:
+
+```code
+# this doesn't actually work, but you get the idea
+r = requests.get("www.debian.org")
+pageSize = r.json()['pageSize'] # camel case ok
+```
+