Feb 072013
 

Why are these things always so weird? Someday I’ll understand why OSX is set up that way. And on that day, I’ll probably weep.

$ sudo /usr/bin/dscl . -append /groups/wheel GroupMembership username

This was found here : https://discussions.apple.com/thread/1230828?start=0&tstart=0

Feb 022013
 

More to the point, should Rails die?

Rails brought a lot of great things – it made it dumb easy to package an entire app together. It abstracted the complexity of the storage layer. It created an entire market. Things like Heroku, Railsonfire/codeship and other companies turned a profit by extending the benefits of Rails. And things like Capistrano were born.

Everything that can be automated should be automated.

 

This has brought great things. And people wrote more tests, and life was good. But then, Rails apps grew, and people realized they had written them badly – because they interleaved their code within Rails, instead of using Rails as a layer and building their code on top of it, carefully segmenting the access points to that layer. Gosh, that sounds like work! Enter things like Avdi Grimm’s Object On Rails. And the Rails community re-learns things that the Java community has suffered through and grown past. Dependency Injection is making a comeback, Ruby-style. People use TDD as an indicator of design smells – if you have to boot up Rails to run your tests, you’re doing something wrong! Although of course SOME tests require the entire Rails stack, but we call these Capybara tests, because “end-to-end” is ugly, and capybaras are much prettier to look at.

And then, on the other hand, you have Sinatra, and Backbone.js, and other things that are focused on doing one thing and doing it well.

Now we have everything that Rails has taught the Ruby world – segment your logic, stay away from expensive code (the only currency here is time, and this is a very important thing to realize). Your TDD loop should be very short – you can watch some of Gary Bernhardt’s screencasts on Destroy All Software to learn mor about this. We have Capistrano, and Capybara. We have RSpec. We have Opal, a Ruby-to-Javascript compiler.

And in case Opal is too weird for you, you’ve got the Backbone.js world, where you have to make all these exact decisions over again.

You’ve got Sinatra, a wonderful “controller”. Sinatra is a great place to put your API and test it. Because that is the only thing Sinatra gives you, you feel the pain every time you add something — you have to add it.

And your storage is now distributed. Imagine … Backbone.js front-end, Sinatra in the middle, and your distributed storage of choice on the other side: Google Drive, Apple Cloud, Dropbox, MediaFire … You pick it, you store to it. Users now carry their data everywhere. Virtually speaking, of course. Gosh, sounds like you’re even reducing costs.

 

So now, we face the challenge the health world has been trying to solve for over a decade – how do you share information between proprietary systems? After all, the user is the one who’s suffering.

This is an entirely different blog post – how much of “your” data really is yours? How much could be shared? You know.. Like one of those virtual business cards, I suppose. You’d have a JSON object behind a secure server where the user stores THEIR information, and you ask for permission to read that one object.

Jun 112012
 

If you’re using Devise and rspec on Rails 3, and you want to override a controller, and you end up with an error that makes no sense whatsoever:

“Undefined method ‘name’ for nil:NilClass”, well then, you probably want to add the following line to your tests:

@request.env["devise.mapping"] = Devise.mappings[:admin]

Yeah… That took me way longer than expected.

On a COMPLETELY UNRELATED SIDE NOTE, pry is pretty cool when you end up having to step through code…

Apr 112012
 

Here are the things you need to know about using any new font for Rubymine:

  1. It needs to be Unicode
  2. It needs to go into the $JDK_HOME/jre/lib/fonts directory

That is absolutely it. The last thing is the Monaco font, which I have attached for your downloading pleasure. It turns out DejaVu Sans Mono just isn’t as nice — however nice it may be — and Inconsolata XL doesn’t quite do it for me either.

Jan 062012
 

Ruby has a neat feature called at_exit which takes a block and then executes the contents of this block when the program ends. There are a couple of VERY important details:

  1. It takes a block and converts it into a Proc object at the time of parsing. This means that the data has to be available in the binding, or you’ll run into errors. Example: instance variables need to be set before you can use them in that block. Better idea: don’t use instance variables in there at all.
  2. You can ‘chain’ at_exit calls, and they will be resolved in a First In, Last Out (FILO) order.

Once you know this, using at_exit and writing tests for it becomes a little easier:

