Me, The programmer

Just another WordPress.com site

Viewing changed files that changed between git branches

I found myself trying to figure out which files I had modified/added in my working git branch (related to the remote repository).

After giving it a little bit of thought I realized I knew how to do it. Here it goes:

  1. Go to the branch that mirrors the remote repository (I will call it master from now on): git checkout master
  2. Make sure it is up-to-date: git pull –rebase origin master
  3. Create a new branch off of master (just to be on the safe side, so that you don’t accidentally add stuff into it): git checkout -b modified_files
  4. Merge the changes from your working branch into this new branch using the –squash argument: git merge working_branch –squash
  5. git status will tell you which files you have modified
  6. Now you can throw that new branch away

If you want to, you can easily write a script that automate all the above steps.

 

Hope this helps.

Resizing a Root LVM Fedora Partition Running on Virtualbox

Alright, I just went through *A LOT* of trouble to resize a Fedora partition running on a VirtualBox. This is what I did.

  1. My previous VirtualBox had 8gb of space. I created a new one with 30gb
  2. VBoxManage.exe clonehd OldHD.vdi NewHD.vdi –existing (this will copy your current filesystem over to the new virtual hard drive)
  3. On the previous step the file system was copied over, but the extra space will be left as unallocated, so now we need to expand your root partition. In order to do this, you will need to usa a Fedora Live CD.
  4. After the CD has booted, open a terminal and elevate it with “su”.
  5. Run system-config-lvm
  6. Find the uninitialized entities and initialize them
  7. Close system-config-lvm
  8. On the terminal, run lvresize -L +XXXGB /dev/PARTITION_PATH. This will extend your partition.
  9. Your partition has been extended now, but your filesystem still doesn’t know about it. Now run resize2fs -p /dev/PARTITION_PATH and voilá.

Hope this helps.

Testing on Android across multiple activities

I have needed to test on Android across multiple activities multiple times and I always forget how to do it exactly. I’ve found myself researching on this subject multiple times, so I have decided to post the same link that always ends up answering all my questions:

http://stackoverflow.com/questions/1759626/how-do-you-test-an-android-application-across-multiple-activities

Open Declaration and Going Back on Eclipse

Most of the IDEs have the “open declaration” (also called “go to definition”) funcitonality, which, as it says, takes you to the definition of the piece of code you are analyzing.

On visual studio, I was already used to use the F12 shortcut to go to definition and ctrl- to go back. Going back is very useful because you often get lost if you start jumping to the definition of too many things while you are trying to understand the code.

Today I found out eclipse also has the “go back” functionality, and its shortcut is the ALT+LEFT ARROW key.

NSRunLoop and Autorelease Pools

I was coding for iOS today and I found out my code was leaking memory. What my code was doing, basically, was running an HTTP RPC server in an NSRunLoop.

At first I thought the reason why it was leaking memory was because I didn’t create an auto release pool for the NSRunLoop, until I decided to read how the NSRunLoop actually works. It was somehow hard to find out information about how NSRunLoop works, but I ended up finding out that NSRunLoop already creates an autorelease pool when a input or a task comes in an releases it after it finishes handling them. Eventually, I discovered that the leak was actually in the HTTPServer code I got from Apple’s website and fixed it.

Searching code in visual studio with regular expressions

You can search in visual studio using regular expressions. All you need to do is press ctrl+F and click on the “use” checkbox. This will cause the combo-box below to get activated. All you gotta do next is choose “regular expressions”.

Searching for the followin string, for example, will select lines that contains the “<returns>” tag: :b*/// \<returns\>(.*)

:b means spaces

\< is just scaping <

\> is just scaping >

(.*) means any combination of characters.

Note that (.*) doesn’t match newline.

Getting memory used by app on the iPhone Programatically

Autotest

Sounds like a *Very* interesting concept. Basically, what it does is to test everything you change automatically.

I haven’t tried it yet, but here goes tutorials on how to set it up:

 

http://ruby.railstutorial.org/chapters/static-pages#top

http://automate-everything.com/2009/08/gnome-and-autospec-notifications/

Linux Bash Profile

I’ve been developing for windows for a while and it is always a pain to migrate to a different platform. I think this is probably going to sound kinda silly, but today I just found out about linux bash profiles, and it has made a huge productivity impact on me.

More on: http://www.cyberciti.biz/faq/change-bash-profile/

“failed to build gem native extension” – ffi

Spent the whole day today trying to get bundle install to work and I always got an error while trying to install the ffi gem:

Installing ffi (1.0.7) with native extensions ..
.
/usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:481:in `build_extensions’: ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby extconf.rb
checking for ffi.h in /usr/local/include… no
checking for rb_thread_blocking_region()… no
checking for ruby_thread_has_gvl_p()… no
checking for ruby_native_thread_p()… no
checking for rb_thread_call_with_gvl()… no
creating extconf.h
creating Makefile

make
Configuring libffi
/home/vicente/.bundler/tmp/2390/gems/ffi-1.0.7/ext/ffi_c/libffi/configure: line 725: 0: Bad file descriptor
make: *** [/home/vicente/.bundler/tmp/2390/gems/ffi-1.0.7/ext/ffi_c/libffi/.libs/libffi_convenience.a] Error 1

Gem files will remain installed in /home/vicente/.bundler/tmp/2390/gems/ffi-1.0.7 for inspection.
Results logged to /home/vicente/.bundler/tmp/2390/gems/ffi-1.0.7/ext/ffi_c/gem_make.out
from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `each’
from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions’
from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:198:in `install’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `run’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `send’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/bin/bundle:13
from /usr/bin/bundle:19:in `load’
from /usr/bin/bundle:19

Seems like this issue only repros on a Fedora VM (and I am happening to be using exactly one of those).

Fortunately, I found this: which helped me solve the issue: http://bugs.joindiaspora.com/issues/477