Tuesday, June 11, 2013

How do I debug/run an app in Android Studio to a Nexus 7

So, it turns out developer mode is a little tricky to find on a Google Nexus 7. Go to "Settings" -> "About Tablet" then click EXACTLY 7 TIMES on the "Build Number". (After three presses, you'll get a message "You are four steps from being a developer”) This will open up "Developer Options" in the menu. Choose that. Enable "USB debugging"

Thursday, May 16, 2013

Chrome - Network error - Failed

So, let's say you're downloading a large file in Chrome and it fails... what do you do?

Well, if you're at home or work or somewhere with a fast network, you probably just start the download again (there's no resume functionality).

But what if you're at a conference or coffee shop or somewhere without a fast internet connection.  Starting the download from the beginning could cost you a significant amount of time.
Instead:

Open your downloads folder (e.g. ~/Downloads in OSX if you haven't changed the defaults)
Locate the file you were trying to download, it will have the extension .crdownload
Rename the file, removing the ".crdownload" extension (e.g. myfoo.zip.crdownload should be renamed to  myfoo.zip)
Open a terminal window in the same directory
Use wget to resume the file (the -c flag will continue the download you're already started)
wget -c <url_of_the_file_you_were_downloading>

Thursday, January 17, 2013

getting py2cairo installed on osx w/ brew

(this is more of an gist that a post)
> ./waf configure

  ./options()
Setting top to                           : /Volumes/HDD/Downloads/py2cairo-1.10.0
Setting out to                           : /Volumes/HDD/Downloads/py2cairo-1.10.0/build_directory
  ./configure()
Checking for 'gcc' (c compiler)          : ok
Checking for program python              : /usr/bin/python
Checking for python version              : (2, 7, 1, 'final', 0)
Checking for library python2.7           : yes
Checking for program python2.7-config    : /usr/bin/python2.7-config
Checking for header Python.h             : yes
Checking for program pkg-config          : /usr/local/bin/pkg-config
Checking for 'cairo' >= 1.10.0           : not found
The configuration failed
(complete log in /Volumes/HDD/Downloads/py2cairo-1.10.0/build_directory/config.log)


 After a TON of trial and error, followed by brew install , here's what I came up with: 
 export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig:/usr/local/Cellar/libpng/1.5.13/lib/pkgconfig:/usr/local/Cellar/freetype/2.4.10/lib/pkgconfig:/usr/local/Cellar/fontconfig/2.10.1/lib/pkgconfig:/usr/local/Cellar/pixman/0.28.0/lib/pkgconfig:/usr/local/Cellar/cairo/1.12.8/lib/pkgconfig:/opt/local/lib/pkgconfig

> ./waf configure
> sudo ./waf install

Monday, June 11, 2012

one-line update for all pom versions in multi-module project

We have a multi-module Maven project with many children, so it's a little annoying to bump the version number. Here's a one-liner to do it, just replace _OLD_ and _NEW_ with the old version and new version, respectively.
for f in `find . -name pom.xml`; do sed 's/_OLD_/_NEW_/' $f > $f.new; mv $f.new $f; done
for example:
for f in `find . -name pom.xml`; do sed 's/1.1.23-SNAPSHOT/1.1.24-SNAPSHOT/' $f > $f.new; mv $f.new $f; done

*DON'T FORGET TO CHECK THE DIFF (you ARE using Git, right?)*

** Update (thanks jamcole)**

Or even easier, use the Maven versions plugin (from the top-level project):
mvn versions:set

Saturday, June 9, 2012

Autotest w/ jeweler and 1.9.2-p320

I wanted to take another stab at TDD (and stick with it this time!) so I dusted off my copy of the awesome PragProg book 'Continuous Testing' and tried to get everything working again. Here's what I had to do (since I have trouble getting everything to work anytime I try - not detracting from the hard work the authors put into the writing, but it's never gone smoothly for me) There's just too many moving pieces that always seem to have minor version incompatibilities or quirks.

jeweler - wasn't too tough to set up, I'm using 1.8.3

So, run:

  • $ jeweler --rspec tower_d
  • $ cd tower_d
  • $ rake
Cool, get the expected:
F

Failures:

  1) TowerD fails
     Failure/Error: fail "hey buddy, you should probably rename this file and start specing for real"
     RuntimeError:
       hey buddy, you should probably rename this file and start specing for real
     # ./spec/tower_d_spec.rb:5:in `block (2 levels) in '

Finished in 0.00038 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/tower_d_spec.rb:4 # TowerD fails

Ok, now to get autotest working...

  • $ autotest
loading autotest/rspec2

Uhoh, it just hangs and doesn't run anything... this is where we run off the rails a bit. Time to read through page after page of conflicting advice based on which version of autotest/ZenTest/rspec/etc we're running.

$ bundle list
Gems included by the bundle:
  * bundler (1.1.4)
  * diff-lcs (1.1.3)
  * git (1.2.5)
  * jeweler (1.8.3)
  * json (1.7.3)
  * multi_json (1.3.6)
  * rake (0.9.2.2)
  * rdoc (3.12)
  * rspec (2.8.0)
  * rspec-core (2.8.0)
  * rspec-expectations (2.8.0)
  * rspec-mocks (2.8.0)
  * simplecov (0.6.4)
  * simplecov-html (0.5.3)

$ gem list autotest

*** LOCAL GEMS ***

autotest (4.4.6)
autotest-fsevent (0.2.8)
autotest-growl (0.2.16)
autotest-rails (4.1.2, 4.1.1)
Hmm... ok, well there's this (rspec wiki) that says for rspec > 2.3 (I'm using 2.8.0) to "make sure you have a .rspec file in the project root. That tells RSpec to tell Autotest to load RSpec’s autotest extension." Jeweler created one already, so that can't be it...

Turns out that you need something like this in a file called .autotest (at the root of your project). The way the wiki is formatted, it LOOKS like it applies to rspec-2.0 – 2.2 only, but it must be for all =/

Autotest.add_hook(:initialize) {|at|
  at.add_exception %r{^\.git}  # ignore Version Control System
  at.add_exception %r{^./tmp}  # ignore temp files, lest autotest will run again, and again...
  at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
    Dir['spec/**/*_spec.rb']
  }
  nil
}

tl;dr: Make sure you have a .autotest file that adds the mapping

Monday, May 7, 2012

Sunday, July 24, 2011

Burn a VIDEO_TS folder to DVD

Suppose you have a VIDEO_TS folder lying around and you want to create a DVD that will actually play outside of your computer...

It's pretty easy to do, tough to remember - just run this command from a terminal window:

hdiutil makehybrid -udf-volume-name <title> -o ~/Desktop/<dvd_name>.iso <location_of_video_ts_folder>


Replace:

'title' with what you want the title of the DVD to be (e.g. 'awesome_summer')
'dvd_name' with the image file name you want (e.g. 'awesome_summer')
'location_of_video_ts_folder' with where your VIDEO_TS folder resides (e.g. ~/Desktop/MyReallyAwesomeSummer)

That will create the iso file in whatever location you specified - in my example, I'd have a file called awesome_summer.iso sitting on my Desktop). Navigate to that file in finder.

Ctrl-click on the ISO and choose 'Open with...' then Disk Utility.

Click on the ISO name from the left-hand side of Disk Utility then click 'Burn'