Technology Musings

May 07, 2013

Platforms /

Why the tabs-vs-spaces debate matters:

Inconsistent indentation: 2 spaces were used for indentation, but the rest of the document was indented using 1 tab.

Everyone - indent with tabs.  Then you can control the indentation using your editor's settings.  DO NOT indent with spaces.  And DO NOT use any programming language or configuration system that cares about indentation.

October 07, 2012

Amusing / A Review of Several Nerf and Nerf-Like Guns

JB

Usually I don't splurge on things like Nurf guns, but our family was challenged to a dual, and I decided we needed to load up.  The kids had been saving money, so they all got to purchase their own gun, and so my only purchase was for my own.  Anyway, I thought I'd post what everyone bought and a short review of each of them.  Here's what we bought:

Below is a picture of all of the guns:

We bought these at Target, and none of them cost more than $25.  In fact, most of them were $10 or less.

The gun with the most "cool factor" was the Nerf Retaliator.  This gun is modular and therefore can actually be transformed into four different styles below:

If you remove the stock and the barrel, you get a very nice basic gun similar to a Skorpion (bottom right).  If you have a stock without a barrel, you get a gun very reminiscent of a UMP45.  If you have a barrel but no stock, it looks a bit like an MP5.  With all of the attachments, it could be really any assault rifle, but it most reminds me of an M4 or FAL.  Now, I should point out, this is pretty much all for show - I didn't detect any advantage of having a barrel attached - but it looks pretty intimidating nonetheless.  

The Retaliator fires well, and with a long range , but is *very* erratic.  In our battle with our friends, I'm not sure I hit *anyone* with this gun.  It is mega-cool, and shoots pretty far, but don't count on actually hitting anything.

The gun that actually shot the best was the Vortex Proton - and I think it only cost $9.  The Proton is one of Nerf's new disc-firing guns.  The disks are Nerf disks so they don't hurt.  However, the disks are *very* aerodynamic, so they actually fly straight!  The Vortex is a single shot, and it takes a little bit to load, but nonetheless I had the best success with it because it was so accurate!  I could be sure to know that the disk would fly exactly to where I aimed it!  The only drawback, as I said, was that it was a single-shot, and didn't even have a spot to hold additional ammo.  So, reloading was problematic because it took time, and fumbling around with ammo was difficult.  I think if you got a multi-shot version of this you would have an amazing gun!  

Another good gun is the Buzz Bee RADS 12.  This is a twelve-shot gun that you pull back on a lever to cock it.  It shoots decently and doesn't cost very much.  Overall I would say that it is a decent purchase, but my 5-year-old was the one to purchase it, and it took too much hand strength to cock the gun.  He could do it, but only if he held it on the ground with one hand and pulled with the other - not very helpful in a gun battle.

The worst gun was the Buzz Bee double-barrel shotgun.  This was not worth buying.  Here are the problems with the gun:

 

  • It takes a *lot* of effor to load the gun.  You have to pull it apart really hard, and it is not always clear when it is fully cocked (pulling it apart is what cocks it)
  • The bullets have to be loaded into "shells" (to make it more realistic).  This is just a hassle.  My son likes this, but it is unhelpful.
  • The shells eject when you pull apart the gun.  Again, this aims for realism, but doesn't help during a battle, and is just more pieces to get lost.  In fact, in this case, they actually seem to be actively trying to get lost.
  • It only holds two shots.  This seems pretty obvious for a double-barrel shotgun, but the fact that it takes so long to load makes this really problematic.
  • It doesn't shoot very far.  It's moderately accurate, but, really, it has an effective range of about 6-12 feet.

Anyway, my 6-year-old likes it because of the "realism", but I think that if we do too many more battles, he will realize the problems with the gun.

The next gun is the Buzz Bee Tek-3.  This is a tiny gun with three shots.  However, it does not auto-rotate the barrel.  Between shots, you must BOTH cock the gun AND rotate the barrel.  However, for a tiny gun, it packs a decent punch and is relatively easy to use.  At Target, they had a 3-pack for $6.  That's right, 3 guns for $6.  It makes a good backup weapon (like a boot gun).

Also in the picture is an older Nerf gun that we already had - I believe it is a Nerf Dart Tag Strikefire.  This is an old gun, but still shoots decently.  It is a single-shot, muzzle-loaded pistol, but also has holding spots for five additional rounds.  This original came with Nerf Dart Tag darts, but I think it can fire most anything.  It works really well as a simple, basic gun.

Anyway, if you are looking for Nurf or Nurf-like guns, I hope this review was helpful to you!

 

October 01, 2012

Platforms / Rails, CoffeeScript, and Java

