Total results: 30

Send command to all iTerm 2 panes

In the absense of having any time/thing to write about in the last months, here's another quick tip.

iTerm 2 is a replacement application for the default terminal on OSX. It's highly popular due to allowing advanced features such as tabs, split panes, simpler theming and custom keyboard bindings.

iTerm 2 split panes

If you find the need to enter the same commands into multiple panes at the same time, simply hit "Command + Shift + I". You will recieve a small notification about sending input to all panes, the next text you type will physically begin typing into all open panes for your current tab and is executed once you hit "⏎ Return".

Pretty neat!

I find this extremley useful when I have 4+ panes open in a working state, I don't want to close them but I need to reload my bash profile because of some new changes, so I simply hit "Cmd + Shift + I", type "source ~/.bash_profile", hit "Return" and I'm done.

The "ctrl + alt + delete" of RVM

When ever you are trying to install a Ruby, package or anything else with RVM it is not that uncommon to run into strange issues. Just like when you first go to smashing the Ctrl + Alt + Delete keys on Windows, I have found through experience that the first port of call should be to take the following simple steps.

For an example, imagine you are trying to install Ruby 1.9.2. I recently had to use this approach to get version 1.9.2 installed on OSX Lion.

Note: On OSX, Make sure you have either the GCC libraries or XCode 4.2+ installed to work best with RVM

Steps

  1. rvm get head
  2. rvm reload
  3. rvm remove 1.9.2
  4. rvm install 1.9.2

First we update RVM, reload the environment (important) remove whatever broken ruby/package you are trying to get working. Finally, Install it fresh. 

You would be suprised how often this resolves issues. Give it a try next time you are having issues.

Show git branch and directory in your shell

It's really handy to be able to see the current git branch in your shell prompt along with the directory name. This for a start removes many "git branch" commands from your history.

To enable this feature, you have to edit your .bashrc file on Linux or the .bash_profile on Mac. These files usually exist in your home directory (The default directory when you open a shell) and are executed when the shell logs in. You can edit this file with any text editor such as Gedit or Textmate.

Add the following 2 lines after any existing SP1 variables and then save your file. Open a new shell to see the changes.

GIT_PS1_SHOWDIRTYSTATE=false
export PS1='\[\033[1;36m\]\u at\[\033[00m\] \[\033[34m\]\W\[\033[31m\]$("__git_ps1")\[\033[00m\]  >  '


SP1 colour example

Changing colours

If you would like to update the colours of the prompt, then visit this article to get a grasp of the basics and you can find much more on Google from there.

Activating Apache/PHP on Mac alongside Pow server

Instead of rewriting a step-by-step guide on how to do this, I can recommend two great articles that will get you setup in no time.

First read this article on how to setup Apache and PHP on your Mac:
http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/

Next, follow the instructions from 37signals on using Pow alongside Apache. Make sure to pay attention to the troubleshooting section if you had any trouble.
https://github.com/37signals/pow/wiki/Running-Pow-with-Apache

Detect if page is within Facebook iframe or not: Javascript

Make sure to check the update at the end of the article. 

There is a handy piece of Javascript which you can use to tell if the current page is within the Facebook canvas iframe, or if it is being viewed normally in the browser.

The Facebook canvas gives its window a special "name" attribute. In most cases unless you generated the browsing window, it will have no name so we can use the piece of code below.

  if(window.name != "") {
    //We are on Facebook
  } 
  else
  {
    //We are just in the normal browser window
  }

However, if you changed your window name through Javascript, change the IF statement to match.

With this information, we can hide, add or manipulate our HTML in any way that is required to highlight the difference between your Facebook app and the regular web app.

 

Update Feb 2016:

As noted by Kilian in the comment section, an imporved way to detect the Facebook iframe is:

if(window.name.indexOf('iframe_canvas_fb') > -1)

Fix Fast Debugger (ruby-debug-ide) on Windows 7

I've finally found a solution that will make the Fast Debugger (a.k.a ruby-debug-ide) work with Netbeans 6.9.1+ on Windows 7. This solution should also work for anyone using Vista, which I know from experience has similar issues.


First step: make sure the Ruby DevKit is installed. Full instructions for installing it are here on Github: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit.

The DevKit basically temporarily enhances Windows and allows tricky Gems to be compiled.

Second step: Next you must install the correct debug Gems. If your Ruby version is 1.9.2+ then you will require the gems ending with a "19".

The way to make the gems install successfully is through Netbeans. Go to Tools > Ruby Gems > New Gems.

Do a search for "ruby-debug" and you shall see a list similar to this:

Install the "latest" version of all of the Gems which I have highlighted. Do not try and install "ruby-debug".

Third step: Once the Gems have installed, open up and new Command Prompt, run the command "gem list" and check that all of the Gems are listed, if not try to install them manually.

Next, the "rdebug-ide" file must be edited. Find this by browsing to (or similar):
C:\Ruby192\lib\ruby\gems\1.9.1\gems\ruby-debug-ide19-0.4.12\bin

 

Find the line (around 79):

Debugger::PROG_SCRIPT = ARGV.shift

Replace it with:

script = ARGV.shift
Debugger::PROG_SCRIPT = (script =~ /script([\\\/])rails/ ? Dir.pwd + $1 : '') + script
puts Debugger::PROG_SCRIPT
#Debugger::PROG_SCRIPT = ARGV.shift

Final step: Save the file and restart your computer. When Netbeans is reopened, click the "Debug main project" button to start the server in debug mode.

Thanks must be given to the following for help in figuring this one out:

© Blake Simpson, 2012 – 2017