package playne

imports "programmer"

Category: Programming

  • Writing to the Android Log

    So I just figured out how to get my log messages from a system Golang program into the android log without the need for logwrapper. It is a side effect of importing the “app” mobile package. so… import ( _ “” ) The downside is that *everything* written via stdout will go to the system […]

  • How To: Cross compile Golang for Android

    Update 2022: Since this was back in the Golang 1.4 days and I have now had reason to do this again, the steps are a little easier. For Golang 1.19 I made a handy Makefile Here is a handy Makefile that will build a 32bit binary on an Ubuntu22.04 box

  • Cross Compile Golang on Ubuntu 14.04

    So today I needed to cross compile a basic Golang app from linux/amd64 to linux/arm (for android) on my Ubuntu 14.04 box. It is actually kinda easy sudo apt-get install golang-go-linux-arm because I am running the latest 1.3 golang i needed to run an extra step: cd /usr/local/go/src/ sudo GOARCH=arm ./make.bash Once you have that […]

  • Golang – struct, make and the case of the missing variable

    I made a rookie mistake last night. I forgot an asterisk in my code and it caused me a an hour of confusion! TL;DR – methods on structs in golang need their stuct passed as a pointer if you want to modify it! This works func (f *Foo)SomeFunc() {} This does not! func (f Foo)SomeFunc() […]

  • rails generate Could not find <gem> in any of the sources

    So with my latest project I am using Rails 4.1 – this is all well and good, but here is a gotcha. there is a thing called spring that is supposed to make things faster – except when it gets in the way! tl;dr – killall spring So – here are the symptoms $ rails […]

  • Rails, CanCan and Best In Place editing

    So here is a little gotcha and solution when using CanCan and Best In Place. With the default setup, if CanCan auth fails on a best in place edit you get a redirect to your default “Auth Failed” path and that page then tries to render as javascript. that does not work all that well! […]

  • has_many :through and the case of the missing include

    tl;dr – you need to specify the “inverse_of” option on your has_many/belongs_to relationship to get your children fully populated So I came across an interesting situation the other day, where my includes() statement was preloading data, but then when accessing it I would see another SQL query. require ‘active_record’ class Parent < ActiveRecord::Base attr_accessible :name […]

  • sprintf, floats and rounding

    So I had some fun figuring out why my Spec tests were failing today. tl;dr – do not use floats for currency (BigDecimal will sort you out in Ruby) I was starting to question my highschool math today as I was seeing things like this: php > echo sprintf(“%0.2f\n”, 1.045); 1.04 and irb(main):003:0> ‘%0.2f’ % […]