JB

I *hate* the direction that Rails is moving.  It is becoming a bloated piece of garbage.  I got into Rails precisely because Rails got out of my way most of the time, but was easy to use right where I needed it.  ActiveRecord was a thin shell over SQL.  Therefore, if there was a problem, I could easily diagnose it, because I knew SQL.  It added a few bits of magic, but those were usually pretty understandable.  Likewise with the javascript helpers and the like.  If you needed something done, just pop into Javascript and patch it up.

This contrasted heavily with J2EE.  I used J2EE for a while, but it turns out that if you want to use J2EE you have to commit to it like it's a religion.  If you don't know 20 different platform libraries, you can't even do a hello world in J2EE.  When you finally get it working, you don't know what the heck is even going on.  Some magic is happening somewhere, but it is beyond what is plainly visible.  This, and the fact that Ruby is very metaprogramming-ish, was the reason I chose Rails.

However, starting with Rails 3, the Rails team decided that it was simply going to do everything for you, and everything was going to be done in domain-specific languages.  Thus, instead of the required list of languages/platforms being Ruby/Rails/SQL/Javascript, it has balooned out to Ruby/Rails/SQL/Javascript/Coffeescript/SASS/ECO/Node.js, and probably a few others I'm forgetting.  The asset pipeline is kind of cool, but it's yet another place for things to go wrong.  I think the anti-CSS measure of auto-h()ing code is terrible.  If you wanted to go that way, instead you should use Perl's taint feature, and just give errors if you display tainted values.  The idea that random code should transform my strings is horrible.

Finally, I understand the reason for getting rid of the javascripty stuff from rails core, but some of those were really what made the platform really rock.  I think they have missed the mark - they put the ease-of-use in the wrong places, and instead have made sure that no one that doesn't have a relgious commitment to the software stack will ever find it usable.  It has basically gone the way of J2EE, and I am now looking for a new platform to love.

September 23, 2012

General / Today's Thoughts on Algorithmic Information Theory

JB

