ianneubert.com

Quickly convert files to Unix or Windows line endings

April 26th, 2012

Here is a quick script that will convert all js file line endings in a folder from either Windows or Unix into Unix line endings:
find . -type f -name '*.js' -print0 | xargs -0 perl -pi -e 's/(\n|\r\n?)/\n/'

And here is the same script to convert them into Windows line endings:
find . -type f -name '*.js' -print0 | xargs -0 perl -pi -e 's/(\n|\r\n?)/\r\n/'

VMWare Workstation left mouse stops responding

June 29th, 2011

For the last couple days I’ve had a problem with VMWare Workstation v.7.1.4 build-385536 where my left mouse click suddenly stopped working in my Windows 2008 guest VM.

I finally found the problem!

When dragging and dropping text inside the guest VM I was dragging outside the VMWare container. This is what caused the problem.

To fix it so that never happens again I’ve disabled the ability to Drag & Drop from the guest. You can set this in your virtual machine settings, under Options > “Guest Isolation”.

 

Add “I’m Feeling Lucky” keyboard shortcut to Chrome

May 13th, 2011

I often will search Google for a keyword that I know will return the result I want in the first spot. Until now I was using Chrome to search for the keyword and then clicking on the link to go to the page.

There must be a better way!

There is!

Setup a custom search engine in Chrome like this:

  1. Click the wrench icon
  2. Click on Preferences
  3. Click on Manage Search Engines
  4. Scroll to the bottom
  5. Add a new search engine with these fields:
    1. Google Instant
    2. !
    3. http://www.google.com/search?q=%s&btnI=Im+Feeling+Lucky

Bam!

Now you can do an I’m Feeling Lucky search just by hitting the exclamation point, a space, and then the keyword. Like this:

! ruby arrays

Windows 7 Drag & Drop Stops Working

April 19th, 2011

I’ve found that in Windows 7 sometimes I will randomly be unable to drag and drop files from the explorer shell.

If you ever have that problem try this to fix it:

  1. Press Ctrl+Alt+Del.
  2. Press Esc.

This worked great for me. Your results may vary!

By the way: Thanks Microsoft for yet another reason to use a Mac instead of a PC.

Source: superuser.com

Remote Desktop Connection: Copy and Paste Stopped Working?

February 1st, 2011

I have been using Remote Desktop Connection on my Mac to connect to my new Windows 7 PC for the last couple weeks. Ever run into a problem where your RDP connection stops sharing copy and paste with your Mac?

It was driving me nuts, but thanks to this website I was able to finally find the answer:

  1. Open task manager on the PC
  2. Kill the rdpclip.exe process
  3. Run the program rdpclip.exe from the CLI or close and reconnect the RDP session.

Update: After the break is a script that will automatically kill and restart rdpclip.exe.
Read the rest of this entry »

How to sync music from iTunes on Mac to a PC

January 13th, 2011

Here is an rsync command that will synchronize music stored in a Mac to a PC. It will not sync Movies or TV Shows. Just remove the –excludes if you want to sync those things.

rsync -av --force --delete --stats --size-only -e ssh --exclude="ethumbs_vista.db" --exclude="Thumbs.db" --exclude=".DS_Store" --exclude="iTunes\ Library.xml" --exclude="Mobile\ Applications/*" --exclude="Movies/*" --exclude="TV\ Shows/*" ~/Music/iTunes/* /Volumes/itunes

Thanks to MacRumors for the base of this command.

Use SSH to get tail of log file

July 14th, 2010

Ever wanted to take the last 1000 lines of a log file from your remote server and then copy that to your local machine to use in a nicer text editor?

Now you can! This single command will grab the last X lines from a remote file, remove any ANSI color codes, and then compress the output right on to your local computer.

Just replace the green text with your information and you’re all set.

ssh username@my.server.com "tail -n 3000 /var/log/mylogfile.log | sed -r 's/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g' | bzip2" > /my/local/file.log.bz2

The log will be trimmed, cleaned, and compressed all on the remote server before transport.

Ruby RVM Rocks!

April 23rd, 2010

I just now got around to installing RVM on my Mac. I wish I had done it a lot sooner!

RVM let’s you install multiple Ruby versions side by side. You can easily install a new ruby version just by typing:

rvm install ruby-1.8.7-p160

or

rvm install 1.9.2-preview1

And you can quickly switch between versions by typing this:

rvm ruby-1.8.7-p249

Note that you will need to install gems independantly in each of your ruby environments. But they make it easy with gemsets. Also note, that if you want to preserve your custom ENV settings on your Mac, you should place the bash source line into your .profile file and not to .bashrc as it notes.

Have fun!

Holy Optimizations Batman!

February 20th, 2010

I previously published a Ruby script that essentially duplicates an Amazon S3 bucket. I use it to copy my production bucket into a testing bucket that I can then use in my staging environment, without fear of killing off something important.

Hydra, the multithreaded fire breather
Hydra, the multithreaded fire breather

Anyway, this script used to take around 18 minutes to complete a full copy of a bucket with about 2,000 keys. What a pain when I had to run this script multiple times for some testing!

So I finally got around to rewriting it today, and wow, what an improvement!

I upgraded the delete and copy operations to run multithreaded, and boy does it fly.

On my main bucket (with about 2,000 keys) it now only takes about 1.5 minutes to complete! That’s 12x faster than it used to be!

So if you are looking for a multithreaded Amazon S3 bucket copier or duplicator, check it out!

New rubygem: ianneub-right_aws

April 7th, 2009

Continuing my new trend of publishing code that I use, I’ve released a new fork of RightScale’s right_aws ruby gem. This gem makes accessing Amazon’s S3, EC2, and other web services a piece of cake through ruby.

One problem with (at least) the latest release of right_aws is that it tries to connect to the Amazon API at the bucket_name.s3.amazonaws.com. This causes the connections to the API to thrash when you are working with more than one bucket. I’ve taken out the code that makes that connection so that it will now only connect to s3.amazonaws.com/bucket_name by default.

You can find the code on GitHub. And see extra documentaion here.