Monday, December 10, 2012

Todoist : Solving cross domain security policy


Solving cross domain security policy [top]

You cannot use AJAX to directly communicate with Todoist, this is due to browser security policy. You can solve this by communicating with Todoist using a script tag:
var script = document.createElement('script');
script.type = 'text/javascript';
The response data will look like this (callbackFunction will be called):
callbackFunction({ JSON data here });

Sunday, December 2, 2012

GNU Screen Cheat-Sheet

Taken from
–ctrl a c           -> cre­ate new win­dow
–ctrl a A           -> set win­dow name
–ctrl a w           -> show all win­dow
–ctrl a 1|2|3|…   -> switch to win­dow n
–ctrl a ”           -> choose win­dow
–ctrl a ctrl a      -> switch between win­dow
–ctrl a d           -> detach win­dow
–ctrl a ?           -> help
–ctrl a [           -> start copy, move cur­sor to the copy loca­tion, press ENTER, select the chars, press ENTER to copy the selected char­ac­ters to the buffer
–ctrl a ]           -> paste from buffer
How to start screen:

–screen –DR            -> list of detached screen
–screen –r PID         -> attach detached screen ses­sion
–screen –dmS MySes­sion -> start a detached screen ses­sion
–screen –r MySes­sion   -> attach screen ses­sion with name MySession

–ctrl a S       -> cre­ate split screen
–ctrl a TAB     -> switch between split screens
If you cre­ated a new split screen, the cur­rent win­dow is empty. either select an exist­ing win­dow (ctrl a ”) or cre­ate a new split screen (ctrl a n).

–ctrl a Q       -> Kill all regions but the cur­rent one.
–ctrl a X       -> remove active win­dow from split screen
–ctrl a O       -> logout active win­dow (dis­able out­put)
–ctrl a I       -> login active win­dow (enable output)

Thursday, November 29, 2012

Sphinx fails to start with rake ts:start or rake ts:rebuild

$ rake ts:start
Failed to start searchd daemon. Check ../log/searchd.log.
Failed to start searchd daemon. Check ../log/searchd.log
Be sure to run thinking_sphinx:index before thinking_sphinx:start
Almost always is the case for me that searchd is already running / orphaned and needs to be killed. Run
$ps -ax | grep searchd
shows that its already running
49630 ttys000    0:00.06 searchd --pidfile --config ../config/development.sphinx.conf
49644 ttys001    0:00.00 perl /usr/local/bin/grep searchd
and kill it
$kill -9 49630

Friday, November 2, 2012

Is there a way through which I see which mysql queries are fired from ActiveRecord in rails console?

Yes, this can be achieved through redirecting rails log to standard output.

Write these at your console prompt:

ActiveRecord::Base.logger =
Furthermore, you can put these lines in ~/.irbrc file, so that each time you don't need to manually write these 2 lines:

require 'rubygems'

if ENV.include?('RAILS_ENV') && ENV["RAILS_ENV"] == 'development'
    ActiveRecord::Base.logger =

Friday, August 10, 2012

VIM: Search And Replace Text In Multiple Files

:args **/*.*   // set the pattern of file names to look at
:argdo %s/search_for/replace_with/gecI | update

Wednesday, May 9, 2012

Giganews Mimo Crashes After Splash Screen on Win 7

If you're crashing on the splash screen right after it the RMI initialization message try passing the -noRmi flag to mimo.exe. In the start menu right click on Mimo, select properties, and add the flag to the target. Mine looks like this:
"C:\Program Files (x86)\Mimo\Mimo.exe" -noRmi
You should see an "RMI Disabled" message on the splash screen.

Oracle, Ruby, RVM, and OSX Lion

As of this writing the x64 version of the Oracle Instant Client do NOT work with OSX Lion. I got everything working like so:

Install Oracle Instant Client

Install the 32 bit version of the Oracle Instant Client. Download and install the following packages to /usr/local/oracle/instantclient_10_2

Install the 32-bit version of Ruby

brew install libyaml
rvm install 1.9.3 -n i386 --with-arch=i386
rvm use ruby-1.9.3-p194-i386


Add the following to your .bash_profile
export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2"
export TNS_ADMIN="/usr/local/oracle/network/admin/"
export SQLPATH="/usr/local/oracle/instantclient_10_2"
export ORACLE_HOME="/usr/local/oracle/instantclient_10_2"
export PATH="$PATH:/usr/local/bin/"
export PATH="$PATH:/usr/local/oracle/instantclient_10_2"
Open and use a new terminal going forward.


Create a tnsnames.ora file here:
Mine looks like this:
staging_db =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 123.456.789.1)(PORT = 1521))

Try it

ruby -rubygems -e "require 'oci8';'username','password','staging_db').exec('select * from users where rownum < 2') do |c| puts c.join(','); end;"

Thursday, April 26, 2012

Conditionally load ruby-debug gem

At the time of this post ruby-debug isn't available on for 1.9.3. I can't code ruby without it, well I can but I wont. If not everyone on the team wants to do this ruby-debug-on-ruby-193 to get it working you can conditionally load the gem like so:
# for all you ruby-debug haters out there
  if (Gem::Specification::find_by_name "ruby-debug-base19", ">= 0.11.26")
    gem 'linecache19',       '>= 0.5.13'
    gem 'ruby-debug-base19', '>= 0.11.26'
    gem 'ruby-debug19'
rescue Gem::LoadError
  puts "no debug for you"

Monday, April 23, 2012

"No Xcode folder is set" when attempting "brew install macvim"

xcode-select: Error: No Xcode folder is set. Run xcode-select -switch to set the path to the Xcode folder.

This fixed it
sudo xcode-select -switch /Applications/

If you're on a non-upgraded x64 version of Lion don't use Homebrew to install MySQL

At least for me I couldn't get gem install mysql or gem install mysql2 to compile. Kept bitching about missing header files and the like. Instead use this .dmg

mysqld: Table 'mysql.plugin' doesn't exist

If you installed MySQL 5.5 using Homebrew and you're getting this when trying to execute mysqld you probably just need to run mysql_install_db from your /usr/local directory.

From the instal directory run scripts/mysql_install_db

Solution to clipboard sharing when running Mac OSX 10.7 as a VMWare Workstation Guest OS

Install Synergy on both the guest and host. Stand back and watch it work.

Friday, April 20, 2012

Tuesday, April 17, 2012

I can never remember this url since I only need it about once a year. Great little site for building a custom installer.

Thursday, March 1, 2012

Sunday, February 26, 2012

ruby-debug on ruby 1.9.3

Taken from:

First download linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem from, then …

$ gem install linecache19-0.5.13.gem 
Building native extensions.  This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed
$ gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/Users/rtremaine/.rvm/src/ruby-1.9.3-p194  
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19-0.11.26
and voilá.

Wednesday, February 15, 2012

Rails: WARN TCPServer Error: Address already in use - bind(2)

Getting this message when trying to start WEBrick. Run
lsof|grep 3000
kill -9
the pid you get from the previous command.