• A Little Bit More

    Had to fill my garbage cans again, so I took out a cabinet. Now I need to put a valve on my gas line, so I can disconnect the stove. And then it will be time to get rid of the sink. At that point, I’ll be sad because washing dishes will be a pain. (I’m thinking I’ll just go and buy paper plates and cups.)

  • A Fun Vacation

    I signed up to the Five Boro Bike Tour in NYC over last weekend. I took my folding bike on Amtrak and it was a pretty good trip. It would have been great, but Amtrak is definitely not the way to travel. (Next time I want to go somewhere on a train, I first need to go to Europe.) As this was my first vacation in a while, I was very much looking forward to it.

  • Little vim tricks

    Our datalogger saves files in a windows format, which means when I open it in a unix program, I don’t see any line feeds. The quick solution to this is to open the file in vim and run:

  • Little More Work

    I took the morning and tried to take down a bit more of the wall in the kitchen. It was nice being able to stand on the counter to reach the high parts. Here’s how things look now.

  • Libv8 Gem Problems

    I had some problems installing the libv8 gem after installing ruby 2.0. The solution was to use yum to install the python26 packages and then make a link from them to /usr/local/bin/python. After that the gem install libv8 command worked.

  • Requiring https

    My apps tend to just be electronic sign-up sheets for various events. There’s no way we’re going to pay for an SSL certificate for a site that will probably be up for a month or two, at most. However, we do require people administering the page to login, which means passwords which need to be encrypted. That’s really all I care about encrypting, not the entire site. So, my somewhat simple solution is:

  • More Capistrano

    Capistrano used to have a pair of tasks called deploy:web:disable and deploy:web:enable that I really liked. All they basically did was to upload a file to the webserver that would be displayed while a new version was deploying. I thought this was really helpful because if anyone visited the site during the deployment, they’d see the message that the site was under maintenance. Without this file, visitors to the site would see a cryptic rails rack error that made no sense. Sometime last year, after a capistrano update, I realized that these tasks were no longer there. By that time, I had understood that it was just uploading a file, so I could duplicate the tasks manually by editing a file to add the current time and then uploading it to the webserver. (In either case, I had to modify my httpd.conf file to reflect the location of the file.) Then, after the update, I’d remove the file. This wasn’t difficult, but it was WAY easier to do this:

  • 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.