Ever needed to share VirtualBox machines, transfer them over the internet or back them up?
This article describes how to reduce the size of your virtual machine hard disk. Space savings are incredible, especially if you've been adding/deleting files to the VM hard drive a lot.
What the article does not say (because it is obvious): zip your virtual machine after performing the described steps and before transferring/backing it up.
Link: How To Shrink Your Virtualbox VM And Free Up Space For Your Hard Disk - Make Tech Easier
Thursday, 14 May 2015
Sunday, 10 May 2015
Migrate a VMware disk to Virtualbox: VMware player does not work on the Dell XPS 13 2015 Developer Edition
If you plan to use VMware player on it, you should know that I got plenty of issues as soon as I started using it: freezes every day or so, the sound was distorted and copy/paste wan't working 100%, I won't get in the details why I chose VMware player over Virtualbox in the first place.
For my office work (read: Microsoft Office 2013 ;-), I needed and purchased licences from Microsoft and wasn't too keen on creating a new virtual machine so I decided to migrate it. The best (and only) working solution I found was to convert the virtual harddrive and use it in VirtualBox. Here are the steps I followed (source):
Install qemusudo aptitude install qemu
Convert the virtual disk to a raw imageqemu-img convert /path/to/original.vmdk converted.bin
Convert the raw image to a VirtualBox vdi format:VBoxManage convertdd converted.bin converted.vdi
I then recreated a VirtualBox virtual machine around that harddrive and was good to go.
Note: I had to call the Microsoft support to (re)activate (virtual hardware had changed) Windows. I suppose they don't mind as long as you don't use the other virtual machine (which I don't intend to do since it was crashing my computer).
Please let me know if it helps (in the comment section below).
Friday, 31 October 2014
line1Let's say I want to retrieve the 'random text' lines but have no clue of what it looks like. I however know that the previous line contains the unique 'some text' string and that the line just after the random text I want to retrieve contains the unique 'other text' string.
Note the previous and next lines can contain any other text on them as long as I have a pattern I can match with grep.
Here is how I solve that problem;
Find the pattern before and return it with 999999 lines after
grep 'some text' -A 999999
Remove the first line of the previous results (start at line two)
tail -n +2
Find the pattern following our random text and return it with 999999 lines before it
grep 'other text' -B 999999
Skip the last line of these results
head -n -1
Put together we get
cat file.txt | grep 'some text' -A 999999 | tail -n +2 | grep 'other text' -B 999999 | head -n -1
Friday, 24 October 2014
This is a quick tip for people who don't want to start clicking on the Heading/Normal styles all the time when writing a long document (full of titles). This is especially handy when making a quick fist draft taking care of the structure but without looking too much at the format.
Here are the most useful keyboard shortcuts I use in these cases. Change the current selection or line to:
- Heading 1: Ctrl+Alt+1
- Heading 2: Ctrl+Alt+2
- Heading 3: Ctrl+Alt+3
- Normal: Ctrl+Shft+N
Thes are keyboard shortcuts any good MSWord document writer should know.
Friday, 10 October 2014
Replacing <BR> tags with actual carriage returns:
Note this command works with
- Capitalised and small letter tags e.g.: <BR> or <br>
- Tags with additional parameters (which is nonsense), e.g.: <br class="something">
- Tags with spaces and a closing slash, e.g.: <br />
Replacing with spaces
sed 's_ _ _g'
Remove heading space at the begining of each line
sed 's_^[\t ]*__g'
Remove all remaining html tags
You can then use all these commands together:
cat file.html | sed 's_<[bB][rR][^>]*>_\n_g' | sed 's_ _ _g' | sed 's_^[\t ]*__g' | sed 's_<[^>]*>__g'
Saturday, 4 October 2014
Ever wanted to download a page or make an http request with a custom header?
The parameters below let wget pretend it is a regular browser:
wget --referer="http://www.google.com" --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:184.108.40.206) Gecko/20070725 Firefox/220.127.116.11" --header="Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" --header="Accept-Language: en-us,en;q=0.5" --header="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" --header="Keep-Alive: 300" http://www.website.com/page.htmlThis can be useful to check e.g. if the server you're configuring blocks the right browsers and not the other ones.
Note: the blue referer lets you specify the page you were previously on.