Skip to content

Instantly share code, notes, and snippets.

//inside a fragment. If in an Activity you could use findViewById(Window.ID_ANDROID_CONTENT);
getView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
{
@Override
public void onGlobalLayout()
{
//do something like measure a view etc
View content = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
Log.d("DISPLAY", content.getWidth() + " x " + content.getHeight());
@z8888q
z8888q / rails_test_box_prepackaged.sh
Created May 5, 2012 09:47 — forked from jeroenvandijk/rails_test_box_prepackaged.sh
Instructions for setting up the prepackaged Rails test environment
# These commands will help you setup the Rails test environment without problems
#
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste all of following commands in your normal terminal and the following things will happen:
# - rails_test_box dir is created
# - rails master branch is checkout in the dir rails
# - A Gemfile is created and all the gems to run the virtualbox are installed using bundler
# - The rails vagrant box is downloaded and added to your vagrant boxes
# - A Vagrantfile is created for vagrant
@z8888q
z8888q / posts_and_comments.rb
Created March 30, 2012 17:27 — forked from vsavkin/posts_and_comments.rb
Create Posts and Comments
blog = Blog.create
post = blog.make_post text: 'great post', location_country: 'Canada', location_city: 'Toronto'
post.make_comment text: 'great comment', location_country: 'Canada', location_city: 'Toronto'