UNIX Diary - Psychology, Philosophy, and Licenses
dear unix diary,
today i learned about pandoc, a tool that's used to convert between markup formats. armed with this new tool i made a simple shell command that converts markdown files to man page format then pipe them into a pager. so essentially this mdcat command makes markdown files act like man pages :D

# read markdown files like manpages
mdcat() {
    grep -v "\-\-\-\-\-" "$*" | pandoc -s -f markdown -t man | groff -T utf8 -man | less
Dear UNIX diary,

Sunny with a chance of meatballs.

OpenBSD-san is awesome. CRUX-san is awesome. I don't like systemd-san, though I'm not sure why.

OpenBSD-san is mean to me and won't turn on the screen after a suspend/resume, and I am sad that my uptime is always low because of that.

Ethernet cable-kun is strange. He needs to be in a comfortable position at an angle or otherwise he doesn't want to work.
Eduan / greduan
@xero Awesome idea, very unixy. You inspired me to go looking for a markdown man page viewer and I found this:

* https://github.com/tj/mad

* PS: A big problem with pandoc for me is that its a bit of dependency hell if your not into haskell. I found [mkd2pdf](https://aur.archlinux.org/packages/mkd2pdf/) its not bad as a simpler program.

* Have a good one :)
blog: c-jm.github.io
twitter: https://www.twitter.com/_c_jm
My ambition in life is to be a graybeard by the time I am 65.
There is also ronn which can create manpages directly from markdown. Never tried it though
Dear unix diary,

Today I wrote a simple neat script. I really like discovering music on youtube by the 'up next' autoplaylist thing that youtube has going on - if I find a song I like that I am not familiar with, it is nice to get others like it! So, to feed my data hoarding, I wrote a script that takes in a youtube url, then grabs the 'up next' suggestion. And then the next one. and the next one after that. You get the idea - anyways, after all the urls are accounted for by a loop, I have youtube-dl download the audio to my music folder. I threw it into a gist as well: https://gist.github.com/neeasade/24822fe4ac96edb39187
Pretty cool! It could be nice to use it as a "background music playlist" when you get people at home.
Dear UNIX diary,

I wish the writers of *nix documentation had cracked open the elements of style.

What should have been a painless install of gentoo turned sour when my exotic wireless card and the messy sporadic notes that are the gentoo wiki ganged up on me.

I tried to flee back to the safety of debian to nurse my wounds only to find that I had accidentally deleted the partition. My afternoon turned into an epic hunt for my CD case. Which my brother had hidden after I continued leaving Linux live CDs in his computer to try and woo him to the freedom: he was not amused.

I found it behind a pile of clothes on the washer and popped the CD back in.
It is with a heavy heart that I type this out. For I must remake my entire setup, again.

While I was setting up my window manager I spotted a few dinosaurs in the repositories. Only in debian.
(Houseoftea, you have my sympathies.)

Dear UNIX diary,

I recently added "\a" to my $PS1. This way, I automatically get notified when a long running task has finished. I wonder if this is going to helpful or annoying.
Dear Unix diary,

Today I discovered a neat trick involving /proc
Some user complained AGAIN that their development server was full. Indeed, they have a component whose logs are set in "DEBUG" mode, which makes it fill the available space rather quickly (and they don't want to do anything about it, because they're lazy asses!).
So as usual, I log onto the machine, perform the traditionnal "df -h" semi-automatically, and then navigate to the log directory that I know is guilty. But this time, I was surprised:

# cd /opt/app-data/guilty/var/log
# du -sh *opt/app-data/guilty/var/log
5.1M    APP_20150720.log
72K     APP_20150721.log
72K     APP_20150722.log
72K     APP_20150723.log
237M    APP_20150724.log
0       APP_20150725.log
0       APP_20150726.log
17K     APP_20150727.log

Ah, so there might be another guilty app! which one is it?

# du -sh /opt/app-data/*
500M    app01
123M    app02
17M     app03
400M    guilty

# du -sh /
7.6G    /

WTF? Then I got enlightenned... Someone deleted a huge ass file, while it was still openned!
Dammit, I already told them not to play heroes on the box, and call me instead...
After some research and the help of our good IRC members (props to SOMEONE[1] for finding the link).

This stackoverflow post advise to use "lsof" to find the openned. I already though about it, but lsof was not installed on the box, and the disk being full didn't allow me to install it. So I had to go with another option.
Hopefully, another answer on the page suggested an alternative, which I tried immediately:

# find /proc/*/fd -ls | grep  '(deleted)'
35225653    0 lrwx------   1 appuser users          64 Jul 27 18:56 /proc/3568/fd/1 -> /dev/pts/0\ (deleted)
35225657    0 lrwx------   1 appuser users          64 Jul 27 18:56 /proc/3632/fd/2 -> /dev/pts/0\ (deleted)

I found them! I told them that restarting their component would free the space, but being too busy "coding", they couldn't afford a reboot. So I just temporarily emptied the file descriptors by hand ("> /proc/3568/fd/1" , and let them go with it.
# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       73G   6.7G 66.3G 9%  /

Hooray! Unix will always impress me!

[1] ymbx doesn't deserves the honor of being cited. Die alone man.
Dear Unix diary,

Today I scratched an itch I had for a long time, using chmod.

I've always been irritated by the fact I had to change file/directories ownership of my web root everytime I wanted to share a file, or publish a git repository. I had to let my current user own the said directories, create the files, then "chgrp -R http ." so the HTTP daemon could read it. Easy to automate, but really hackish.

This time is over.

I just discovered the 's' flag for directories. If you run

mkdir /var/www
chgrp http /var/www
chmod g+s /var/www

Then every file or directory created under /var/www will inherit it's parent group, meaning every file will be readable by group "http" if you have your umask set accordingly. It's time for a new era!

PS: sadly, I couldn't find a way to assign a umask to a group. It does not seem to be possible.

Members  |  Stats  |  Night Mode