tmux cheat sheet

I’ve recently started using tmux, so here’s my cheat sheet to remember some of the basic commands:

tmux new -s bob  create new session called ‘bob’
tmux attach (at) -t bob  attach session ‘bob’
tmux list-sessions (ls)  list sessions

Ctrl + b is the action key
$  rename session
c  new window
,  rename window
&  kill current window
x  kill current pane
↑/↓/←/→  go to pane
"  split horizontally
%  split vertically
c  new window
d  detach session
l/n  last/next window
0-9 select window
?  help
: command prompt

In command prompt:

resize-pane -{D|U|L|R} 10  resize pane in direction by 10

Posted in Linux, Software | Tagged , , , | Leave a comment

Apache: address already in use, but not for real

Check you don’t have multiple “Listen 80” or multiple “Listen 443” throughout your configuration.

Posted in Linux, WebDev | Tagged | Leave a comment

Puppet trouble with vcsrepo module

After having tried to use the vcsrepo module for Puppet a while back and it not working, then trying tonight and it still doesn’t work; no kind of message even in debug to help understand what’s going on, I finally remembered something form having used another module previously:

# /etc/puppet/puppet.conf
[main]
pluginsync = true

And that’s it!

The module simply has a plugin included, and if you don’t sync it, the module won’t run.

 

Source: https://docs.puppetlabs.com/guides/plugins_in_modules.html

and https://projects.puppetlabs.com/issues/7585

Posted in Linux | Tagged , , , , | Leave a comment

Javascript unexpected errors

Today while working on a mini-project, I encountered some problems with JavaScript, notably:

Unexpected end of input
or
Unexpected token illegal

Oddly, the source file had barely changed (new line, for example) and there was no apparent error. Also, sometimes the file received seen through Chrome Developer Tools didn’t reflect the changes made on the source.

After searching around for a bit, I found this post in StackOverflow which brings to this post, where it appears to be a problem with VirtualBox and its use of the sendfile() function.

The problem appears when using shared folders through VirtualBox, and the fix is to add the following directive to your site description:

For nginx:

sendfile off;

For Apache:

EnableSendfile Off

Extract from the Apache docs:

This directive controls whether httpd may use the sendfile support from the kernel to transmit file contents to the client. By default, when the handling of a request requires no access to the data within a file — for example, when delivering a static file — Apache uses sendfile to deliver the file contents without ever reading the file if the OS supports it.

This sendfile mechanism avoids separate read and send operations, and buffer allocations. But on some platforms or within some filesystems, it is better to disable this feature to avoid operational problems:

  • Some platforms may have broken sendfile support that the build system did not detect, especially if the binaries were built on another box and moved to such a machine with broken sendfile support.
  • On Linux the use of sendfile triggers TCP-checksum offloading bugs on certain networking cards when using IPv6.
  • On Linux on Itanium, sendfile may be unable to handle files over 2GB in size.
  • With a network-mounted DocumentRoot (e.g., NFS or SMB), the kernel may be unable to serve the network file through its own cache.

For server configurations that are vulnerable to these problems, you should disable this feature by specifying:

EnableSendfile Off

For NFS or SMB mounted files, this feature may be disabled explicitly for the offending files by specifying:

<Directory "/path-to-nfs-files">EnableSendfile Off</Directory>

Please note that the per-directory and .htaccess configuration of EnableSendfile is not supported by mod_disk_cache. Only global definition of EnableSendfile is taken into account by the module.

Posted in WebDev | Tagged , , | Leave a comment

Disk passthrough in Proxmox

Recently, I’ve added a few gigs of RAM to my main homeserver, so I figured I could transform it into a VM hypervisor, P2V the original config and then have some room to play with other stuff.

I chose to go with Proxmox, as it’s Debian-based, and I had trouble with both Hyper-V and ESXi (installation from/to USB, network drivers, etc.)

Because I use Puppet to manage all my configuration, I didn’t do anything particular to backup the original configuration, except saving some dotfiles.

The first difficulty I encountered was uploading ISOs through the web interface, it would always timeout after about 400MB transferred so I just sent them through SFTP.

Since I have multiple disks in the server which are used for Samba, I wanted to pass them through to the new VMs, but couldn’t find a way to do so through the web interface. After looking around for a bit, I found two solutions which work together.

The first step is to identify the disk you want to pass through. For this, there are multiple methods:

fdisk -l
ls -l /dev/disk/by-label
ls -l /dev/disk/by-uuid
ls -l /dev/disk/by-id

Note that using /dev/sdX is not a great option since the letter attribution can change, whereas a disk’s uuid will not.

Then, you’ll want to copy whatever label/uuid/id that is relevant, and to allow passthrough there are now two options:

1. Through the Proxmox console

qm set {vmid} -{ide|sata|scsi}# /dev/disk/by-{label|uuid|id}/{reference}

with vmid the ID of your VM, ide or sata the type of disk you want to add.

Note that ide value can be 0-3, sata can be 0-5 and scsi 0-13. Also, ide0 is generally the boot disk and ide2 will be the CD drive; Adjust depending on your configuration.

example:

qm set 101 -sata0 /dev/disk/by-label/data01

This will modify the {vmid}.conf file, which bring us to option 2.

2. By directly modifying the {vmid}. conf file in /etc/pve/qemu-server/

Add a line as follows:

{ide|sata|scsi}#: /dev/disk/by-{label|uuid|id}/{reference}

example:

sata0: /dev/disk/by-label/data01

 

You’ll want to shutdown then boot the VM (not just a regular restart) for the changes to take effect, after which the disk should be accessible in your VM.

Posted in Linux | Tagged , , , , , , | 1 Comment

Budgeting app

For a bit more than a year now, I’ve been tracking all my income and expenses in a Google Doc Spreadsheet; From that I wanted to analyse the data and create some graphs based on different factors like categories, months, etc.

Of course, I could do it all in GDocs, but since I’ve got some free time these days, I wanted to try and create an application for doing so using MongoDB as data store and a Python API.

I’ve decided to use Bottle as API engine since it appears to be lightweight and fairly easy to use.


Update (20/11/2014):

I’ve created a github repo for the project: https://github.com/JohannDickson/Budget

Posted in WebDev | Leave a comment