Menu

Back to the Basics: Crayon, wp-LaTex, and vimWiki

Before I forget, I should review some of the basics.

So, this is a blog, and having your own blog requires some maintenance. It’s like owning a house except the servers are hosted in Arizona, the domain name is registered in France, and I guess you’re not owning said house. You’re renting hardware space in someone else’s basement.. Note where your local and remote machines are. Okay, so I need to remember how to bash function. How to bash function? No, how about just a bash alias?

alias alias_name="commandToRun"

while we’re at it

alias maketotaldestroy='sudo halt -p'

but the alias needs to be remembered after reboots

cd ~/
ls -la
vim .bash_aliases

include in file, continue with life.

source ~/.bash_aliases

So with this, instead of memorizing a very long username + host domain I can access my blog with only a few magic words.

alias sshblog='ssh forgettableLongName@ridiculouslyLongRemoteHostName.net'

.. checkmate. I guess we could include the password as an argument but, no. So long as remote and host have authenticated each other before, this ought to be enough.

Now, without needing to activate FTP we can update and modify everything in the blog via command line. Will need WP-CLI. Fortunately the freebsd log files kept track of the commands I issued to it oh so many seasons ago, so simply pressing the up arrow key and holding it for a minute or two sent me to the keystrokes. the magic keywords are simply:

wp help
wp help core
wp core check-update
wp core update
wp core update-db
wp core verify-checksums

wp help plugin
wp plugin update --all
wp plugin uninstall akismet
wp plugin uninstall hello

remove/deactivated unneeded plugins which could become hazardous to your health. For more information these functions have been well documented at http://wp-cli.org/docs/ or simply refer to the man pages

How to syntax on wp?

since we’re going to be typing code here and there, a nice plug-in to have is:
https://wordpress.org/plugins/crayon-syntax-highlighter/

from here we can simply dl to our own machine or even use SSH from the remote machine to dl the file from a selected URL https://downloads.wordpress.org/plugin/crayon-syntax-highlighter.zip and then save it to the remote machine’s plugin directory, then..

via wp-cli
search for “crayon” to get a list of plugins already available through official channels

wp plugin search crayon
wp plugin install crayon-syntax-highlighter
wp plugin activate crayon-syntax-highlighter

So now we have pretty colors that support languages beyond what the regular vanilla wordpress supports. you could also git clone or wget + unzip from https://github.com/aramk/crayon-syntax-highlighter.git to get the same affect, but we’re already using wp-cli to run an update so might as do it from the remote host.

Next order of business: LaTeX.. how to LaTeX?

simply typing in:

$latex i\hbar\frac{\partial}{\partial t}\left|\Psi(t)\right>=H\left|\Psi(t)\right>$

should produce:

$latex i\hbar\frac{\partial}{\partial t}\left|\Psi(t)\right>=H\left|\Psi(t)\right> $

Unfortunately, I won’t get to see it until I preview it on the wordpress had it even worked to begin with. Apparently a viable plugin would need access to a latex server in order to generate some sort of image. It could be a .png and there’s even one that generates .svg vector images, but it pings to some guy’s web basement server and I’d rather not have my blog reliant on whether or not some random guy forgot to pay their electric bill. Of course, there’s always the option to self host a latex server on my own or a remote machine. A search for latex on the plugin menu yields several attempts at doing this.

While searching, I discovered an old .png generator for latex inputs. It seems to be not-so-old and the current method from which wordpress.com uses to render .png images. You can play around with the below URL.

https://s0.wp.com/latex.php?latex=i\hbar\frac{\partial}{\partial+t}\left|\Psi(t)\right>%3DH\left|\Psi(t)\right>\Psi(t hey type stuf in here and get a png)&bg=ffffff&fg=000&s=0

So, there’s a wordpress.org plug-in that utilizes a  similar, if not the exact same generator from wordpress.com. Note the distinction between the .com and .org service. It also has an option to generate from a self hosted server. Humm..

