RSync + Pelican: A Short Note About Permissions

Yesterday I spent most of my time dabbling in Pelican’s configuration file. Right now how is set is pretty simple. I just rsync the data to the server, and back up the project on a weekly basis to my personal account in BitBucket. There’s a catch on this, any tool using rsync will upload the data as the user you are uploading it as. This doesn’t sound as a problem at all if you are using a shared hosting! However, I use a VPS from DigitalOcean, so it sort of changes quite a bit.

I’ll be frank, before explaining my solution which is just a simple line. I haven’t configured my nginx completely, and if there’s another way to do this it’s lost on me. Feel free to contact me, my e-mail is in the About Me page!

What I did was simple, edit your Pelican generated Makefile and add this line in the rsync_upload action:

rsync_upload: publish
rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
ssh $(SSH_USER)@$(SSH_HOST) "chown -R www-data:www-data $(SSH_TARGET_DIR)"

That’s all you really need to solve the permission problems. There’s another way which is adding rsync to sudoers, but doing so introduces a security risk. The alteration made my way simply re-uses the variables that were previously declared. Once rsync finishes syncing the files, it will make open up ssh and chown the folder.

That’s all, and if you are using vim. Type :make rsync_upload (you must have your virtualenv enabled if you didn’t install it system wide). 🙂

Vim: My Experience as a New User

Many of you have heard of Vim, a lot of people call it the greatest text
editor ever “second to none”. While that claim seems like a bit of a mouthful
and purely driven by the fans there are reasons why Vim is great, as well as
there are reasons for you not to use it.

I started learning Vim this week. Let’s make this clear, Vim is not an IDE,
you can make it look like an IDE but it won’t behave like one. As I searched
through the web for plugins to empower my Vim editor I noticed one thing:
Everyone wants Vim to be an IDE. Oh, the many out there. I don’t mind
them, but it puzzled me as a new user.

Don’t get me wrong, I love Vim. I love all the amazing text editing keymaps
you can do with it. I love how you can use Visual Block and replace whatever
text with the same name in just a matter of 2-3 keys. I love how you can just
ci” and magically delete. I love plugins like YouCompleteMe, how well
NERDTree works even though I’m looking at something like Sauce but bookmarks
do just fine, how AMAZING is python-mode, tagbar is a must, vim-airline, and
oh so many plugins out there that even in 2014 it maintains Vim relevant.

Vim is an investment. As a new user it took me a couple of days to fully get
it to where I wanted it. Just like Emacs if you want to be its user, then
you’ll know that you need to install plenty of plugins for it too.

But see, Vim is a great tool. Let me show you the first screenshot:

My .vimrc is a mess so I’m not going to post it here today but let’s take a
look at semantic completion provided by YouCompleteMe, it also uses omni-
completion. This is just one of my random projects.

Here is a more IDE-like screenshot that shows you tagbar.

It looks great, doesn’t it? As a new user I should have waited a bit before
getting into plugins but at the same time I wanted to do some C++ already. My
reason to choose Vim was because Eclipse just keep crashing over and over
again and it also froze several times. Netbeans didn’t even want to work.

So, I chose Vim because it was THE text editor I needed. The world whispered
in my ears and said “Use vim, use vim! You won’t regret it!” I don’t regret
it. I like it, I haven’t worked on a REAL project with it but I know that
it’ll be a delight to work with.

Now, all my praises for it so far ends here. Let’s go on to why you might not
want to deal with vim.

  • Setting up a project with virtualenv and YouCompleteMe is a pain. No matter how you look at it, you don’t get a predefined workspace like you do in Eclipse or Netbeans. There’s no ROOT PROJECT folder to use. It causes YCM not look up the libraries set with virtualenv. And it’s just awkward hard to make it work. Since YCM looks at your system libraries, what I did was just install the framework I wanted to use to get the semantic support. It’s sad.
  • ctags? Manual generation of something that should be automated? Well, yea it’s like that. Apparently you gotta freshen up your ctags if you want to navigate your source files.
  • No way to jump around headers/sources file. I can’t for the life of me find a way to JUMP at the standard header I just included. In Emacs, this is done oh so easily, it makes me sad.
  • It takes time to deal with buffers/windows/tabs. If you are new like me, chances you are going to be nuts jumping from buffer to buffer, or tab to tab.

Listen, if I were to choose between PyCharm and vim, my answer would be
PyCharm. It removes a lot of the hassle that is introduced by vim. But see,
vim is a text editor and such it cannot be blamed for not working as one.

So where’s the investment exactly? Text editing. No, really. Once you learn
the flow of vim you will be fast to get that source written. At first, you
will feel slow, frustrated because the workflow is really different. I know I
have. Heck, I have started typing while it was in Normal Mode and I’ve screwed
up plenty of files due to that. It happens because we are just new to vim.

Is it worth the pain? That’s for you to choose. I’m sticking with it for a
while because it doesn’t hurt.