Quickly Remove Comments from Configuration Files
Configuration files can be long and complex and it is hard to see which values have been set. There are numerous ways to do this however, grep with -v (–invert-match) is a quick way to achieve this. The following example removes all the comments from an elasticsearch configuration file:
ed@es01:~$ sudo grep -v ‘#’ /etc/elasticsearch/elasticsearch.yml Which returns:
cluster.name: es node.name: es01 network.host: 10.1.10.187 discovery.zen.ping.unicast.hosts: ["10.1.10.187", "10.1.10.124"] discovery.zen.minimum_master_nodes: 2 Five lines where it is easy to see what has been configured.
Batch Convert Images
The quickest way of converting image formats is to use ImageMagick. There are binary releases for most popular operating systems, however in my case I’m using it on OS X. So to install using brew from a terminal use:
brew install imagemagick Once that is installed then just move to the folder you are interested in and use the following:
mogrify -format png *.jpg Once that is completed the folder of jpegs should now have some png friends to play with.
Nslookup on The Mac, Interactive Mode Broken
Nslookup under osx is tricky to use interactively as it doesn’t support readline. When you try to use the command history you get the following:
> ^[[A Argh! This means more typing. As far as I can remember it has always returned ^[[A or ^[[B depending on the arrow key used. After a bit of research it seems you can fix it with rlwrap which you can install via mac ports.
Getting the Size of a File in Bytes in Unix/Linux
Use the following from a terminal to get the file size in bytes:
wc -c ~/screenlog.0 Which in this case will output:
76974 /Users/edward/screenlog.0 Showing my screenlog.0 is 76974 bytes.
Open the Current Working Folder from the Command-line/Terminal in Windows, Ubuntu or OS X
Sometimes you need to use the operating system file manager rather than a terminal so a quick way of opening it can be seen below. For the Windows command line:
explorer . The OS X terminal:
open . The Ubuntu console:
nautilus . This will work for parent folders .. as well as current directory. Note, in case you are interested to do the same in Haiku OS just use the OS X version.
Installing Hyper-V Role on Windows Server 8 Beta Running Under VMware Fusion
This is a catchy title, but if you are interested in playing with Hyper-V 3 then add the following to your virtual machine vmx file:
vhv.enable = TRUE hypervisor.cpuid.v0 = FALSE mce.enable = TRUE Once you have added these lines you are good to install the Beta and add the Hyper-V 3 Role. If you miss out the ‘mce.enable’ line, when you reboot after adding the Hyper-V role you get a blue screen with an error complaining about hal_initialization_failed, so make sure you include it.
Compiling Growl 1.3 for Lion
To begin, make sure you have removed any previous versions of Growl. Instructions here. You will need to install Mercurial, which can be found here. Once installed input the following from a terminal:
mkdir ~/Desktop/tmp cd ~/Desktop/tmp hg clone https://code.google.com/p/growl/ cd growl At this point you need to open Keychain Access as we have to self sign a certificate for xcode to use in building Growl. In Keychain Access, go to the application menu and choose: Keychain Access < Certificate Assistant < Create a certificate In the box that appears, change the name to: 3rd Party Mac Developer Application: The Growl Project, LLC Select the Certificate Type ‘Code Signing’ and click create accepting the trust warnings.
How to Restart Finder from the Terminal
Some times it is necessary to force finder to restart. You can do this from the GUI using the ‘Force Quit’ menu item, however sometimes it can be quicker to use the Mac terminal:
sudo killall Finder You may need to manually start finder if it doesn’t automatically:
open /System/Library/CoreServices/Finder.app Sometimes you can’t beat a good old fashioned reboot:
reboot This is rather a harsh way of rebooting as it just sends out a sigterm and subsequently a sigkill.
Removing/Uninstalling Xcode
Just run the following from a terminal:
sudo /Developer/Library/uninstall-devtools –mode=all This is quite old, these days you should just be able to delete the Xcode app.
Converting an Ovf Template to run in VMware Fusion
VMware has a tool called ovftool. You need to do a full, custom install of Fusion to get the ovf tool. It is located in:
/Library/Application Support/VMware Fusion/ovftool Change to this directory and run the following to see examples:
./ovftool –help examples``` To run a basic conversion use: ./ovftool path_to_ovf_file.ovf /output_directory/
This will convert the ovf into a format that Fusion can try to boot. This will not enable a virtual machine with incompatable hardware to boot.