pro: less bandwidth
con: if access to wordpress.com goes down, image rendering capabilities go down with it. This will happen several times a year depending on who’s attacking the DNS.. but if the DNS is down this website will probably be inaccessible as well. Except in Australia. There’s a story to that.

To be reliant on external services.. Sure, to an extent.

wp plugin install wp-latex
wp plugin activate wp-latex

for more details: https://wordpress.org/plugins/wp-latex/faq/

how to vimwiki?

I’ve been reliant on gnote and random .txt files scattered around my drive to write down random things. A friend of mine recommended vimwiki, almost randomly like he had been reading my mind (or had shell access to my laptop).

vim remember.txt
remember to go through the ssh dot files and delete any weird pgp certs you don't recognize
:qw

The vimwiki is more of a plugin than anything, and should be easily installable through pathogen.

You can find the installation instructions here: https://github.com/tpope/vim-pathogen
and for vimwiki: https://vimwiki.github.io/

I shouldn’t need to go through writing the instructions here because the details are literally right there.

What I did need to figure out was that I was expected to make my own index.wiki file inside the ~/vimwiki/ folder. I was surprised when I could “enter” and “backspace” between files joined together by a link. #jawdrop.

:Vimwiki2HTML

creates a folder with a html transaction (along with a .css) of the page you’re on. It doesn’t follow through the nested links though. With maybe about a 100 functions on that help page, it’ll take a while to get acquainted with this program. I think it’s safe to say it has more functionality than what I had been previously using. I’ll play around with this for a few weeks and then decide if I’m better off with it.

What’s next? humm… I have less than 4 days to prep up on my Korean, toy around with some java, and I think they’ll be putting me in something about a “smarter cities” think group. I suspected it was related to the CES hackathon but that’s this weekend. I should probably go to that, but I need some ‘me’ time and me time includes prepping up on my Korean and toying around with some java. Also, my friend tells me I need to get more sunlight. I do.

[edit] Had been invited by some friends to join them at the CES hackathon this weekend, and despite making an attempt to print out my ticket, I just received an e-mail specifying that entrants needed to be registered for the CES portion by 7 days ago. This would be a separate registration process, and they’re only letting the first 450 people in. It’s fine. More ‘me’ time. Also,

convert -density 300 ticket.pdf -fill blue -opaque black ticketout.pdf

will attempt to change all your black pixels into blue ones in case your printer ran out of black ink. Sadly, I also just found out that we have a Kodak that refuses to print if it detects the black is low (or refuses to print black if it detects the color is low). Hardware should not be used like this against the consumer’s interest. Alternatively I could’ve gone to a UPS store or library that opens early to get something printed – mobile ticket barcodes ftw.

On a lighter note, I finally received the schedule for the Ajou workshop on Monday, so it looks like I’m slowly placing things on that to do list.

Test Post Please Ignore

To be honest, it would’ve been simpler had everyone used the same nomenclature, but I got to play around with all these different configurations.. It’s not like my time is worth anything – maybe it’s a French thing? Like, imagine if it’s just something you could put blame on a cultural thing. Their culture is different from ours, and our culture is somewhere hosted in Arizona – I’ve no clue what type of culture Arizonians have. Either way, despite being across an entire ocean; I’ve managed to assemble data from several sources to get this thing running. CNAME, zone file, unregistered proxy domain, mail exchange, etc. Now all we have to do is wait for DNS propagation. Time Till List – approximately 3 hours. Pretty standard.

Learning is slow, but it leads to something. It always has. I can’t put blame on culture, not as much as putting blame on me for not understanding it. There’s usually a missing context somewhere. My WORST experience overall was probably trying to figure out dynamixel specs from their source. Of course, it’s all there if you could speak/write Korean, but when an employee made the documentation your academic life depends on.. it’s frustrating. I mean, it certainly doesn’t help, yet it’s the only help you have. I’m sure the guy on the other side is 50 times smarter than I, but I just can’t understand him (or her). It’s a similar experience, except this time the ocean you have to cross is the other one (as opposed to the French one). #rant

