• Spoke Too Soon

    When I came home from work, I was feeling a little full of myself and then I wrote my previous blog post. I spent the past couple of hours watching some Railscasts that were really informative, on using capistrano to do all sorts of things. So I changed my capistrano file quite a bit and do feel that I understand it a bit more.

  • Advancing

    Today, I started a new ruby on rails website for a workshop. It’s a very basic site that just handles registrations and redirects people to the credit card processor that we use. This is the main type of website that I write in rails and it’s probably my tenth site that I’ve written for this purpose. Previously, I had always used scaffolding in rails and then deleted the stuff that I didn’t need. This time, I made a conscious choice to not use any scaffolding and instead generate my own controllers and models. I’m happy to say that I didn’t have any real problems. So I’m thinking that I’m no longer a complete beginner with rails. I might even go so far as to say I’m an intermediate rails programmer. Which means it’s time for me to start advancing some more. I found this website http://learn.thoughtbot.com and was thinking of signing up for the prime program. The intermediate ruby on rails workshop looks pretty interesting. Though, after reading the syllabus, I’m thinking that perhaps I was at intermediate level a while ago. In the listing of things that they plan to cover, I already know a few:

  • Little Work

    My organizing kick really tired me out. I slept for a very long time and didn’t feel like doing anything today. But I felt I should do something today, so I decided to just finish taking the drywall off the back of the kitchen. It didn’t take long, but since I was already tired, it pretty much finished me for the day.

  • Organizing Kick

    Since I was doing a bit of organizing at work this week, it has carried over to my house. This is not a mood I’m usually in, so I decided to take advantage of it and do a little work on my basement. My basement needs a lot of work, so this put a very small dent into it. I’d say I cleaned up about a quarter of the basement. And I’m pretty happy with that.

  • A Few Good Hours

    I woke up and decided I better get started. So, down came the upper cabinets, except for the one with the vent going outside. I’ll do that later.

  • It Begins Again

    It’s March and I’ve finally saved up enough (I hope), so I started work on my kitchen. Here’s a shot of the first two cabinets I took down.

  • RHEL6 No graphics, error: could not open default font ‘fixed’–SOLVED

    After some updates from RHEL6, some users were having problems with X not starting. Looking at the log file, I saw this error:

  • Ruby 2.0 with Other Versions

    Ruby 2.0.0 came out today and I thought I’d install it. I had been using rvm to handle my multiple versions of ruby, but when I tried to do a rvm install 2.0.0, I got a bunch of errors about homebrew. It seems as though homebrew is now required. This is a problem for me because I’ve been using MacPorts for years and I just don’t feel like switching right now. So, I figured that I’d just see if I could compile it myself by hand and come up with a way to have multiple versions of ruby. The thing is, I really don’t switch between versions all that much. I will now, as I slowly convert all the sites I have to 2.0. So I’ll need to go back and forth a little. But once it’s done, I probably won’t switch for a long time. I’ve been on 1.9.3 for a very long time and it worked fine. Anyway, I’m not exactly sure how I’ll do this, but I’m going to give it a try.

    First step, was to update XCode and then go into Preferences and update the command-line tools. In the ruby download, my config command was pretty basic:

    ant:ruby-2.0.0-p0 $ ./configure --prefix=/Users/maryh/Software/rubies/2.0.0-p0
    

    Putting everything in a Software/rubies/version directory seems to be a good idea. I could be completely wrong about this, but that’s how I’m starting. My first make attempt failed with an error like this:

    compiling ./missing/setproctitle.c
    compiling dmyext.c
    linking miniruby
    /Users/maryh/Downloads/ruby-2.0.0-p0/lib/fileutils.rb:111: [BUG] Stack consistency error (sp: 38, bp: 36)
    ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
    
    -- Crash Report log information --------------------------------------------
    ...
    

    I needed to set CC=clang (it was CC=gcc-4.2) and that fixed this problem.

    New error:

    compiling readline.c
    readline.c:1688:9: error: use of undeclared identifier 'username_completion_function'; did you mean
          'rl_username_completion_function'?
                                        rl_username_completion_function);
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                        rl_username_completion_function
    readline.c:75:42: note: expanded from macro 'rl_username_completion_function'
    # define rl_username_completion_function username_completion_function
                                             ^
    /usr/local/include/readline/readline.h:449:14: note: 'rl_username_completion_function' declared here
    extern char *rl_username_completion_function PARAMS((const char *, int));
                 ^
    1 error generated.
    

    Readline errors are apparently common. Again, I’m pretty sure this is related to the fact that I’m using MacPorts. My fix was to:

    ant:ruby-2.0.0-p0 $ export LDFLAGS="-L/opt/local/lib"
    

    Then rerun configure and make and things worked. Everything is installed in /Users/maryh/Software/rubies/2.0.0-p0. And the gem environment is:

    ant:bin $ ./gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 2.0.0
      - RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [x86_64-darwin12.2.0]
      - INSTALLATION DIRECTORY: /Users/maryh/Software/rubies/2.0.0-p0/lib/ruby/gems/2.0.0
      - RUBY EXECUTABLE: /Users/maryh/Software/rubies/2.0.0-p0/bin/ruby
      - EXECUTABLE DIRECTORY: /Users/maryh/Software/rubies/2.0.0-p0/bin
      - RUBYGEMS PLATFORMS:
        - ruby
        - x86_64-darwin-12
      - GEM PATHS:
         - /Users/maryh/Software/rubies/2.0.0-p0/lib/ruby/gems/2.0.0
         - /Users/maryh/.gem/ruby/2.0.0
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :backtrace => false
         - :bulk_threshold => 1000
      - REMOTE SOURCES:
         - http://rubygems.org/
    

    So, now I think I can just install gems there and see how things go.

  • More Ruby Notes

    I just found out that these two ruby commands do the same thing.

  • Rails3 form_for vs form_tag

    I’ve been advancing a little in my rails work, to the point where I’m making more elaborate forms. So I’ve had to switch to using form_tag instead of the form_for that’s the default when you use scaffolding. I have a pretty good understanding of the differences now, so I’m documenting it here.

  • Sendmail on Mac OS X 10.8

    I wanted to use sendmail to test the sending of some messages in one of my apps. The command I wanted to run was:

  • Ruby File Open Options

    I spent a little time looking for this info, so I thought I’d post it here. Use it like this:

    File.open("#{output}","a") do |w|
      w << "#{Time.now.to_s(:datetime_stamp)} Other text to write
    end
    

    Remember if you use File.open or CSV.open with a block, the file is automatically closed when the block closes. Otherwise you have to close the file.

      Mode |  Meaning
      -----+--------------------------------------------------------
      "r"  |  Read-only, starts at beginning of file  (default mode).
      -----+--------------------------------------------------------
      "r+" |  Read-write, starts at beginning of file.
      -----+--------------------------------------------------------
      "w"  |  Write-only, truncates existing file
           |  to zero length or creates a new file for writing.
      -----+--------------------------------------------------------
      "w+" |  Read-write, truncates existing file to zero length
           |  or creates a new file for reading and writing.
      -----+--------------------------------------------------------
      "a"  |  Write-only, starts at end of file if file exists,
           |  otherwise creates a new file for writing.
      -----+--------------------------------------------------------
      "a+" |  Read-write, starts at end of file if file exists,
           |  otherwise creates a new file for reading and
           |  writing.
      -----+--------------------------------------------------------
       "b" |  Binary file mode (may appear with
           |  any of the key letters listed above).
           |  Suppresses EOL <-> CRLF conversion on Windows. And
           |  sets external encoding to ASCII-8BIT unless explicitly
           |  specified.
      -----+--------------------------------------------------------
       "t" |  Text file mode (may appear with
           |  any of the key letters listed above except "b").
    
  • Drop a Column in MySQL Table

    For some reason, my migration file wouldn’t drop a column when I tried to go back to an earlier version. I fixed this by just going into mysql and dropping the table manually.

  • Simple Dropdown Menu of Numbers

    Every so often I need to make a simple dropdown menu of numbers in my app. And for some strange reason, I always seem to forget how to do this. So here are some examples for myself to use when I forget the next time.

  • Update Multiple Boolean Attributes in Rails3

    We are hosting an event where students need to submit two pieces of paper and pay to attend. The model I’ve created has three boolean values for these three items: safety_waiver, image_waiver and paid. As the forms and payments come in, I could manually edit each entry and check off who has paid or not. But, since I’ve done a few of these events in the past, I know it would be easier if I could just see a list of everyone who hasn’t paid or turned in their waivers and check a bunch at once. I tried following Railscast #52, which was great and almost got me there, but didn’t work for me in the end. So here’s what I did.

  • A Bad Habit

    Until yesterday, I had been carless for the past few weeks. Even though it was ridiculously cold, if I wanted to get to work, I’d do my bus-el-bus trip to get there and then reverse it to get home. In all honesty, this wasn’t that difficult, though it was rather cold this week. One of the things that I had thought about, when I bought my house, was that I didn’t want to be dependent on a car. So, I can take public transit to work, I can walk to a grocery store or other stores that I might need. Now though, that I have my car back, I was just thinking that I’ll drive over to Target this morning to pick up some stuff. This is ridiculous. Last week, I would have (and did) just walk there. There was a talk in the evening the other day downtown that I wanted to hear. So, even after I took public transit home, ate dinner and was a bit tired, I bundled up again and walked to a different el stop to take the train to go to the meeting. Now, I’m being a total weenie and want to drive to a store that’s maybe a mile away, but probably less to buy some things that aren’t even heavy. I am completely ashamed of myself. This is a habit that I need to break and I’m not sure how I’ll do it. But, I’m going to try and be more aware of when I instinctively think to just get in my car and drive. More immediately, I’m going to put on my boots and coat and walk over to the store. Self, quit being such a wuss!

  • FUN!

    My brother convinced me to buy a mountain bike on Friday and we went up to Kettle Moraine on Saturday for a ride. I was a bit nervous, hoping that I wouldn’t hurt myself, since I’d never done anything like this. I love riding my bike, but I usually stay on pavement, which makes the riding pretty easy, even in traffic. Since there were a few of us who had never done it before, we went on an intermediate trail of about 4 miles. It was about 41 degrees, which wasn’t bad, but it was totally muddy. And I have to be honest, I haven’t gotten that filthy in a long time and it was fun. Since it was so muddy and a bit chilly, I couldn’t take too many pictures because it was a pain to take off my gloves and get the camera out. But here are a few shots from the day.

  • Rails and Autocomplete

    I recently wrote a simple rails app to let people record measurements (current and voltage) on for a given plate. Each plate can have many measurements and each measurement belongs to only one plate. I wanted to make it easy for people to enter the data and there might be a fair number of plates, so I didn’t want people to have to scroll down a long drop down menu to pick a plate. This seemed like an ideal situation to use autocomplete on. Basically, the home screen is just the new measurements path. So, putting in the measurements will be easy. I then wanted to have a text field for the plate name that has autocomplete enabled. As the user enters in information for each plate, a little drop down list will popup that users can use to pick the correct plate. And if it’s a new plate, it will automatically add it to the database.

  • Coffeescript is Whitespace Sensitive

    I’m attempting to get autocomplete working on a rails app. I’m basically following the instructions in Railscast #102 (revised). It wasn’t working because I didn’t realize that coffeescript was whitespace sensitive. Once I realized that, I thought I was set, but I wasn’t. I like having my tabs be two spaces, but coffeescript wants four space tabs. So after I doubled all of my tabs, things started working.

  • Context

    There are a number of blogs that I read, almost daily. I know a lot of people do this and many do it by subscribing to the RSS feed of a given blog. I am not one of those people. Why? I like to see the information in its original context. RSS readers strip everything off the webpage except the text of the post. So just by glance, I can’t tell which website the post came from. I don’t like this at all. I prefer to read the text on the original site that the author created. Why? It helps me to remember where I read the information. A typical example, just the other day, I was thinking that there was a book I was interested in reading because I had read about it on some website. It was a somewhat technical book, so it could have been reviewed on any number of sites that I visit. However, I couldn’t remember the title and I didn’t think it was an actual review of the book. I was something written by the person who wrote the book. I remembered liking the post, but all I could remember was that I had read about it in December and it was to be published in January. Now that it was January, I wanted to remember it to see if I wanted to buy it. After picturing the article, I remembered that it was on the NY Times website. I like that my brain still had the connection of where I read the article. I supposed if I read it in an RSS feed (which I don’t even know if the NY Times provides), I could have looked there somehow. But I think it’s good for my brain to still be making connections like this. It’s probably more inefficient to read blogs this way, but it’s my preferred way. And I’m also not a fan of making everything more efficient. Inefficiency is good. But that’s a post for another day.

  • To 2013

    Here are my goals for 2013. A lot of the same things as last year, but hopefully I’ll get further along with them.

  • 2012 in Review

    Being the last day of 2012, I thought I’d take a minute and check out how I did with the goals I set for last year.

  • Kindle/iPad/ebook Reader Issue

    I just purchased a book on Amazon to read on my ipad. Unfortunately, I have a number of different email addresses and I ended up using an email address that was different than the one I used to set up the Amazon app on my ipad. So the only way that I can read the book I just bought is to deregister the app with the old email, which will delete all the books that I currently have and then reregister with the new email address that I used. I did that and now have a single book in my ipad app, which is the one I just bought. If I want to get back the others, I have to repeat the process and go back to my old email address.

  • Ruby and Ldap

    I’ve been rewriting a script I use that lets people update their linux and samba user passwords at the same time. Our server uses samba and openldap to behave as a primary domain controller for our windows computers and a single sign-on for a few other services. It’s been working great for years and way back when we started using this, I wrote a perl script to take care of keeping the two passwords in sync. The original problem was that if you use the regular linux passwd command, the linux password will change, but the samba one will not. The samba password uses an nthash. In a given user’s ldap account, there is the userPassword field which holds the linux password and the sambaNTPassword field which holds the samba password. For a user to be able to use any of the web services we run on the server and login to any of our windows computers with the same password, these two fields need to contain the same password.

  • Hidden ~/Library Directory

    Mac OS X 10.8 (I think 10.7 too) hides the user’s Library directory by default. This is annoying. To automatically make in show in Finder, run this: