Backstory

I really wanted to have the filename of the file I was editing to be a different color than the path of the file. Using statusline without any tricks would only provide just the filename or the full path with filename.

Solution

bufname and fnamemodify to the rescue!

Using bufname with '%' as an argument: bufname('%') will return the filename of file currently in the buffer.

Using fnamemodify with the above and the ':p:h' as escape codes will give you the entire path of the passed file and then cut off the filename.

All together it looks like: fnamemodify(bufname('%'), ':p:h')

My full statusline (with helpful comments)

[code lang=text]
" put paste info
set statusline=%#error#%{SL('HasPaste')}%*
" set color to 'search'
set statusline+=%#todo#
" if a help file or not
set statusline+=%h
" if modified or not
set statusline+=%m
" set color to 'error'
set statusline+=%#error#
" read-only or not
set statusline+=%r
" reset color
set statusline+=%*
" FILETYPE (COMMENTED OUT FOR NOW)
"set statusline+=%y\
" column number
set statusline+=\ %c,
" line/total lines
set statusline+=%l/%L
" percent of file
set statusline+=\ %P
" Move to the right align
set statusline+=%=
" put up to 50 characters of filename and path
set statusline+=\ %30.30{fnamemodify(bufname('%'),':p:h')}/
set statusline+=%#statusbold#
set statusline+=%t
" space at end to make it easier to read
set statusline+=\
[/code]

Some other tips:

To add a space you need to use: \_ where _ is actually a space.
You can define your own highlight names (seen above with #statusbold#) with:

[code lang=text]
highlight statusbold term=bold,reverse ctermfg=5 ctermbg=118 gui=bold,reverse
[/code]

We’ll be using a Ubuntu 14.10 image. The size/flavor you choose depends on the amount of players that you want to support.

Synopsis

  • Make instance
  • Install stuff and run Minecraft in tmux

Process of Making a Rackspace Instance

[code lang=text]
<wip>
[/code]

Installing the Base Packages

[code lang=text]
# update all of our package lists
sudo apt-get update

# install utilities and java
# if openjdk-7-jre is not available use openjdk-6-jre
sudo apt-get -y install unzip python-software-properties \
openjdk-7-jre tmux

# create a user to run the server as and become them
sudo adduser minecraft
sudo su minecraft
cd ~

# get the config files for the server to work
cd /usr/local
sudo wget http://mcmyadmin.com/Downloads/etc.zip
sudo unzip etc.zip

# download mcmyadmin and unzip
wget http://mcmyadmin.com/Downloads/MCMA2_glibc25.zip
unzip MCMA2_glibc25.zip && rm MCMA2_glibc25.zip

# create our working directory
mkdir mcmyadmin
mv MCMA2_Linux_x86_64 mcmyadmin

# run the script with the admin password
# this will put you into blue(maybe) screen saying to
# complete setup with the web interface
./MCMA2_Linux_x86_64 -setpass A_Password_For_You

# You should now be able to log on to the web interface
# which is at http://YOUR_IP:8080
# I recommend setting your License if you have a McMyAdmin key
# You can find the License portion in About > Updates

# When done stop McMyAdmin by typing in the blue interface
/quit

# Then start it again and go to website to accept EULA
./MCMA2_Linux_x86_64

# Your new Minecraft server and world will be up now
[/code]

If you want to import a world

[code lang=text]
# Stop the server from interface using /quit
# These instructions are from some other linux server to this one
# (this might take awhile, my world was 750 MB)
scp world_backup.tar minecraft@YOUR_IP:~

# remove the existing world
rm mcmyadmin/Minecraft/world -rf

# untar and mv the world folder into the Minecraft folder
tar -xvf world_backup.tar
mv world mcmyadmin/Minecraft/

[/code]

Running the Server in Tmux

[code lang=text]
# As the minecraft user:
tmux
cd ~/mcmyadmin
./MCMA2_Linux_x86_64
[/code]

This is apparently a pretty common thing to do but I was unaware. It’s pretty simple once you know about it and I’m just blogging about it to remember:

[code lang=”text”]
# SSH into the machine with the -A argument:

$ ssh -A user@host -p 314

# Once on the machine if you need to use sudo
# use the -E argument to save the environment:

$ sudo -E su
[/code]

Some concerns are that a clever person on the machine can use your credentials to do nefarious things.

This is useful for allowing you to use your ssh-keys (such as github, or SSHing into other machines using a key) from your local machine on remote machines.

You will need to ensure that your ssh config ~/.ssh/config contains (I put mine at the top) ForwardAgent yes for this to work.

Cheers

(Update) The Real Problem and Solution

While creating the fork of the python-neutronclient we ran into this problem again. We found that it was simply that the version.py that was being used was looking for the wrong client. It was a problem with the distribution and not the installation.

I made a post about it.

If you run into this problem this may not be a solution anymore!

Old Solution

I was having a problem with an application I just uploaded to pypi. After I pip installed it to my system I got this error when I ran it:

[code lang=”text”]
$ neutron –version
Traceback (most recent call last):
File &quot;/usr/local/bin/neutron&quot;, line 6, in &lt;module&gt;
from neutronclient.shell import main
File &quot;/usr/local/lib/python2.7/dist-packages/neutronclient/shell.py&quot;, line 73, in &lt;module&gt;
from neutronclient.version import __version__
File &quot;/usr/local/lib/python2.7/dist-packages/neutronclient/version.py&quot;, line 22, in &lt;module&gt;
__version__ = pbr.version.VersionInfo('python-neutronclient').version_string()
File &quot;/usr/local/lib/python2.7/dist-packages/pbr/version.py&quot;, line 78, in version_string
for part in self.release_string().split('.'):
File &quot;/usr/local/lib/python2.7/dist-packages/pbr/version.py&quot;, line 70, in release_string
self.release = self._get_version_from_pkg_resources()
File &quot;/usr/local/lib/python2.7/dist-packages/pbr/version.py&quot;, line 62, in _get_version_from_pkg_resources
return packaging.get_version(self.package)
File &quot;/usr/local/lib/python2.7/dist-packages/pbr/packaging.py&quot;, line 870, in get_version
raise Exception(&quot;Versioning for this project requires either an sdist&quot;
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?
[/code]

It was a weird error and I quickly learned that it was because pbr expects the git tag to have a v in it. Such as v2.3.7. I provided 2.3.7 and that is what caused the bug.

I simply made a new tag (git tag -a v.2.3.7 -m "yey version") and uploaded to pypi (python setup.py sdist upload -r pypi).
Problem with pbr and “sdist tarball”

You need some machine (vm or instance) that has at least 4GB of RAM. 8GB is much better. I will assume you just booted a machine and have root, and nothing else.

Installing Devstack

  • I prefer to make an account (my own) and run devstack as that account (some say to make a stack account, it’s the same thing)
  • adduser herpderp &amp;&amp; adduser herpderp sudo &amp;&amp; apt-get update &amp;&amp; apt-get install git &amp;&amp; exit
  • Log back into the machine as your user; herpderp in this case
  • git clone https://github.com/openstack-dev/devstack.git
  • cd devstack
  • create a new file called localrc with the contents:

[code lang=text]
# Originally from http://www.sebastien-han.fr/blog/2013/08/08/devstack-in-1-minute/
# Misc
DATABASE_PASSWORD=password
ADMIN_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=password
RABBIT_PASSWORD=password

# Enable Logging

LOGFILE=/opt/stack/logs/stack.sh.log
VERBOSE=True
LOG_COLOR=True
SCREEN_LOGDIR=/opt/stack/logs

# Pre-requisite
ENABLED_SERVICES=rabbit,mysql,key

# Horizon (always use the trunk)
ENABLED_SERVICES+=,horizon
HORIZON_REPO=https://github.com/openstack/horizon
HORIZON_BRANCH=master

# Nova
ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch
IMAGE_URLS+=",https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img"

# Glance
ENABLED_SERVICES+=,g-api,g-reg

# Neutron
ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron,q-lbaas

# Cinder
ENABLED_SERVICES+=,cinder,c-api,c-vol,c-sch

# Tempest
ENABLED_SERVICES+=,tempest
[/code]

  • ./stack.sh

Using Devstack

  • Devstack runs inside of a screen session which you access using:
    screen -r
  • Basic screen usage is to hit the escape sequence then some key; the default escape sequence is ctrl+a:
    Example: ctrl+a let go of keys then
  • To move between the many windows in the devstack screen use:
    ctrl+a then " (that’s double quote, or shift+’)

Tips

  • devstack provides unstack.sh and rejoin_stack.sh (or restack.sh); I personally don’t have a lot of luck with these and just recreate the whole machine

I am tired of WordPress

I’m sure that sentiment is shared by more and more people every day. It is a heavyweight contender that no longer fits the leightweight blogger battles. This is my simple attempt to install something different.

The obvious benefits of Ghost, from my limited experience, have been:

  • the simple markdown editing
  • ease of installation (for people with Linux experience)
  • wonderful mobile support (mostly for tablets)

Update!!!

I primarily use the method described by [5] instead of the rest of it because it is a lot more secure.

You will still need to do a couple of the fixes listed here, but I will move them up for convenience:

  • Delete the default nginx symlink: sudo rm /etc/nginx/sites-enabled/default

Prerequisites

  • have a running Ubuntu 13.10 with root access
  • update apt-repo: sudo apt-get update
  • install the basic packages: sudo apt-get install -y build-essential

Steps to Install Ghost

  • Install the basic Ubuntu Packages required: sudo apt-get install -y nodejs [1]
  • Download the ghost package: curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip [2]
  • Unzip the ghost package: unzip -uo ghost.zip -d ghost
  • Change into the ghost directory: cd ghost
  • Create a symlink of /usr/bin/nodejs to /usr/bin/node [3]
  • You may also need to install sqlite dev libraries: sudo apt-get install libsqlite3-dev
  • You can now run npm install --production
  • To run ghost run: npm start
  • You can modify config.js to have an external-facing IP (such as 0.0.0.0)

Steps to Deploy Ghost

  • Install nginx: sudo apt-get install nginx [4]
  • Create and edit the file: /etc/nginx/sites-available/ghost.conf
  • Enter the following into the file:

[code lang=text]
server {
listen 80;
server_name example.com;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
}
[/code]

  • Change server_name to your domain
  • Symlink your config file from sites-enabled:

[code lang=text]
sudo ln -s /etc/nginx/sites-available/ghost.conf \
/etc/nginx/sites-enabled/ghost.conf
[/code]

  • Delete the default nginx symlink: sudo rm /etc/nginx/sites-enabled/default
  • Restart nginx: sudo service nginx restart

Secure Ghost and Server

Check out this website to know how to do that.

Sources