class Piddler
   def initialize
     create_pid_file
   end

   private

   def create_pid_file
     pid_file = "/tmp/piddler/my_pid" #Simplified for example purposes
     File.new(pid_file, 'w')
     at_exit { FileUtils.rm_f pid_file }
   end
end

What you’ll notice is that the at_exit block is defined RIGHT AFTER I create what I will need to resolve/undo/finish – not separately, right inside the method.

 

def test_clears_pid_file_when_it_exits
   at_exit { assert_equal 0, Dir['/tmp/piddler/*].size}
   Piddler.new
end

The advantage of that is that I know exactly when it gets defined. For this example, it gets defined at the end of the ‘initialize > create_pid_file’ call. This means that any at_exit blocks defined BEFORE that will be resolved AFTER.

 

May 102011
 

I just moved into a new apartment where the AT&T reception is, well, atrocious. Still, I like AT&T, so I’m dragging my feet to switch to Verizon (or something else).

Today, I spoke in live chat to some AT&T employee. I believe the name was Monica Garnett but I could be wrong — and it probably doesn’t matter. My issue was that I didn’t seem to have a mailbox for my phone number. She says my data plan is unsupported for smart phones.

… Wait, what? I’ve been using this data plan for over a year with this phone. Maybe I never got voicemail, but who cares! It WORKED. I had unlimited text and unlimited data. Now, yes, I know, this plan had been removed and AT&T wasn’t offering it anymore, but I am an existing customer, I get the perk of keeping that, right?

… No. I was told I could switch to their 200Mb/month or 2Gb/month plan, which I did, but what I wasn’t told is that THESE PLANS DO NOT INCLUDE MESSAGING.

Now, I want to fix this. I got screwed by a company, big whoop, whatever, I’ll just limit myself a little. THE WEBSITE DOES NOT GIVE ME REASONABLE OPTIONS. I can get unlimited text, or unlimited text with any mobile-to-mobile calling, or 1000 texts.

I could pay $15 for 200 megs and $10 for 1000 texts, and then I’d have $25 — which is, $5 less than unlimited data and unlimited texts. Huh. NO.

I could pay $25 for 2Gb and $10 for 1000 texts, or $20 for unlimited texts. So .. $35 or $45? NO.

Seriously? So I have to pay MORE now to have LESS than I used to have? Well, goodbye, AT&T. Guess who’s going to go say hi to another phone service provider tomorrow?

Feb 052011
 

Scrivener is a wonderful OSX app for writing basically anything you want (novels, plays, theses, etc). There’s a beta out for Windows. As it turns out, they’re actually developing it using the Qt toolkit.

The Windows Beta runs on WINE, if you do a bit of work. I am getting all my information from a Lifehacker tip, just rewriting it and adding some more information for those who don’t know enough.

  • Install WINE — version 1.3.5 or higher.
  • Download winetricks
    $ wget http://winetricks.org/winetricks
  • I also recommend installing the ‘cabextract’ tool, as indicated in the previous link.
  • run winetricks and install the following runtime libraries:
    $ sh winetricks vcrun2008 vcrun6 quartz dotnet20
  • I did not need to do this, but the link also recommends downloading qsvg.dll and qtsvg.dll and copying them to your ~/.wine/drive_c/windows/system32 directory. I’m not actually sure where to find these, and installing Scrivener created a qsvg4.dll file.
  • Finally, install and run the Beta.

Let me know if you run into any issues following these instructions.

May 112010
 

If you happen to use Gentoo on a Notebook, you may already know this. If not..

At the time of this writing, If you have a Poulsbo video card (another craptastic Intel invention) do _not_ upgrade to xorg-server 1.7. Stay on 1.6.5-r1 or whatever you have. If you upgrade, xorg will just refuse to work for you, and downgrading is kind of a pain.

If you have upgraded already, then here’s what to do:

http://bugs.gentoo.org/show_bug.cgi?id=290679#c4

After doing this, you’ll need to also mask >xorg-server-1.6.5-r1, then re-install the old xorg-server, and finally re-emerge everything you have installed from the category x11-drivers.

Have fun!

Mar 312010
 

Hooks are a fascinating bit of Ruby magic. They are methods you can define with actions to run when something happens. You can put triggers in your code.

This blog post explains them very well; and for more information, get “Metaprogramming Ruby”, which is a great book – not only about the callbacks, but about a host of information.

%d bloggers like this: