diff options
-rw-r--r-- | .md/about/faq.md | 21 | ||||
-rw-r--r-- | .md/about/whereami.md | 2 | ||||
-rw-r--r-- | .md/thoughts/net/the-web30-people-kinda-scare-me-a-little.md | 163 | ||||
-rw-r--r-- | .md/thoughts/society/as-a-conservatively-liberal-fascist-anarchist.md | 23 | ||||
-rw-r--r-- | .md/thoughts/syntax/my-worst-habit.md | 26 | ||||
-rw-r--r-- | .md/thoughts/syntax/random-python-idiosyncrasies.md | 35 | ||||
-rw-r--r-- | .md/tutorials/vim/.description | 1 | ||||
-rw-r--r-- | .md/tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.md | 53 | ||||
-rw-r--r-- | about/faq.html | 15 | ||||
-rw-r--r-- | thoughts/syntax/my-worst-habit.html | 53 | ||||
-rw-r--r-- | thoughts/syntax/random-python-idiosyncrasies.html | 140 | ||||
-rw-r--r-- | tutorials/vim/.description | 1 | ||||
-rw-r--r-- | tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.html | 106 |
13 files changed, 574 insertions, 65 deletions
diff --git a/.md/about/faq.md b/.md/about/faq.md index 36eddbc..87db7da 100644 --- a/.md/about/faq.md +++ b/.md/about/faq.md @@ -12,6 +12,21 @@ reconsider using the Internet all together. The hidden service has a benefit though, mostly to *you*. You don't need to expose your IP to me or to anyone else to access this site. +### *How come I can't access your main domain?* + +Honestly, I wouldn't know if my site is blocked elsewhere, but I may +have blocked your IP for the following reasons: + +- You attempted to ssh to my server (I use fail2ban and employ private + keys, I block all failed attempts) +- You tried to pass some weird or malicious HTTP request (again, + fail2ban) +- Someone else on your IP tried to do one of those things + +This is part of the reason why I run the site as hidden service since +you can still read my nonsense anyway through that, but if you think +this might be an error on my part, you can email me. + ### *You wrote all this in vim? Why tho?* Neovim more lately, but yeah other than large projects, I prefer using @@ -23,7 +38,7 @@ lately that I'm used to it. Honestly, I though the fish was cool. -<img src="/static/puffy.gif" /> +![puffy](/static/puffy.gif) I don't know the artist of that one unfortunately, I just found it on a forum. @@ -92,9 +107,9 @@ word that leads to a place, since the user doesn't have expectation of where it's going to lead, they'll tend to hover to see where it's going. A full URL looks like it's going exactly where it's going. A user won't think twice about clicking on -[https://facebook.com/](https://www.youtube.com/watch?v=dQw4w9WgXcQ). +[https://facebook.com/](https://fwesh.yonle.repl.co/). They will if they see -[totally not a virus](https://www.youtube.com/watch?v=dQw4w9WgXcQ). If +[totally not a virus](https://fwesh.yonle.repl.co/). If you're giving out the full URL anyway why bother linking it? Every browser in the world has double-click (or long-press) to highlight the URL automatically, then right-click, and open in new tab. diff --git a/.md/about/whereami.md b/.md/about/whereami.md index 2d72588..9cf4129 100644 --- a/.md/about/whereami.md +++ b/.md/about/whereami.md @@ -27,7 +27,7 @@ cables into and out of ports so calls could connect. <img src="/static/human_router.jpg" /> -*Image of a switchboard courtesy of +*Image of a switchboard courtesy of [Wikipedia contributors](https://en.wikipedia.org/wiki/File:Jersey_Telecom_switchboard_and_operator.jpg)* diff --git a/.md/thoughts/net/the-web30-people-kinda-scare-me-a-little.md b/.md/thoughts/net/the-web30-people-kinda-scare-me-a-little.md index e69de29..3424f96 100644 --- a/.md/thoughts/net/the-web30-people-kinda-scare-me-a-little.md +++ b/.md/thoughts/net/the-web30-people-kinda-scare-me-a-little.md @@ -0,0 +1,163 @@ +*Note: this article discusses web 3.0 in the context I originally +understood it, which I now understand was coined by [Gavin +Wood](https://en.wikipedia.org/wiki/Web3). I have no understanding of, +or interest in Tim Berners-Lee's concept of the +[Semantic Web](https://en.wikipedia.org/wiki/Semantic_Web)* + +## We are all Satoshi + +Satoshi Nakamoto committed the first block to a blockchain with: "The +Times 03/Jan/2009 Chancellor on brink of second bailout for banks." A +technology born in global financial crisis, known only among a group of +people who liked to call themselves the "cypherpunks, Bitcoin--and the +blockchain concept on which is was based--was a technology born from +political turmoil and couldn't be anything but a political statement. + +What was that statement exactly? + +If you read the Bitcoin white paper, and I highly recommend you do since +it's probably one of the best-written research papers in recent memory, +the impression you get is somewhere between utilitarianism and utopia. +Freedom and psuedonymity achieved through the mathematically perfect +organization of cryptography. + +Without trying to re-write the white paper, the core concept can be +described very simply. Say you have a network of random schmoes with +computers (some people call this the "Internet," but let's not get hung +up on jargon). You can organize these people into three main camps: +miners, nodes, and buyers. The nodes all keep a record of all +transactions ever made on the Bitcoin network. The miners, using +cryptography (and therefore CPU power), check these nodes to make sure +they're all accurate and up to date. The first miner that checks a full +set of transactions wins the Bitcoin. The people with the Bitcoin serve +kind of like a mint, distributing the currency to user's wallets in +exchange for pizza, illegal drugs, but most usually: cash. The buyers +ultimately provide the value of Bitcoin and make transactions with it +for the nodes to update, the miners to check and so on. + +The best part of all this, is that unlike traditional digital payment +like credit cards or Paypal: no corporation needs to do the bookeeping. +Instead, any volunteer with an internet connection can store and serve +their own copy of the book, the record of transactions Satoshi calls a +blockchain. The idea comes directly from torrenting, where anyone with +a link to the torrent can download a file from potentially thousands of +others who are also serving (or seeding) the file. + +There is a world that Bitcoin needs for all this to operate in a neat +way. Bitcoin demands a society of volunteers for it's book-keeping, a +gathering of self-starters for it's mining and maintenance (preferably +ones that don't track or scam people), and something like a national +myth--a belief that you have *something*, and that *something* has worth. + +But the world that's come out of it, seems far off from that ideal to +me. + +## We are the Web 3.0 people + +I imagine anyone reading this who happens to be part of crypto start up +is either seething with rage at how little detail I went into or is +completely unaware of any of that history. They also might snipe that +Bitcoin is irrelevant nowadays. Bitcoin is becoming something +of a "boomer" cryptocurrency now that some feel has seen better days in +spite of the booming price. But that's all it is--an imperfect software +hijacked into a get-rich-quick-scheme. Prophetically they hint that +something bigger is coming. + +If Web 1.0 was a littering of static content left by bored users and +Web 2.0 made the pictures move with your mouse to lull us all into +surveillance capitalism, Web 3.0, to it's proponents, is the light at +the end of the tunnel that will replace all those tyrannical centralized +software corps with user-owned and user-operated *de*centralized means +of communicating and commerce. To the libertarian: it's the end of the +Fed, the end of big government crony capitalism, and something like the +start of *Wealth of Nations*. To the marxist: it's the working class +owning entirely the means of commerce on the Internet organized +bureaucratically as open-source projects tend to become. + +Gavin Wood, the coiner of the term Web 3.0 as I understand it, had this +to say back in 2014: + +``` +WIRED: What's your handy elevator definition of Web3? + +“Less trust, more truth.” + +WIRED: What does “less trust” mean? + +I have a particular meaning of trust that’s essentially faith. It's the +belief that something will happen, that the world will work in a certain +way, without any real evidence or rational arguments as to why it will +do that. So we want less of that, and we want more truth--which what I +really mean is a greater reason to believe that our expectations will be +met. + +WIRED: It sounds like you're saying "less blind faith, more credible +trustworthiness." + +Yes and no. I think trust in itself is actually just a bad thing all +around. Trust implies that you are you're placing some sort of authority +in somebody else, or in some organization, and they will be able to use +this authority in some arbitrary way. As soon as it becomes credible +trust, it's not really trust anymore. There is a mechanism, a +rationale, an argument, a logical mechanism--whatever--but in my mind, +it's not trust. +``` + +On the surface there's no way this doesn't seem wonderful. There are few +people I imagine who would argue that blind-faith in authority is a good +thing. And to our inner anarchist: should *anyone* really rule over us +anyway. + +But I don't question the idealism of the Web 3.0 people, or that they +really believe they are making the world a freer more efficient place. +What I question is: does blockchain technology, as described by +Nakamoto and as expanded on by many others, actually achieve these +ends? And will the people at large, who ultimately are left the task to +run this Web 3.0 as volunteers, actually fall in line with the ideal the +software developers see so clearly expressed in code. + +## We do not forgive. We do not forget. + +### China's Social Credit System + +### The digital dollar + +### A data mining society + +Many of the Web 3.0 people would agree with the often quoted point +against social media companies: "we own our data so they should pay +us." The sentiment fits perfectly into the Web 3.0 agenda. Enter +steemit, a crypto-powered Twitter/Facebook like web front where you can +write articles, make articles, like other's work, and get paid for it +all! ... + +Brave is attempting a similar kind of project with their Basic Attention +Token (BAT), which rewards users of the browser for watching sponsored +ads. ... + +## We would like you to play + +At the core of the ideology of Web 3.0, I can't help but feel a strong +urge--particularly from software-minded people--to gamify society. Write +the article to get your coins. Read the book to gain XP. Gain XP to get +more visibility for your articles, and get even more coins. + +## We will all be Satoshi + +The identity of Satoshi Nakamoto, a name intentionally chosen since it +is parallel to the English "John Doe," is still unknown as of this +writing. But Wikipedia has a surprisingly complete set of references on +what we *do* know. + +... + +Most interesting to me is the case of Len Sassaman, which I caught in +earlier revisions of the article, but was removed due to lack of a +source. + +## Do we want this? + +## References + +1. https://www.wired.com/story/web3-gavin-wood-interview/ +2. https://en.wikipedia.org/wiki/Satoshi_Nakamoto#Possible_identities diff --git a/.md/thoughts/society/as-a-conservatively-liberal-fascist-anarchist.md b/.md/thoughts/society/as-a-conservatively-liberal-fascist-anarchist.md index 3749b95..0577aa6 100644 --- a/.md/thoughts/society/as-a-conservatively-liberal-fascist-anarchist.md +++ b/.md/thoughts/society/as-a-conservatively-liberal-fascist-anarchist.md @@ -15,4 +15,25 @@ ### Fascists Even worse the never-ending sects of sects of the modern left is -the empty category of fascism, which even Orwell in 195X bemoaned:
\ No newline at end of file +the empty category of fascism, which even Orwell in 195X bemoaned: + +## Synthesis + +I see no contradiction between these streams of thought as they all +operate within me in the following way: + +- I am a liberal as I believe in freedom of action of the individual, + and I see no reason to deny anyone their own happiness (or pleasure) + unless it harms it another. People are generally all capable all + things held equal and we should strive to assist the less capable and + less fortunate. +- I am a conservative since I see no reason to subvert or abandon most + of the social structures we've created over time: including family, + local community, and the sense of citizenship (to both nation and to + the world). Tradition and ritual has it's place in the world, even if + the ways we indulge in those past times change. +- I am an anarchist as I believe no one rules above me and there is no + need to preserve any social or government structure that cannot + justify itself. Without governing yourself, you can't talk about + governing the rest of the world. +- I am a fascist in diff --git a/.md/thoughts/syntax/my-worst-habit.md b/.md/thoughts/syntax/my-worst-habit.md index 2f760e1..ab89ddf 100644 --- a/.md/thoughts/syntax/my-worst-habit.md +++ b/.md/thoughts/syntax/my-worst-habit.md @@ -39,18 +39,26 @@ 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. +This is the only example I know that dares to put parentheses *and* a +long quote 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. A careful +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: +Burroughs, here's an example I regrettably wrote to a coworker +recently with some details removed: -... +``` +[...] As a precaution, I did review $NOBODY's recent +$THING_I_WAS_ASKED_TO_REVIEW (if you would like a detailed report on +that, I can pull that together for you). +``` + +Somehow, I managed to take the *one* point worth emphasizing (an entire +sentence at that!) and *de*-emphasized it. 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 index be3f1f8..22e9e25 100644 --- a/.md/thoughts/syntax/random-python-idiosyncrasies.md +++ b/.md/thoughts/syntax/random-python-idiosyncrasies.md @@ -1,16 +1,24 @@ # 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 + 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. +to automate. I like [black](https://pypi.org/project/black/) since it's +easy to use but there' plenty of advanced linters out there. + +I usually invoke it like this to turn off forcing double quotes and +force the line length to 72: + +```bash +black -S -l 72 file.py +``` That aside, I have the following idiosyncracies: @@ -21,7 +29,7 @@ why not? Like so: -```code +```python string = "This is a phrase" word = "word" cur_char = 'a' @@ -33,7 +41,7 @@ dictionary = { 'key' "1245dqw3w431", 'return': newline } The only exception is for strings with quotes in them (anything to avoid escapes, really) -```code +```python quoted_string = ( '"You miss 100% of the shots you don't take - Wayne Gretsky"' ' - Michael Scott' @@ -45,7 +53,8 @@ That brings me to my next point. ## 2) Long strings belong in parentheses As in: -```code + +```python 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" @@ -55,7 +64,7 @@ longboi = ( ) ``` -## 3) Tabs are four spaces and spaces are *ALWAYS* prefered to tabs +## 3) Tabs are four spaces and spaces are *ALWAYS* preferred to tabs Again, see PEP8. @@ -63,19 +72,19 @@ Again, see PEP8. It's a pain to read: -```code +```python 1/(2*sqrt(pi))*exp(x**2) ``` Do this -```code +```python 1 / (2 * sqrt(pi)) * exp(x ** 2) ``` The same goes for logic operators -```code +```python true & false ^ true ``` @@ -85,7 +94,7 @@ 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 +```python user_input = int(input()) # variable MAX_INPUT = 1000 # constant def judge_input(_input, _max): # function @@ -99,7 +108,7 @@ class Input_Judger: # a class Example exception: -```code +```python # this doesn't actually work, but you get the idea r = requests.get("www.debian.org") pageSize = r.json()['pageSize'] # camel case ok diff --git a/.md/tutorials/vim/.description b/.md/tutorials/vim/.description new file mode 100644 index 0000000..9a4526d --- /dev/null +++ b/.md/tutorials/vim/.description @@ -0,0 +1 @@ +Random little fixes I'e found for vim/neovim diff --git a/.md/tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.md b/.md/tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.md new file mode 100644 index 0000000..df0af33 --- /dev/null +++ b/.md/tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.md @@ -0,0 +1,53 @@ +I really like neovim since [COC](https://github.com/neoclide/coc.nvim) +is integrated with it to work nicely. Plus, I like the defaults and +the fact there's a lot of active development on extensions. I didn't +use it for a long time because I *needed* NerdTree but every time I'd +scroll the window, I'd get a mess. + +## The Problem + +![](/static/mess.gif) + +Now, yes, I know I'm a heretic for using the arrow keys and not just +jumping around, but I thought it was weird I didn't see this issue +anywhere else. Also, vim doesn't have this problem. + +![](/static/nomess-vim.gif) + +It's also not because of my meme tmux setup, the same issue happens in +terminator, which I happened to have installed. + +![](/static/mess-terminator.gif) + +## The Attempt + +There's a better way to do this, but I first figured just triggering +a redraw on scroll would do the trick. You can do so by adding the +following line to your init.vim file: + +```vimscript +au WinScrolled * redraw! +``` + +As it turns out, the "WinScrolled" event *only* exists in neovim, so +this command won't work in plain vim (see `:help autocmd-events` for the +list of events in each program). + +## The Actual Solution + +After installing COC and running a healthcheck, I realized that my +TERM variable was set to 'xterm'. I'm not sure if I did that +intentionally to run something or if it's just a legacy thing I left in +from Debian's default bashrc, but all I had to do was change it: + +```bash +export TERM='tmux256-color' +``` + +![](/static/fixed.gif) + +No more hacky autocommands! + +If I had the foresight to test the issue in xterm first, I probably +would have seen it right away.... + diff --git a/about/faq.html b/about/faq.html index d9803f7..87180cc 100644 --- a/about/faq.html +++ b/about/faq.html @@ -23,6 +23,7 @@ <li><a href="#questions-noone-asked-but-could-maybe">Questions noone asked, but could maybe</a> <ul> <li><a href="#why-bother-running-a-tor-hidden-service-if-youre-gonna-put-your-full-name-on-it"><em>Why bother running a Tor hidden service if you're gonna put your full name on it?</em></a></li> +<li><a href="#how-come-i-cant-access-your-main-domain"><em>How come I can't access your main domain?</em></a></li> <li><a href="#you-wrote-all-this-in-vim-why-tho"><em>You wrote all this in vim? Why tho?</em></a></li> <li><a href="#why-openbsd"><em>Why OpenBSD?</em></a></li> <li><a href="#why-bother-making-your-site-from-scratch-it-looks-like-crap"><em>Why bother making your site from scratch? It looks like crap</em></a></li> @@ -38,11 +39,21 @@ <h3 id="why-bother-running-a-tor-hidden-service-if-youre-gonna-put-your-full-name-on-it"><em>Why bother running a Tor hidden service if you're gonna put your full name on it?</em></h3> <p>One, because I think hidden services are neat and I thought it'd be neat to make one. And two, if I really needed to be anonymous, I would probably self-host or find a hosting provider somewhere else, or reconsider using the Internet all together.</p> <p>The hidden service has a benefit though, mostly to <em>you</em>. You don't need to expose your IP to me or to anyone else to access this site.</p> +<h3 id="how-come-i-cant-access-your-main-domain"><em>How come I can't access your main domain?</em></h3> +<p>Honestly, I wouldn't know if my site is blocked elsewhere, but I may have blocked your IP for the following reasons:</p> +<ul> +<li>You attempted to ssh to my server (I use fail2ban and employ private keys, I block all failed attempts)</li> +<li>You tried to pass some weird or malicious HTTP request (again, fail2ban)</li> +<li>Someone else on your IP tried to do one of those things</li> +</ul> +<p>This is part of the reason why I run the site as hidden service since you can still read my nonsense anyway through that, but if you think this might be an error on my part, you can email me.</p> <h3 id="you-wrote-all-this-in-vim-why-tho"><em>You wrote all this in vim? Why tho?</em></h3> <p>Neovim more lately, but yeah other than large projects, I prefer using vim for editing. Mostly because it's easy to edit consistently across servers and because I just spend so much of my time in the terminal lately that I'm used to it.</p> <h3 id="why-openbsd"><em>Why OpenBSD?</em></h3> <p>Honestly, I though the fish was cool.</p> -<p><img src="/static/puffy.gif" /></p> +<figure> +<img src="/static/puffy.gif" alt="" /><figcaption>puffy</figcaption> +</figure> <p>I don't know the artist of that one unfortunately, I just found it on a forum.</p> <p>Besides I've installed Debian lots of times so I figured, why not try something different? It's pretty cool as a server OS. Just a lot of homework. I'm sure it's good as a desktop/laptop one too, but it's not different enough for me to move all my data.</p> <p>For what it's worth, I use Debian sid for a daily driver.</p> @@ -56,6 +67,6 @@ <p>I get that people have to get paid. I get that people are afraid of someone else taking credit for their work. But for this site at least, I guess I just don't really care. If someone really finds some way to profit of some random guy's Linux tutorials and unqualified thoughts on the world I honestly think <em>they</em> deserve the credit not me. I have no idea how I'd do that; I'm not sure I'd even want to waste my time with all the marketing nonsense of the modern web. And on the second point, if someone "steals" my work it's not exactly hard to figure out it was published here first--a Google search will prove that. But even if that weren't the case, I still wouldn't mind. I'd be glad that this stuff is useful at all. That would be a nice surprise.</p> <p><em>Not</em> everything that is <em>linked</em> to on this site falls under the same guidelines, so be sure to respect that author's copyright; I tend to link stuff that is generally pretty free to use, though.</p> <h3 id="why-dont-you-highlight-urls-you-dinosaur">Why don't you highlight URLs you dinosaur?</h3> -<p>Because I think it's kinda deceiving. It's one thing to highlight a word that leads to a place, since the user doesn't have expectation of where it's going to lead, they'll tend to hover to see where it's going. A full URL looks like it's going exactly where it's going. A user won't think twice about clicking on <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">https://facebook.com/</a>. They will if they see <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">totally not a virus</a>. If you're giving out the full URL anyway why bother linking it? Every browser in the world has double-click (or long-press) to highlight the URL automatically, then right-click, and open in new tab.</p> +<p>Because I think it's kinda deceiving. It's one thing to highlight a word that leads to a place, since the user doesn't have expectation of where it's going to lead, they'll tend to hover to see where it's going. A full URL looks like it's going exactly where it's going. A user won't think twice about clicking on <a href="https://fwesh.yonle.repl.co/">https://facebook.com/</a>. They will if they see <a href="https://fwesh.yonle.repl.co/">totally not a virus</a>. If you're giving out the full URL anyway why bother linking it? Every browser in the world has double-click (or long-press) to highlight the URL automatically, then right-click, and open in new tab.</p> </body> </html> diff --git a/thoughts/syntax/my-worst-habit.html b/thoughts/syntax/my-worst-habit.html new file mode 100644 index 0000000..7d7698b --- /dev/null +++ b/thoughts/syntax/my-worst-habit.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>my-worst-habit</title> + <style> + code{white-space: pre-wrap;} + span.smallcaps{font-variant: small-caps;} + span.underline{text-decoration: underline;} + div.column{display: inline-block; vertical-align: top; width: 50%;} + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + ul.task-list{list-style: none;} + </style> +</head> +<body> +<p>Overuse of parentheses, by far.</p> +<p>Why is this a bad thing? Parentheses, as read by most readers, tend to contain additional <em>superfluous</em> 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.</p> +<p>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:</p> +<pre><code>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.")</code></pre> +<p>This is the only example I know that dares to put parentheses <em>and</em> a long quote within parentheses, unless we're counting math textbooks. In a way it works, since if information is ever <em>superfluous</em>, the history of sailors getting high on nutmeg fits that bill. A careful 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.</p> +<p>But just in case you think I'm just picking on William S. Burroughs, here's an example I regrettably wrote to a coworker recently with some details removed:</p> +<pre><code>[...] As a precaution, I did review $NOBODY's recent +$THING_I_WAS_ASKED_TO_REVIEW (if you would like a detailed report on +that, I can pull that together for you).</code></pre> +<p>Somehow, I managed to take the <em>one</em> point worth emphasizing (an entire sentence at that!) and <em>de</em>-emphasized it.</p> +<p>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.</p> +</body> +</html> diff --git a/thoughts/syntax/random-python-idiosyncrasies.html b/thoughts/syntax/random-python-idiosyncrasies.html index 80e4563..ba88071 100644 --- a/thoughts/syntax/random-python-idiosyncrasies.html +++ b/thoughts/syntax/random-python-idiosyncrasies.html @@ -12,6 +12,68 @@ div.column{display: inline-block; vertical-align: top; width: 50%;} div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} ul.task-list{list-style: none;} + pre > code.sourceCode { white-space: pre; position: relative; } + pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } + pre > code.sourceCode > span:empty { height: 1.2em; } + code.sourceCode > span { color: inherit; text-decoration: inherit; } + div.sourceCode { margin: 1em 0; } + pre.sourceCode { margin: 0; } + @media screen { + div.sourceCode { overflow: auto; } + } + @media print { + pre > code.sourceCode { white-space: pre-wrap; } + pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } + } + pre.numberSource code + { counter-reset: source-line 0; } + pre.numberSource code > span + { position: relative; left: -4em; counter-increment: source-line; } + pre.numberSource code > span > a:first-child::before + { content: counter(source-line); + position: relative; left: -1em; text-align: right; vertical-align: baseline; + border: none; display: inline-block; + -webkit-touch-callout: none; -webkit-user-select: none; + -khtml-user-select: none; -moz-user-select: none; + -ms-user-select: none; user-select: none; + padding: 0 4px; width: 4em; + color: #aaaaaa; + } + pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } + div.sourceCode + { } + @media screen { + pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } + } + code span.al { color: #ff0000; font-weight: bold; } /* Alert */ + code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ + code span.at { color: #7d9029; } /* Attribute */ + code span.bn { color: #40a070; } /* BaseN */ + code span.bu { } /* BuiltIn */ + code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ + code span.ch { color: #4070a0; } /* Char */ + code span.cn { color: #880000; } /* Constant */ + code span.co { color: #60a0b0; font-style: italic; } /* Comment */ + code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ + code span.do { color: #ba2121; font-style: italic; } /* Documentation */ + code span.dt { color: #902000; } /* DataType */ + code span.dv { color: #40a070; } /* DecVal */ + code span.er { color: #ff0000; font-weight: bold; } /* Error */ + code span.ex { } /* Extension */ + code span.fl { color: #40a070; } /* Float */ + code span.fu { color: #06287e; } /* Function */ + code span.im { } /* Import */ + code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ + code span.kw { color: #007020; font-weight: bold; } /* Keyword */ + code span.op { color: #666666; } /* Operator */ + code span.ot { color: #007020; } /* Other */ + code span.pp { color: #bc7a00; } /* Preprocessor */ + code span.sc { color: #4070a0; } /* SpecialChar */ + code span.ss { color: #bb6688; } /* SpecialString */ + code span.st { color: #4070a0; } /* String */ + code span.va { color: #19177c; } /* Variable */ + code span.vs { color: #4070a0; } /* VerbatimString */ + code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ </style> </head> <body> @@ -22,64 +84,70 @@ <ul> <li><a href="#strings-are-double-quoted.-keys-and-chars-are-single-quoted.">1) <em>Strings</em> are <em>double-quoted</em>. <em>Keys</em> and <em>chars</em> are <em>single-quoted</em>.</a></li> <li><a href="#long-strings-belong-in-parentheses">2) Long strings belong in parentheses</a></li> -<li><a href="#tabs-are-four-spaces-and-spaces-are-always-prefered-to-tabs">3) Tabs are four spaces and spaces are <em>ALWAYS</em> prefered to tabs</a></li> +<li><a href="#tabs-are-four-spaces-and-spaces-are-always-preferred-to-tabs">3) Tabs are four spaces and spaces are <em>ALWAYS</em> preferred to tabs</a></li> <li><a href="#always-add-spaces-between-arithmetic-but-never-for-brackets">4) Always add spaces between arithmetic, but never for brackets</a></li> <li><a href="#everything-should-be-snake_case">5) EVERYTHING should be snake_case</a></li> </ul></li> </ul> </nav> <h1 id="coding-style-guide">Coding Style Guide</h1> -<p>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 <em>I</em> adhere to my own style because I'm terribly inconsistent</p> +<p>The purpose of this document is twofold:</p> +<ol type="1"> +<li>To ensure that anyone who might like to make my code better understands why I write python the way I do</li> +<li>To ensure <em>I</em> adhere to my own style because I'm terribly inconsistent</li> +</ol> <p>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.</p> -<p><em>BUT</em> first and foremost, <em>code must comply with PEP8 first</em>. This is easy to automate. I like coala since it's friendly but there' plenty of advanced linters out there.</p> +<p><em>BUT</em> first and foremost, <em>code must comply with PEP8 first</em>. This is easy to automate. I like <a href="https://pypi.org/project/black/">black</a> since it's easy to use but there' plenty of advanced linters out there.</p> +<p>I usually invoke it like this to turn off forcing double quotes and force the line length to 72:</p> +<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="ex">black</span> -S -l 72 file.py</span></code></pre></div> <p>That aside, I have the following idiosyncracies:</p> <h2 id="strings-are-double-quoted.-keys-and-chars-are-single-quoted.">1) <em>Strings</em> are <em>double-quoted</em>. <em>Keys</em> and <em>chars</em> are <em>single-quoted</em>.</h2> <p>This is really just because I like how C does it. And Cpython's C-based so why not?</p> <p>Like so:</p> -<pre class="code"><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 }</code></pre> +<div class="sourceCode" id="cb2"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true"></a>string <span class="op">=</span> <span class="st">"This is a phrase"</span></span> +<span id="cb2-2"><a href="#cb2-2" aria-hidden="true"></a>word <span class="op">=</span> <span class="st">"word"</span></span> +<span id="cb2-3"><a href="#cb2-3" aria-hidden="true"></a>cur_char <span class="op">=</span> <span class="st">'a'</span></span> +<span id="cb2-4"><a href="#cb2-4" aria-hidden="true"></a>newline <span class="op">=</span> <span class="st">'</span><span class="ch">\n</span><span class="st">'</span> <span class="co"># note, two characters, but it's still ONE char out</span></span> +<span id="cb2-5"><a href="#cb2-5" aria-hidden="true"></a><span class="co"># keys are single-quoted to avoid confusion</span></span> +<span id="cb2-6"><a href="#cb2-6" aria-hidden="true"></a>dictionary <span class="op">=</span> { <span class="st">'key'</span> <span class="st">"1245dqw3w431"</span>, <span class="st">'return'</span>: newline }</span></code></pre></div> <p>The only exception is for strings with quotes in them (anything to avoid escapes, really)</p> -<pre class="code"><code>quoted_string = ( - '"You miss 100% of the shots you don't take - Wayne Gretsky"' - ' - Michael Scott' -)</code></pre> +<div class="sourceCode" id="cb3"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true"></a>quoted_string <span class="op">=</span> (</span> +<span id="cb3-2"><a href="#cb3-2" aria-hidden="true"></a> <span class="st">'"You miss 100</span><span class="sc">% o</span><span class="st">f the shots you don'</span>t take <span class="op">-</span> Wayne Gretsky<span class="st">"'</span></span> +<span id="cb3-3"><a href="#cb3-3" aria-hidden="true"></a><span class="st"> ' - Michael Scott'</span></span> +<span id="cb3-4"><a href="#cb3-4" aria-hidden="true"></a><span class="st">)</span></span></code></pre></div> <p>That brings me to my next point.</p> <h2 id="long-strings-belong-in-parentheses">2) Long strings belong in parentheses</h2> <p>As in:</p> -<pre class="code"><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." -)</code></pre> -<h2 id="tabs-are-four-spaces-and-spaces-are-always-prefered-to-tabs">3) Tabs are four spaces and spaces are <em>ALWAYS</em> prefered to tabs</h2> +<div class="sourceCode" id="cb4"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true"></a>longboi <span class="op">=</span> (</span> +<span id="cb4-2"><a href="#cb4-2" aria-hidden="true"></a> <span class="st">"This is a really long string usefull when making help menus. Be</span><span class="ch">\n</span><span class="st">"</span></span> +<span id="cb4-3"><a href="#cb4-3" aria-hidden="true"></a> <span class="st">"sure to leave s space at the end of each line, or add a new line</span><span class="ch">\n</span><span class="st">"</span></span> +<span id="cb4-4"><a href="#cb4-4" aria-hidden="true"></a> <span class="st">"when needed.</span><span class="ch">\n\n</span><span class="st">"</span></span> +<span id="cb4-5"><a href="#cb4-5" aria-hidden="true"></a></span> +<span id="cb4-6"><a href="#cb4-6" aria-hidden="true"></a> <span class="st">"Try your best to keep formatting accurate like this."</span></span> +<span id="cb4-7"><a href="#cb4-7" aria-hidden="true"></a>)</span></code></pre></div> +<h2 id="tabs-are-four-spaces-and-spaces-are-always-preferred-to-tabs">3) Tabs are four spaces and spaces are <em>ALWAYS</em> preferred to tabs</h2> <p>Again, see PEP8.</p> <h2 id="always-add-spaces-between-arithmetic-but-never-for-brackets">4) Always add spaces between arithmetic, but never for brackets</h2> <p>It's a pain to read:</p> -<pre class="code"><code>1/(2*sqrt(pi))*exp(x**2)</code></pre> +<div class="sourceCode" id="cb5"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true"></a><span class="dv">1</span><span class="op">/</span>(<span class="dv">2</span><span class="op">*</span>sqrt(pi))<span class="op">*</span>exp(x<span class="op">**</span><span class="dv">2</span>)</span></code></pre></div> <p>Do this</p> -<pre class="code"><code>1 / (2 * sqrt(pi)) * exp(x ** 2)</code></pre> +<div class="sourceCode" id="cb6"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true"></a><span class="dv">1</span> <span class="op">/</span> (<span class="dv">2</span> <span class="op">*</span> sqrt(pi)) <span class="op">*</span> exp(x <span class="op">**</span> <span class="dv">2</span>)</span></code></pre></div> <p>The same goes for logic operators</p> -<pre class="code"><code>true & false ^ true</code></pre> +<div class="sourceCode" id="cb7"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true"></a>true <span class="op">&</span> false <span class="op">^</span> true</span></code></pre></div> <h2 id="everything-should-be-snake_case">5) EVERYTHING should be snake_case</h2> <p>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.</p> -<pre class="code"><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</code></pre> +<div class="sourceCode" id="cb8"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true"></a>user_input <span class="op">=</span> <span class="bu">int</span>(<span class="bu">input</span>()) <span class="co"># variable</span></span> +<span id="cb8-2"><a href="#cb8-2" aria-hidden="true"></a>MAX_INPUT <span class="op">=</span> <span class="dv">1000</span> <span class="co"># constant</span></span> +<span id="cb8-3"><a href="#cb8-3" aria-hidden="true"></a><span class="kw">def</span> judge_input(_input, _max): <span class="co"># function</span></span> +<span id="cb8-4"><a href="#cb8-4" aria-hidden="true"></a> <span class="cf">if</span> _max <span class="op">></span> _input:</span> +<span id="cb8-5"><a href="#cb8-5" aria-hidden="true"></a> <span class="bu">print</span>(<span class="st">"Too big!"</span>)</span> +<span id="cb8-6"><a href="#cb8-6" aria-hidden="true"></a></span> +<span id="cb8-7"><a href="#cb8-7" aria-hidden="true"></a>judge_input(user_input, MAX_INPUT</span> +<span id="cb8-8"><a href="#cb8-8" aria-hidden="true"></a><span class="kw">class</span> Input_Judger: <span class="co"># a class</span></span> +<span id="cb8-9"><a href="#cb8-9" aria-hidden="true"></a> <span class="co"># etc etc</span></span></code></pre></div> <p>Example exception:</p> -<pre class="code"><code># this doesn't actually work, but you get the idea -r = requests.get("www.debian.org") -pageSize = r.json()['pageSize'] # camel case ok</code></pre> +<div class="sourceCode" id="cb9"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true"></a><span class="co"># this doesn't actually work, but you get the idea</span></span> +<span id="cb9-2"><a href="#cb9-2" aria-hidden="true"></a>r <span class="op">=</span> requests.get(<span class="st">"www.debian.org"</span>)</span> +<span id="cb9-3"><a href="#cb9-3" aria-hidden="true"></a>pageSize <span class="op">=</span> r.json()[<span class="st">'pageSize'</span>] <span class="co"># camel case ok</span></span></code></pre></div> </body> </html> diff --git a/tutorials/vim/.description b/tutorials/vim/.description new file mode 100644 index 0000000..9a4526d --- /dev/null +++ b/tutorials/vim/.description @@ -0,0 +1 @@ +Random little fixes I'e found for vim/neovim diff --git a/tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.html b/tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.html new file mode 100644 index 0000000..075d777 --- /dev/null +++ b/tutorials/vim/how-to-fix-neovim-nerdtree-rendering-issue.html @@ -0,0 +1,106 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> +<head> + <meta charset="utf-8" /> + <meta name="generator" content="pandoc" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> + <title>how-to-fix-neovim-nerdtree-rendering-issue</title> + <style> + code{white-space: pre-wrap;} + span.smallcaps{font-variant: small-caps;} + span.underline{text-decoration: underline;} + div.column{display: inline-block; vertical-align: top; width: 50%;} + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} + ul.task-list{list-style: none;} + pre > code.sourceCode { white-space: pre; position: relative; } + pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } + pre > code.sourceCode > span:empty { height: 1.2em; } + code.sourceCode > span { color: inherit; text-decoration: inherit; } + div.sourceCode { margin: 1em 0; } + pre.sourceCode { margin: 0; } + @media screen { + div.sourceCode { overflow: auto; } + } + @media print { + pre > code.sourceCode { white-space: pre-wrap; } + pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } + } + pre.numberSource code + { counter-reset: source-line 0; } + pre.numberSource code > span + { position: relative; left: -4em; counter-increment: source-line; } + pre.numberSource code > span > a:first-child::before + { content: counter(source-line); + position: relative; left: -1em; text-align: right; vertical-align: baseline; + border: none; display: inline-block; + -webkit-touch-callout: none; -webkit-user-select: none; + -khtml-user-select: none; -moz-user-select: none; + -ms-user-select: none; user-select: none; + padding: 0 4px; width: 4em; + color: #aaaaaa; + } + pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } + div.sourceCode + { } + @media screen { + pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } + } + code span.al { color: #ff0000; font-weight: bold; } /* Alert */ + code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ + code span.at { color: #7d9029; } /* Attribute */ + code span.bn { color: #40a070; } /* BaseN */ + code span.bu { } /* BuiltIn */ + code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ + code span.ch { color: #4070a0; } /* Char */ + code span.cn { color: #880000; } /* Constant */ + code span.co { color: #60a0b0; font-style: italic; } /* Comment */ + code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ + code span.do { color: #ba2121; font-style: italic; } /* Documentation */ + code span.dt { color: #902000; } /* DataType */ + code span.dv { color: #40a070; } /* DecVal */ + code span.er { color: #ff0000; font-weight: bold; } /* Error */ + code span.ex { } /* Extension */ + code span.fl { color: #40a070; } /* Float */ + code span.fu { color: #06287e; } /* Function */ + code span.im { } /* Import */ + code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ + code span.kw { color: #007020; font-weight: bold; } /* Keyword */ + code span.op { color: #666666; } /* Operator */ + code span.ot { color: #007020; } /* Other */ + code span.pp { color: #bc7a00; } /* Preprocessor */ + code span.sc { color: #4070a0; } /* SpecialChar */ + code span.ss { color: #bb6688; } /* SpecialString */ + code span.st { color: #4070a0; } /* String */ + code span.va { color: #19177c; } /* Variable */ + code span.vs { color: #4070a0; } /* VerbatimString */ + code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ + </style> +</head> +<body> +<nav id="TOC" role="doc-toc"> +<h2 id="toc-title">Contents</h2> +<ul> +<li><a href="#the-problem">The Problem</a></li> +<li><a href="#the-attempt">The Attempt</a></li> +<li><a href="#the-actual-solution">The Actual Solution</a></li> +</ul> +</nav> +<p>I really like neovim since <a href="https://github.com/neoclide/coc.nvim">COC</a> is integrated with it to work nicely. Plus, I like the defaults and the fact there's a lot of active development on extensions. I didn't use it for a long time because I <em>needed</em> NerdTree but every time I'd scroll the window, I'd get a mess.</p> +<h2 id="the-problem">The Problem</h2> +<p><img src="/static/mess.gif" /></p> +<p>Now, yes, I know I'm a heretic for using the arrow keys and not just jumping around, but I thought it was weird I didn't see this issue anywhere else. Also, vim doesn't have this problem.</p> +<p><img src="/static/nomess-vim.gif" /></p> +<p>It's also not because of my meme tmux setup, the same issue happens in terminator, which I happened to have installed.</p> +<p><img src="/static/mess-terminator.gif" /></p> +<h2 id="the-attempt">The Attempt</h2> +<p>There's a better way to do this, but I first figured just triggering a redraw on scroll would do the trick. You can do so by adding the following line to your init.vim file:</p> +<pre class="vimscript"><code>au WinScrolled * redraw!</code></pre> +<p>As it turns out, the "WinScrolled" event <em>only</em> exists in neovim, so this command won't work in plain vim (see <code>:help autocmd-events</code> for the list of events in each program).</p> +<h2 id="the-actual-solution">The Actual Solution</h2> +<p>After installing COC and running a healthcheck, I realized that my TERM variable was set to 'xterm'. I'm not sure if I did that intentionally to run something or if it's just a legacy thing I left in from Debian's default bashrc, but all I had to do was change it:</p> +<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true"></a><span class="bu">export</span> <span class="va">TERM=</span><span class="st">'tmux256-color'</span></span></code></pre></div> +<p><img src="/static/fixed.gif" /></p> +<p>No more hacky autocommands!</p> +<p>If I had the foresight to test the issue in xterm first, I probably would have seen it right away....</p> +</body> +</html> |