I know this won't make a lot of sense to most people, but I thought I needed to store these thoughts in a more permanent place before I forget them.  I've been reading a paper today on Algorithmic Information Theory, and it make me think these thoughts (most of which are probably ill-founded):

 

  1. Is the Chaitin halting probability really a probability?  In other words, if I have the first 5 bits of omega, does this mean that a random sampling of all programs will really match this value to some extent?
  2. To what extent is self-delimiting programs an intrinsic part of AIT, vs just a cheap trick to get the math right?  It makes sense simply because you need the program length.  But on the other hand, if omega is a probability, it seems like having the program length pre-coded would do a number on its interpretation as a probability.
  3. If log2(2^w) is w, is perhaps log2(w) = c?  Is c the complexity number I'm looking for for my axioms?
  4. Is it possible to express the idea of a formal relationship to be the relationship between the algorithmic specification and its logical depth?  I.e. we should expect a material cause when logical depth is low, but a formal one when logical depth is high?  Could this be expressed as a ratio?
  5. Algorithmic complexity on partial specifications.  The word "red", as implemented in 12 pt font or written in the clouds.  Perhaps the partial specification is something that can be detected non-algorithmically, via an Oracle machine?  In other words, instead of "give me the Xth object that matches specification X, you say, give me *an* object that matches specification X.  It does not require an iteration over the whole of infinity, but a potentially large part of it very quickly.  Or, perhaps, it drops it a level of Cantorian infinity.
  6. Recognizers vs generators = P/NP problem = logical depth vs algorithmic complexity
  7. What is the relationship between the constant given in AIT vs expressibility of language?  In other words, if C is small, then it is easier to express random strings, at the penalty of having no easily expressible strings.  A larger C will permit more compressibility.  This might also be usable, at least in theory, to determine the total number of "special" strings available.
  8. How can algorithmic information theory be expanded for programs that take arguments? (note - number of arguments shouldn't matter, only whether one of them is itself a program, perhaps? or if the result is a program?  Maybe what the Wolfram class of the argument is?)
  9. Might semantics and apobetics be higher Turing degrees?
  10. Might ethical norms be an expression of compressibility across Turing degrees?
  11. What about bad plans?  Is it possible to state, even in abstract, non-determinable terms, what a bad plan is?

 

August 15, 2012

Platforms / Autoreleased with No Pool in Place

JB

Before Apple's ARC, you would often have to manage memory semi-manually.  Before operation queues, you would also have to manage setting up autorelease pools on new threads.  If you didn't, you would get an error such as:

autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

However, the other day, I started getting these myself!  I was a little shocked - what on earth was I doing that required an autorelease pool?  Well, eventually I figured it out.  It turns out that if you have custom +load() functions on your classes (these get called whenever the classes load - I use them for registering handlers and such), this is another situation in which you have to set up your own autorelease pool if you do any object creation. 

So, in your +load() function (or, depending on what you are doing, in functions that +load calls), just wrap it with

@autoreleasepool {
Your Code Here
}

And it works!

August 05, 2012

Snippets / Simple Sage Plots for Teaching Functions

JB

I'm teaching calculus to some homeschool students this year, and I wanted to have a bunch of function plots printed out to show them.  Therefore, I turned to Sage, which I have never used.  It is great!  You have to know a few other math software pieces to really understand it, but it's not that bad.  Someone needs to do a general "how to use sage", and some day I might.

Anyway, here's my quick function for plotting graphs for students that some of you might like.

In one of the evaluation boxes, type the following:

def simpleplot(f, range=(-5,5,-5,5)):
p = plot(f, (x, range[0], range[1]))
p += text("$" + latex(f) + "$", (0, range[2] - (range[3] - range[2]) * 0.1), fontsize=30, rgbcolor=(1,0,0))
p.axes_range(range[0], range[1], range[2], range[3])
show(p, figsize=12)

What this does is create a function called "simpleplot" which will do the following:

  • Plot the given function on a default domain of -5, 5
  • Typeset the function using LaTeX, and insert the function slightly below the graph (I calculated it at 10% of the graph size).  It prints in red at 30 point size.
  • Set the axes to be -5, 5, -5, 5 (I used uniform axes on all the functions so they can compare the differences between graphs easier)
  • Draw the whole thing at 3x the normal size (figsize=12 - default is 4).

Now, I can just do:

simpleplot(1/x)

And it gives me my output!

July 23, 2012

Snippets / DVD Rescue! Getting files off of an unfinalized DVD

JB

Just wanted to shout out and say thanks to Flay for saving me!  I had a DVD that I forgot to finalize, but Flay had a nice set of instructions for how to manually copy off the files from the DVD drive.

Now I can finish editing and posting the videos for the Engineering and Metaphysics conference.

July 13, 2012

Platforms / iOS Bug - insertNewObjectForEntityName: deleteObject and rollback

JB

I've been chasing down a wierd bug where, on an NSManagedObjectContext, the hasChanges method keeps returning YES even after a rollback.  It turns out, if you do the following sequence, hasChanges will *never* be cleared:

MyClass *c = [NSEntityDescription insertNewObjectForEntityName:@"MyClass" inContext:ctx];
//Do other stuff
[ctx deleteObject:c];
// Do other stuff
[ctx rollback];
[ctx hasChanges]; // Returns YES!

In my own case, I got around it by not deleting the object, and just rolling back if I wanted it gone, but that won't work for everyone.  So, I did:

MyClass *c = [NSEntityDescription insertNewObjectForEntityName:@"MyClass" inContext:ctx];
//Do other stuff
[ctx rollback]; // Don't delete! just roll back
//Do other stuff
[ctx rollback]; // Now it works
[ctx hasChanges]; // Returns NO like it should

May 12, 2012

General / Why I Won't Be Participating in StackOverflow.com Anymore

JB

I have historically been grateful for stackoverflow.com, but I think that perhaps they may be getting overly full of themselves and self-conscious.

I have long used their site to get answers, especially to iOS questions.  It always seems that someone answers any question I might have.  I've always wanted to give back, but found that nearly every questions someone else has already answered.

So the other day I was trying to figure something out, and the answer on StackOverflow was that it was not possible.  I spent a day messing around, and actually figured out how to do it (read about it here).  So, having spent most of the morning trying to find if anyone had accomplished this, I actually found three different StackOverflow.com questions pertaining to it, as well as several sites on the Internet.  So what did I do?  I decided the best way to let people know about the answer was to write a blog post about it, and then point people to the blog to find the answer in each question.  This was going to be my way of giving back.

So what happened?  Well, two of my comments got deleted from StackOverflow, and one had a comment from a moderator attached accusing me of self-promotion!!!!  Because I solved a problem that had been outstanding for a year, and told people the answer!!!!

So, in the future, I will just post to my blog, and leave StackOverflow out of it.  You can come here for the answers.  I don't have enough brain space to deal with that kind of junk.

May 10, 2012

General / Engineering and Metaphysics 2012 Conference

JB

For those interested in engineering and theology and philosophy, this conference is for you!  I've got two talks slated for the conference - come and listen!  Lots of fascinating stuff from a number of disciplines:

www.eandm2012.com

You can see the abstract list here and the conference flyer here.