Save file in vi using sudo
If you edit a file with vi as normal user, but need superuser rights to save it, you can use this sequence to save it using sudo:
:w !sudo tee %
/hat tip to @nistude Show archive.org snapshot
Related cards:
Change Time Format when using ls on Mac OSX
If you want to display the timestamp of a file e.g. in ISO format when using ls
on OSX, then you need to install the coreutils
e.g. using homebrew
$ brew install coreutils
Then you can use
$ gls -l --time-style=long-iso
...
Switch between spec and source in Sublime Text 2
Install the RubyTest Package
Then you can use
CMD + .
to switch between the spec and the rb file.
knife cookbook site install fails
I assume due to very old, previously installed vendor branches. Do the following:
Cancel the merge the failed command put you into:
git reset --hard HEAD
Delete the problematic vendor branch:
git branch -D chef-vendor-<YOUR COOKBOOK ...
Display time of file
$ brew install coreutils
$ gdate -r file.ext '+%F %T'
Will print:
2007-06-27 20:03:44
Enable Versioning on Amazon S3 bucket using ruby
If you want to enable versioning support for an Amazon S3 bucket, you can use the fog gem.
$ gem install fog
$ irb
irb> require 'fog'
irb> storage = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_s...
Ext3 on Mac OSX Lion
To be able to read ext3 formatted disks on Mac OSX Lion (10.7) you need to install a current FUSE implementation (macFUSE is discontinued, but there are several newer projects):
- OSXFUSE
- [Fuse4X](http://fu...
Sublime Text 2 on the OS X Command Line
To use Sublime Text 2 as command line editor, you need to create a symlink:
If installed via Homebrew Cask:
ln -s "/opt/homebrew-cask/Caskroom/sublime-text/2.0.1/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
or, i...
Delete a remote branch with git
Delete the local branch
git branch -d branch_to_delete
Delete the remote branch:
git push origin :branch_to_delete
NOTE Make sure you put the colon in front of the branch name
Thanks, @nistude