Yet again, I feel validated in having gone with vim and acknowledging its superiority over emac. I spent the last several hours in someone else’s server (rented) making configs here and there, and just overall exploring. Rented doesn’t come with sudo access unfortunately, but a lot (most) of what I can do in a /home directory,  I can do over there. Time and over again, I’ve found myself in need of vim; and it’s proven to have been the better choice. Do you know how many times I’ve needed to use emac for anything? None.. zip.. 0 – as in “zero” times. I’ve needed to know vim for a broad range of applications.

Imagine being inside a multi-hundred-thousand dollar system just digging through code, all the way to fixing a twenty-something dollar raspberry pi. Vim is so light and you can pretty much expect it to be installed in any system you plan on using, especially if it’s old. If by chance it’s not on there, getting it on there isn’t difficult. My chrome netbook was the first time I really needed to use vim. This was maybe 2 or 3 years ago. My ubuntu installation crashed, and so I needed to find another way to get the laptop running again because let’s face it, a chromebook isn’t’ really a laptop. It could be, but the operating system leaves so much more to offer and I don’t particularly like the idea of being locked in anyone’s ecosystem for too long. But my efforts failed, and I found myself in the middle of a bad install with an unsigned BIOS I had chosen to replaced the standard chromebook one. The only way to do that was to short the leads underneath the the laptop so the write protection would turn off – a simple jumper. I felt proud, it being a small, but meaningful hardware hack; but I soon found myself staring at a terminal that wasn’t acting right.

At its bare minimum, my new boot loader had some software to help it get to through the rest of its installation. I was going to put ubuntu on it, because at the time that was pretty much the only linux distro I had any experience with. Among that short list of software in the boot-loader was vi. Not vim, just vi, and I knew what it was. In the past I had forfeited getting acquainted with it because who in their right mind would use such a primitive text editor when you have all these other O-M-G-EYE-CANDY alternatives with so many other useful features? Why would any sane person torture themselves with this nonsense keyboard layout? But there I was, staring at a terminal and I had no other choice but to figure it out. So vi it was.

Fast forward a year or two, and vim’s my favorite editor. It wasn’t until, about 8 months ago that I REALLY began to appreciate it, and even more so this past summer.  Back in January, I was sitting next to a professor watching the guy do kongfu coding on that aforementioned multi-hundred-thousand dollar system. I remember asking him why, and it didn’t make too much sense back then, mostly because I wasn’t the one doing it. Regardless of what you’re working on, it really comes down to the fact that you’re probably working on a terminal. Furthermore, that terminal, probably isn’t on your computer. It’s somewhere else, on an entirely different platform or maybe on an entirely different planet (or not a planet, maybe it’s traveling beyond the now detittled Pluto, and the only way to interface with it is to recompile a Fortran oracle by which the only means to edit is through..). On top of that, you’re probably connected to four different platforms at the same time. Some of these computers might be running sub-controllers, and somehow you’re beyond seven layers away. The good news is, you can control all of them; and instantly reprogram and reedit them while they’re running, (even literally as they’re running/or flying), through vim.

PuTTY was my first real linux experience, granted that was through a windows XP and 3 laptops ago. As a freshman in mechE, we had an amazing professor who made us use it, but this wasn’t something that was drilled into typical mechE students. There’s a real lack of computer programming experience brought into us by the intuition we pay tuition to. There was hardly any back in high school and I wonder how the education system has changed since. So, any of this, is something students will have to learn on their own (or they could quad-major in everything). The other day was my first time being inside of a BSD system – a unix system. I’m a senior, so maybe there’s something poetic to be said about this? So yeah, vim. Not because of the plug-ins or its advanced features, but because there’s beauty in simplicity. It somehow became simple. Also because of the terminal thing. That and I love my color syntax. It’s awesome.Oh, and I’m also on awesomewm. Seven years ago, I wouldn’t have dreamed of being able to write code like this. Seven months ago, I could hardly believe I was controlling platforms like this. It always felt surreal, like I didn’t belong here; and it still does at times. Seven layers ago, I was somebody completely different.

Let’s recheck that propagation
*hits*F5