Archive of posts with category 'Computing'

HP Color LaserJet 5525dn Broken Network Port

At work, we have an HP Color LaserJet CP5225dn printer, which I love. Last year, our network card stopped working. I bought an external print server that sort of worked. For computers where the printer had already been set up, it worked ok. But new windows printers couldn’t add it properly because it couldn’t reach the printer to get the settings. As an example, it would say it was a black and white printer instead of color. And there was no way to override these settings.

Apache Redirects

I should have done this years ago, but I finally set up an automatic redirect from all http websites to https. If the https stuff is already configured correctly, just need to add the following. I put it in my vhosts file.

Ruby Openssl Version

There is a problem if I use a version of ruby with a newer version of openssl than what is on the server. Here’s the command to find out what version of openssl that ruby is using.

Learning DragonRuby

I was on vacation this week. So I had some time to do anything I wanted. For a while now, I’ve wanted to try to create a simple game. I’ve also wanted to learn how to use DragonRuby, which I purchased last year. Then, I found these videos. The guy made a basic tetris clone in a couple of hours. I figured I’d give it a try and see what I could do. Needless to say, it took me a bit over two hours…more like five or six over a couple of days. But I eventually got the game to run. My game has more bugs than the game in the tutorial. Mainly because I didn’t exactly know what I was doing and because I was trying to copy the code from the video, which was hard to read. I tried downloading his final code to compare it to mine, but I couldn’t find it. If I wanted to spend more time to figure out my mistake, I probably could. But the main thing I wanted to learn was how to go about making a game and how to use the DragonRuby workflow. Even with my buggy final game, I definitely learned more about those two things. So I feel like this was time that was well spent.

Using a Barcode Scanner

I got a Tera 1D Barcode scanner at work. What I want to use it for is to be able to scan a barcode on a circuit board and then print out more labels with barcodes to stick on the boxes that we’ll be shipping them in. I also have an old iMac that I’m going to use for this project, along with a Brother QL 550 label printer.

MacPorts, gems and ruby notes

I’ve had a number of issues with my macports, ruby and rails setup after I updated the OS to 12.1. First I want to document some things that helped me to figure out some of my problems.

Downgrading MacPorts Packages

I use macports (not homebrew) as my package manager on my mac for some software that I need to use with Ruby on Rails. From time to time, I’ll get an error like this when I try to start a rails server.

Finally Done

It basically took all day today to sync the files from my laptop to my new coldandheartless server. It took me a bit longer than it should have to create the new linode because I was stupid. I forgot that I had used letsencrypt to get certificates for the files. And I forgot to open the https port and then spent way too much time wondering why the websites didn’t work.

It's Up!

I finally finished editing all of my old posts that had absolute paths to images in the urls. And I edited all the paths in my image galleries, which thankfully had relative paths. So it was pretty easy to fix.

Welcome to Jekyll!

I’ve changed my website from basically a wordpress blog to a jekyll site. Wordpress has a lot of extras that I just really don’t need. The main one being a database. I’m pretty comfortable with html, css, etc. and I can learn markdown, so I think jekyll will be pretty easy.

Nice Windows 10 Trick

To find the info about a motherboard in a windows computer, open a terminal and run this:

Squirrelmail Certificate Issues

We had a certificate update at work that screwed up my ldap system. I fixed that by creating becoming my own CA and creating some self-signed certificates. This fixed everything except squirrelmail, which was still referencing the old certificate which had expired.

RHEL7 Server and mod_ldap Missing

I have an RHEL7 server that uses mod_ldap. When I ran updates yesterday, I got this error:
<br /> ...snip...<br /> --> Finished Dependency Resolution<br /> Error: Package: mod_ldap-2.4.6-90.el7.x86_64 (@rhel-7-server-optional-rpms)<br /> Requires: httpd = 2.4.6-90.el7<br /> Removing: httpd-2.4.6-90.el7.x86_64 (@rhel-7-server-rpms)<br /> httpd = 2.4.6-90.el7<br /> Updated By: httpd-2.4.6-93.el7.x86_64 (rhel-7-server-rpms)<br /> httpd = 2.4.6-93.el7<br /> ...snip...<br />

Making a Windows 10 Bootable USB Drive

I’m trying to update some computers to Windows 10. I have an iso file with windows 10 on it. I could write it to a dvd, but most of the computers I’m updating no longer have dvd players. I’d like to write it to a usb drive and boot from that. Over the past few days, I’ve found that this is a problem with windows 10 because there is one file, sources/install.wim that’s over 4gb. My systems will only boot from a fat or fat32 partitioned drive. On those drives, 4gb is the maximum file size. I also normally work on a mac, so I was trying to find a way to make these bootable usb drives on my mac. I was not successful. The key to making this work is to use a windows program called split-windowsImage. Here’s what I did, though making the NTFS filesystem on my usb drive was not necessary.

Network Cards and Device Names

I know there’s a page on the Red Hat website that explains the new network device names and how they’re created. But, for me, a concrete example that I worked with is always much better. I set up a new server yesterday and had some issues with a fiber network card, so I thought I’d write up what I learned.

Ruby Gem Error

I’ve been doing a bit more work with Sinatra and I got the following error. I’m just documenting how I fixed it.

My First Sinatra Project

I have a wufoo form that I’m using and I want to automatically see the results on a webpage. One of the hangups of this process is that I can’t put any script on the webserver. But what I can do is embed an iframe. So I could download the information that I wanted from my form to another server and then display that page in the iframe. My question was what to run on my second server, which I’m going to call my results server. All it really needed to do was get the results and then show them. So using a ruby on rails app for this seemed to be overkill. After reading about it, sinatra seemed to be the perfect fit. I could still use ruby and just show the results I wanted. This seemed to be the perfect project to test out sinatra.

Connecting to a Windows Remote Desktop from Linux

Our linux systems have xfreerdp installed. We can use that to connect to a windows desktop from linux. The command to use is:

cmake

I haven’t been doing much with writing/compiling c programs of late. So I didn’t really notice the move from using make to using cmake for the build environment. We’ve been having some issues at work with this, so I’ve spent a few days trying to learn it. I’m not at expert at this at all, but I have picked up a few things. So I want to document them here.

Getting RPM names only

I can’t remember where I found this on google, but it’s something I’ll use a lot. If I want to just get the names of rpms installed on a machine, use this:
<br /> rpm -qa --qf " %{name}\n"|sort|uniq > list.rpms<br />

Ideas

It’s weird. I’ve just spent the past two hours making myself a calendar. I was wondering how to design it and it just popped into my head that I have pictures from the early 2000s to now. Why don’t I use some of my own pictures on my calendar? And then find some quotes I like and put them over the picture. It’s a really simple idea, but I love it. I’m going to get a calendar that has motivational or inspirational quotes and I can look at pictures of things I’ve done which brings back those memories. Totally going to make me happy.

Getting Started with the Google API for Reading Public Calendars

I have a few public calendars at work that we use to show events taking place in various departments. I am creating a digital sign for one of our buildings and I’d like to be able to grab the events for the current day and display them on the digital sign. I’m most familiar with ruby right now, so I’m writing a ruby script to do this.

Root Logins with Key Required

I love the fact that I still have so much to learn. I was thinking that I should set things up so that root can ssh in to a computer but only if they have keys set up. One very quick google search and I had my answer.

Splitting a PDF File

I had a pdf file that was too large to email, but I needed to email.  So I quickly broke it up into two smaller files.  I used this command:

My New MacBook Pro

As noted, with the new year, I’m starting to use my new MacBook Pro full-time. Last night, it took a few hours to copy everything from my old backup to this new laptop. Did it work perfectly, of course not. Plus, I don’t like copying everything from my old laptop to my new one. There is a lot of stuff that I could throw away, but it takes time to go through it all. So I copied just my old home directory, but not the Applications directory. I know there’s lots of stuff that won’t run or that should be updated, so I installed all that stuff manually.

Learning More Windows 10 Stuff

My last post talked about using xcopy to copy a bunch of files from one server to another. I had been running this for a day, but a couple of times the command failed with the error “Insufficient Memory”. Since my new server has four times as much memory and three or four times as much disk space, I didn’t think that error was actually true. A quick google search shows that this message usually comes up when filenames are over 255 characters long, which was going to be a problem for me. Instead, robocopy (robust copy) should be used. The command I’m now trying is:

Windows 10 – More Stuff I Didn’t Know

I’m installing a new Windows 10 computer in our office to replace the old Windows XP one. All this computer is going to do is host our shared windows disk. Not a lot of people use this disk, but it’s really good for sharing files or if a student is going to work at different computers in the lab.

Windows 10 in My Samba PDC

I had recently installed windows 10 on one of our computers at work. I was able to successfully add it to the domain, but then none of my users could login. The error message was:

RHEL7 Kickstart

Now that I’m in a place where all ip addresses are handled by dhcp, I need to change how I do kickstart installs.

Merge Three Files into One Using Command Line

I have three pdf files that I want to merge into a single file. But I don’t want the three files to be on three separate pages. I want one big page with the three files all there.

Problems with mp4 files in Firefox

We had some students who took a video with their phone and wanted to post it on an html page. The html code we used was:

<video controls="controls" width="400">
	<source src="Robot.mp4" type="video/mp4">
	Your browser does not support the video tag.
</video>

In Chrome, this worked fine. But in Firefox, it would show like this.

When that happened, I went to Tools -> Web Developer -> Browser Console. I got a message like this:

HTTP "Content-Type" of "video/3gpp" is not supported.  Load of media resource http://www.example.com/Robot.3gp failed.

This message was strange because I wasn’t posting a file called Robot.3gp, but one called Robot.mp4. So on my server, I checked the file.

$ file Robot.mp4
Robot.mp4: ISO Media, MPEG v4 system, 3GPP 

So whatever created this file, actually made a 3gpp file and not a legit mp4. However, I found that you can convert a 3gpp file to mp4 using ffmpeg. I renamed my Robot.mp4 file to Robot.3gp and then converted it.

$ ffmpeg -i Robot.3gp -ab 64k -ar 44100 -strict -2 Robot.mp4
ffmpeg version 2.8.12 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Robot.3gp':
  Metadata:
    major_brand     : 3gp5
    minor_version   : 0
    compatible_brands: 3gp5isom
    creation_time   : 2017-07-26 17:45:04
  Duration: 00:00:20.23, start: 0.000000, bitrate: 5135 kb/s
    Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m), 720x480, 5005 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2017-07-26 17:45:04
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 123 kb/s (default)
    Metadata:
      creation_time   : 2017-07-26 17:45:04
[libx264 @ 0x1e6d1e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x1e6d1e0] profile High, level 3.0
[libx264 @ 0x1e6d1e0] 264 - core 148 r2699 a5e06b9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Robot.mp4':
  Metadata:
    major_brand     : 3gp5
    minor_version   : 0
    compatible_brands: 3gp5isom
    encoder         : Lavf56.40.101
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 480x720, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      creation_time   : 2017-07-26 17:45:04
      encoder         : Lavc56.60.100 libx264
    Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
      creation_time   : 2017-07-26 17:45:04
      encoder         : Lavc56.60.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame=  607 fps=178 q=-1.0 Lsize=    1593kB time=00:00:20.22 bitrate= 645.1kbits/s    
video:1408kB audio:162kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.439324%
[libx264 @ 0x1e6d1e0] frame I:4     Avg QP:19.34  size:  9992
[libx264 @ 0x1e6d1e0] frame P:171   Avg QP:22.56  size:  4317
[libx264 @ 0x1e6d1e0] frame B:432   Avg QP:24.06  size:  1534
[libx264 @ 0x1e6d1e0] consecutive B-frames:  3.3%  2.6%  8.4% 85.7%
[libx264 @ 0x1e6d1e0] mb I  I16..4: 28.5% 58.4% 13.1%
[libx264 @ 0x1e6d1e0] mb P  I16..4:  4.2%  9.2%  1.8%  P16..4: 37.9%  7.7%  5.0%  0.0%  0.0%    skip:34.2%
[libx264 @ 0x1e6d1e0] mb B  I16..4:  0.3%  0.5%  0.1%  B16..8: 42.5%  2.7%  0.4%  direct: 1.4%  skip:52.2%  L0:48.5% L1:48.6% BI: 2.9%
[libx264 @ 0x1e6d1e0] 8x8 transform intra:59.6% inter:80.2%
[libx264 @ 0x1e6d1e0] coded y,uvDC,uvAC intra: 32.2% 41.0% 4.4% inter: 7.5% 10.5% 0.3%
[libx264 @ 0x1e6d1e0] i16 v,h,dc,p: 33% 24% 26% 18%
[libx264 @ 0x1e6d1e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 16% 45%  3%  9%  3%  9%  2%  3%
[libx264 @ 0x1e6d1e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 14% 27%  3% 18%  4% 16%  2%  3%
[libx264 @ 0x1e6d1e0] i8c dc,h,v,p: 61% 18% 20%  1%
[libx264 @ 0x1e6d1e0] Weighted P-Frames: Y:2.3% UV:0.0%
[libx264 @ 0x1e6d1e0] ref P L0: 56.2% 10.7% 21.3% 11.6%  0.1%
[libx264 @ 0x1e6d1e0] ref B L0: 84.3% 11.6%  4.1%
[libx264 @ 0x1e6d1e0] ref B L1: 94.4%  5.6%
[libx264 @ 0x1e6d1e0] kb/s:569.65
$ ll Robot*
-rwxr--r-- 1 hep html 12988147 Jul 27 12:53 Robot.3gp
-rw-rw-r-- 1 hep html  1630980 Jul 27 13:43 Robot.mp4
$ file Robot.3gp
Robot.3gp: ISO Media, MPEG v4 system, 3GPP
file Robot.mp4
Robot.mp4: ISO Media, MPEG v4 system, version 1

Now the Robot.mp4 file plays in Firefox without a problem.

Keyboard not working with old program setup

At work, we use some very old programs. In one program (layout), it opens up the other program (specctra). The weird error was that the keyboard would not work in specctra if it was started from layout. If I started it by itself from the command line, it worked perfectly. I looked at the logs when it started and found a lot of warnings that looked like this:

Compromised Account

I had a user account that was compromised yesterday. Fortunately, all they used it for was to send out a ton of spam for 11 hours or so. The person whose account was compromised came in today to find over 50,000 bounced messages in her account. So I had a pretty good idea of which account was causing the problem. After stopping her mailer and then starting and stopping sendmail, I saw that the messages were still going out. I changed her password and that appeared to stop things. I kept an eye on things and will continue to do so for the rest of the day, to see if anything else goes wrong.

The security ID structure is invalid

All of my new users in my samba domain were getting this error when they tried to login to windows after I updated our ldap server. The problem was that I didn’t update my script to use the new SID on the new server. So for these users, the sambaSID and sambaPrimaryGroupSID values were wrong. I changed them with this ldif file.

Uninterruptible Sleep

Recently, I’ve upgraded some servers at work to RHEL7. I’ve had a few things that I didn’t plan for, but that’s to be expected when you do a major upgrade and you can’t test everything in advance. However, I have had one issue that is still causing problems. And ironically, it seems to affect my own account the most.

Compiling GEANT4

This one is strictly work-related.

Awk notes

I love awk and use it a lot. Yesterday, I used it for something with multiline records. Awk on single lines is quick and easy to use, but I always have to look up what to do with multiline records. And I still don’t exactly understand everything about multiline records, but here’s what worked for me.

Reset a Mailman List Admin Password

I shouldn’t have to do this again. If I don’t have the admin password for a mailman mailing list, I can reset it with:

Adding a Windows Computer to an Openldap-Samba Primary Domain Controller

For a number of years, I’ve used a linux computer running openldap and samba as the primary domain controller for my windows computers. This works great in that we can have a single sign-on for all of our windows and linux computers and use the same account for logins to websites. I’ve had an old piece of paper in my office with the changes that are needed on Windows to be able to get it to join this pdc. Thought I’d finally put them online in case something ever happens to my paper. (#2 below is really the only required step, but I always do all of them.)

Mariadb (Mysql) Setup

I wrote these instructions years ago, but couldn’t find them the other day. So I’m updating a few things and reposting here.

Filtering with procmailrc

I have an email account that I forward to a gmail account so that I can use google’s spam filtering. One thing that google does is limit the size of mail messages to 25mb. If someone sends me a mail message with an attachment greater than 25mb, google will bounce it back to my server, which will then forward it to google, who will then bounce it back to me… you get the picture. I had this happen today and while nothing crashed, it did slow my server to a crawl. So I thought that I’d put a rule in my .procmailrc file before the forward to the gmail account that moves the large file to a local mailbox. This is easy to do, I’d just add a section like this:

Delete a command from the history

If I run a command that, maybe shows a password in it, I’d like to delete that command from my command history. Say I this shows when I run history:

Temp Files in RHEL7

I had an RHEL7 system that would not start mariadb server on boot. I could reinstall the server rpm and then it would work fine, but it would not start after a reboot. So I finally had some time to figure out what’s going on.

Certificate Notes

Every so often I have to do something with certificates. It’s infrequently enough that I always have to re-lookup all the commands because I don’t remember the exact syntax. Also, for a long time, I simply used self-signed certificates because they did the job for me. However, now that there are very inexpensive certificates, I sometimes use them. Anyway, here are my notes:

The credentials are correct…

I had a problem where one user could not login to our windows server 2012 computer. The error message that I got was:

El Capitan NFS Mount

First create the directory /Volumes/sharedirectory

RHEL7 Kickstart Problem

I’ve been trying to set up an RHEL7 kickstart script for our computers and was getting a bunch of errors about PackageKit.

Simple Rsync

I always have to look this up, but a simple rsync command is:

El Capitan Simple DOS Format

The disk utility in El Capitan looks to be much more limited than it used to be in older versions of mac os x. So I need to use the command line to do a lot of things now. First off is a simple format of a new disk as an plain dos disk.

RHEL7 Systemd (Startup) Script

I have an RHEL7 system that needs to start an lmgrd license file for some autodesk software. And since RHEL7 now uses systemd, I have to change my old sysinit scripts to work here. So here’s what I did.

RedHat Improvements

One of the students asked me about installing python2.7 on a redhat 6 system. Since I know the operating system depends on a particular version of python, I was immediately thinking about just upgrading the system to RHEL7, which would have the version of python required. But, happily, I’ve found that RedHat has provided a way to upgrade important systems. It has created a new channel called “RedHat Software Collections”. The beauty of these is that you can still use the regular package manager and that they won’t overwrite or conflict with system files. You need to enable the channel and install “scl-utils and scl-utils-build”. Then, the command to switch/see collections is scl. As an example,

Uploading a File in a Rails Site to Use to Update

I want to upload a file to my rails webpage, but not store it in the database. I just want to upload it and then get the data out of it and update the database with the information in the uploaded file.

Using Ruby on XML Files

I need to copy some data from one system to another. On the first system, I can download an xml file. The second system is a ruby on rails website. So I’d like to them upload the xml file to the site and have it enter in the data. But since I’m not that familiar with working with xml files, I thought I’d work on it from the command line first.

In ruby, there’s a gem called nokogiri which works with xml (or html) files. Here’s the sample xml file that I’m using:


<AbstractBook>
 <Conference>TEST CONFERENCE 2016</Conference>
 <abstract>
  <Id>5</Id>
  


  Diversity, diversity

  <Content>This is all about diversity.</Content>
  <field id="content">This is all about diversity.</field>
  <PrimaryAuthor>
   <FirstName>George</FirstName>
   <FamilyName>Washington</FamilyName>
   <Email>george@wh.gov</Email>
   <Affiliation>WH</Affiliation>
  </PrimaryAuthor>
  <Speaker>
   <FirstName>George</FirstName>
   <FamilyName>Washington</FamilyName>
   <Email>george@wh.gov</Email>
   <Affiliation>WH</Affiliation>
  </Speaker>
  <ContributionType>Abstract</ContributionType>
  <Track>Diversity and Inclusion </Track>
  <AcceptedTrack>Diversity and Inclusion </AcceptedTrack>
 </abstract>
 <abstract>
  <Id>6</Id>
  


  Higgs, higgs, higgs

  <Content>I've got *something to say* out the **Higgs.**</Content>
  <field id="content">I've got *something to say* out the **Higgs.**</field>
  <PrimaryAuthor>
   <FirstName>Abe</FirstName>
   <FamilyName>Lincoln</FamilyName>
   <Email>abe@wh.gov</Email>
   <Affiliation>The White House</Affiliation>
  </PrimaryAuthor>
  <Speaker>
   <FirstName>Abe</FirstName>
   <FamilyName>Lincoln</FamilyName>
   <Email>abe@wh.gov</Email>
   <Affiliation>The White House</Affiliation>
  </Speaker>
  <ContributionType>None</ContributionType>
  <Track>Higgs Physics</Track>
  <AcceptedTrack>Higgs Physics</AcceptedTrack>
 </abstract>
 <abstract>
  <Id>7</Id>
  


  Oh the Lovely Higgs

  <Content>Some interesting info about how pretty the Higgs is.</Content>
  <field id="content">Some interesting info about how pretty the Higgs is.</field>
  <PrimaryAuthor>
   <FirstName>Grover</FirstName>
   <FamilyName>Cleveland</FamilyName>
   <Email>gc@wh.gov</Email>
   <Affiliation>WH</Affiliation>
  </PrimaryAuthor>
  <Speaker>
   <FirstName>Grover</FirstName>
   <FamilyName>Cleveland</FamilyName>
   <Email>gc@wh.gov</Email>
   <Affiliation>WH</Affiliation>
  </Speaker>
  <ContributionType>None</ContributionType>
  <Track>Higgs Physics</Track>
 </abstract>
</AbstractBook>

And here’s the script I wrote:

#!/Users/maryh/Software/rubies/2.2.3/bin/ruby

require 'nokogiri'

File.open("Abstracts.xml") do |file|
	@doc2 = Nokogiri::XML(file)
	elems = @doc2.xpath("//Speaker")
	myfirst ='Abe'
	mylast = 'Lincoln'
	elems.each do |e|
		if (e.at('FirstName').text == myfirst) && (e.at('FamilyName').text == mylast)
			puts e.parent.at('Title').text
			puts e.parent.at('Content').text
			print "#{e.at('FirstName').text} " 
			print "#{e.at('FamilyName').text}\n"
		end
	end

end

First, I open the file and open it as an xml file with nokogiri. I then put in elems all the xml fields labelled “Speaker”. I then cycle through elems looking for the string “Abe” and “Lincoln”. If I find them both, I print out the field “Title” and “Content” which are both in the parent field from “Speaker” and then I print out the first and family names.

This is very basic and there are a lot more things that I need to do. I need to match the speaker info with names stored in a model in my rails app. And then update that entry with the title and content if I find a match.

Using Ruby on CSV Files

I’m working with some different systems for a conference I’m working on. We’re using RegOnline to handle the registrations. One of the things that I need to do is get a list of people who have registered on RegOnline and post them on our conference website. Our conference site is plain html and I don’t want to have to type in each person who registers. I can download a csv file from RegOnline. I want to write a script that reads the downloaded csv file and makes an html file for the website. I hadn’t done much with csv files before, but here’s a basic script that pretty much does what I want. (I still have to put html tags in, but that should be pretty easy.)

Paperclip with Spoof File Checks

I have a rails site that accepts pdf files as uploads. Based on previous experience, I have found that trying to validate on content-type causes lots of problems. There are many browsers that send weird content types with file names. For pdf files, they should always be using ‘application/pdf’ and most browsers do. However, this morning I got email from someone who couldn’t upload his file in one browser. He told me he used a different browser and it then worked. I searched the log files and found a bunch of error messages, but the main bit was this:

Getting Started with Ubuntu

Just about all of the linux systems that I work on are a RedHat variant (Scientific Linux or Centos). But in the past few years, more people have been using Ubuntu, so I need to become familiar with it. And yesterday, I had to set up a system to help someone troubleshoot a board that we built. So here are some things about Ubuntu that I’ve learned recently. And just about all of this stuff is done using the command line because that’s how I prefer to work.

Declarative Authorization attribute rules

I have a website where I use declarative authorization to determine who is allowed to do what. One thing that I need to allow is for people to change their own passwords. It’s pretty simple, my model/controller is users. Here’s what I needed to do:

Making a PDF File and Automatically Attaching It

I’m writing a rails site that collects information from an applicant and references from other people that will then be reviewed by a different group of people. For the programmer, it’s easy to present the information from the database on a webpage and then provide links to uploaded documents. However, this is not necessarily the easiest way for the reviewers to read all the information. Based on other sites that do the same type of job, I’ve learned that reviewers want to be able to download a single file with all the information in it. I’ve put together various hacks in the past to do this, but have recently come up with a proper way. The following isn’t complete, but it presents the basics of how to do this.

Getting Built-in Sound Working with RHEL6

I had a user running RHEL6 who no longer had sound. His computer has an Asus P8H67-M PRO motherboard. This board has a built-in Intel soundcard.

Ruby Iconv to Strings#encode

I wrote a script in Perl, years ago, that lets users update their unix and samba passwords at the same time. This keeps them in sync so that people will have the same password whether they’re logging in via linux or at a windows computer. I thought it would be a good idea to rewrite it in ruby, since that’s the language I’m most comfortable with these days. Along with Google, the book that was most helpful was Programming Ruby 1.9 & 2.0 from the Pragmatic Programmers, which fortunately, I had.

Multiple Authentication Methods with Authlogic

I have a website where users need to login to be able to comment on pictures. For the most part, users will use their university credentials to login. However, I’ve found a few recently retired people who would be able to help us identify people in the pictures. But since they are retired, their university credentials are no longer valid. So for these people, I’d like to be able to make a local account for them to login. My rails app uses authlogic to check credentials. And I’ve been authenticating against the university ldap server for a while without any problems, but mixing in local accounts is going to require a few changes.

Alternative DNS

My internet connection went down today for a few hours. Technically, I guess it didn’t go down, but DNS wasn’t working. So I could ping 216.58.216.68, but I couldn’t ping www.google.com. I had been using the DNS servers from comcast that I got from DNS. I believe they’re 75.75.75.75 and 75.75.76.76. But since these weren’t working for me, I changed to the following:

Crazy Error

I just updated some rails webpages to 4.2.4. On one system, I didn’t have any trouble. But on the other one, things worked fine on my laptop, but gave all sorts of random errors on my production system. I started keeping a list to see if I could figure out what was going on. Here are some of the errors that I was seeing.

Fun with Google Calendars

We’ve started using Google Calendars at work to keep track of different seminars, colloquia, etc. However, we also like to keep our regular html calendars because they’re just easier to read and to get a quick view of all talks for a quarter. So what we want to do is have the + Google Calendar button appear on webpages, but not show the actual calendar. We’ll have all the information in our own html calendar. Yes, this requires us to update two calendars, but it makes it easier to read.

Links vs Buttons

Now that I’m writing more websites, I’m trying to make them better. A lot of it has to do with making them look better so that people have a better (UX) user experience. I’ve been using bootstrap more, which is nice. But now I need to get into more nuts and bolts stuff.

I Prefer Fixes

I bought parts for some new computers for our engineers at work. Everything arrived yesterday, so I started assembling them. When I opened up the video card that I bought (PNY NVIDIA Quadro K1200), I noticed that the bracket was shorter than the standard bracket. I’ve purchased many video cards over the years and normally, the box will include another bracket so that it can be used in a regular sized case. However, I quickly found that there was not another bracket in the box. I looked a bit online and found that this particular card was designed for a small form factor case. My first issue is that that information should have been much more visible on the webpages where I bought it. Anyway, since I bought the cards from our campus vendor with a purchase order, I really didn’t want to try to return them because it’s a big hassle. So my first solution was to simply take the brackets off. I could put the card in and use it without a bracket without a problem. The next step was to see if I could make a new bracket, which quickly sounded like a bit more work than I wanted to do. I returned to Google and found someone who said that they had an older NVIDIA NVS 510 card. He said the bracket from that card fit the K1200 perfectly. I didn’t have any NVS 510 cards around, but more googling led me to a local place that sold that bracket for $20. I ordered them and got them in two days. They fit perfectly.

Capistrano 3 Issues

I decided to give capistrano 3 a try with one of my projects. For the most part, I prefer version 2 to version 3. Mainly this is because I never have a staging server. I only have my development stuff and then I deploy to production. So having to specify the deployment server is just additional work that I always forget.

Counting Comma-Separated Values in Excel

We have a bunch of spreadsheets where which have cells with values like this, R1, R2, R3, R4 or C45, C87, C22. It would be very helpful to have another column that could tell us how many values on in these cells (4 and 3 in my example). The way to do it is to use this function, which would tell us how many values are in cell H8.

Openssl Update Breaks Pine

There was an openssl update recently that caused people who were using alpine to not be able to send mail. When they tried to send, they got this message:

incompatible character encodings: UTF-8 and ASCII-8BIT) in Rails App

I got this error after I updated a website from rails3 to rails4. I spent a few days going over character sets and collations in MariaDB. It turns out that all I needed to do was to use the mysql2 gem instead of the mysql gem. I am writing this so I hopefully will remember when I do this again.

Ruby Lambdas

I’ve used ruby lambdas a few times, but I have to admit that I never really understood them. However, I’ve now come across a case where I have to figure them out. Here’s what I’ve found:

Authlogic Error

I put up a new website that wouldn’t allow me to login and kept giving me an error that said something like undefined method `save_without_session_maintenance’. I double-checked all my controllers and models against another site that was working fine and they all matched up. I didn’t find any bug reports for the version of Authlogic that I was using. The solution was to just deploy the app again. After that, I was able to login successfully. Weird.

Remote Desktop Services with a Samba PDC

We’ve been using a linux computer running samba and openldap as our primary domain controller for a windows domain for years. I absolutely love the fact that I don’t have to deal with windows and their crazy licensing. More importantly, this setup makes it easy for me to create accounts to give people access to everything in our shop. This includes windows accounts, linux accounts and website accounts.

Serving SVG Files

I updated a website and changed to using svg files for our header. On our test setup, we were running RHEL7, which had a newer version of httpd than what’ on our production server, which is running RHEL5. I had to add the following to our httpd.conf file to tell it to specifically serve svg files.

Sendmail on Centos 7.1

I’m running a server that I recently upgraded to Centos 7. For a few months, it wouldn’t send mail and today I finally decided to do something about it. I was getting an error AUTH warning: no mechanisms. After messing around for a while, I saw this in /etc/mail/access:

Make a Bootable USB Drive with Yosemite Installer

I wanted to completely reformat and reinstall Yosemite on an old iMac. To do this, I needed to make something I could boot from. I got an 8gb usb flash drive and used Disk Utility to reformat it to a Mac filesystem that I called Yosemite. This disk was then mounted at /Volumes/Yosemite. I then went to the App Store and downloaded Yosemite, but cancelled the installation. This left the installer in /Applications/Install OS X Yosemite.app. Then, to make the bootable drive, I ran the following command:

Production Gems

I’m not sure how I didn’t notice this before, but my deployment on an app was suddenly taking much longer that it had in the past. While I was watching it run, I noticed that when bundle install was running, it was saying installing each gem. I don’t know why I didn’t notice this before. I looked on my server and noticed that each release was about 177mb in size and the vendor/bundle directory was 173mb in size. I was reading the Bundler website when I saw this bit:

Lots to Learn about Assets

I upgraded a new app to use Rails 4.2 and bootstrap and I thought things were fine. However, when I went to the page today, css wasn’t working. It just never created the css files. Turns out that I needed to add the ‘sprockets-rails’ gem to my Gemfile because the asset pipeline is no longer a feature of rails 4. Once I ran bundle and commit this change to the repo, I could deploy and things worked fine.

Still Learning About Rails and Deployment

I had been feeling pretty good about my Rails skills and had been able to create and deploy a number of simple applications. Since simple applications are just about all I’m going to write, I was ok with things. But I was hanging on to earlier versions of things and it was starting to bug me. One big one was the capistrano gem. I knew there were big changes between version 2 and 3, and I had a pretty good setup using version 2. However, I know that things constantly change so I decided to dive in and start using capistrano version 3, 3.4.0 to be exact.

Changing Rails Boolean with a Button

I suddenly realized how to change a boolean with a button in a much easier way that the post I did yesterday. All I did was make a form with one hidden field (the boolean that I want to change) and just show the submit button.

Change a Boolean in Rails with a Button

There’s a much easier way to do this, which I show in this post.

Rails Rewrite

I have a website that I’ve been using to track timesheets for a number of people. It’s one of the first websites I wrote in rails, written about four years ago. The only person who really uses it is me, but a few other people also login to view the information. Anyway, the site was written in rails 3.2.11 and now the latest version is 4.2. I’ve decided that since I know a bit more rails now (I wouldn’t say I’m a good programmer), I’d rewrite the program. It’s not that elaborate, but it does work really well for me.

Macs and Linux

At work, we have a bunch of computers running linux and hosting disks that are shared using NFS. Of late, many people have been switching to Macs as their primary computer. Usually, they then just ssh into one of the linux machines and work as before. However, now I think they’d like to be able to stay on their Mac and still access the files in linux. Macs are unix-based, so mounting NFS drives isn’t that much of a problem. However, the default user ID and group ID used on the Mac does not match up with our uids and gids in linux. The default (first) user on a mac, is give UserId = 501 and GroupID = 20. This group id corresponds to the group named staff. I wanted to change these ids so they match up with the ids we use in linux. Then, when the user creates a file on an NFS drive, they’ll have the correct owner and group. How to do this? The dscl command on the mac is the one to use.

Alpine on a Mac

I have just installed alpine on two different macs. On one, I used macports and on the other homebrew. Both seem to work just fine. I was also able to set up imap to our mail server without any problems. I did run into a couple of issues, but fortunately, have been able to find solutions to all of them.

Time Machine Transfer Issues with Office

I bought a new imac and wanted to transfer an account from an old imac. I created a new admin account and then used the migration assistant to transfer the old account. The old imac was running office 2008. We now are using office 2011. I installed office 2011 using the admin account and it seemed to work fine. When the user logged in to her account and tried to start Excel, it would just continually crash. I tried reinstalling Office 2011 as the user, but that didn’t help.

Forms and Tables

I had a very weird situation today where a simple form I had created in rails would not work for the edit action. It would work ok for the new action. But if I tried to edit an entry, the submit button wouldn’t do anything.

Compiling Bootstrap

I’m using bootstrap a lot these days for a couple of websites I’m setting up. In addition to bootstrap, I had been using a css file for my own changes that I wanted to make. However, now I’m starting to make more than just a couple of changes, so I want to learn how to recompile my own bootstrap file. Here’s all I’ve done.

Sloppy

I bought computer parts for my nephew to assemble his own computer. We got it all together and it didn’t work. After taking out lots of parts, it looks like I bent some pins in the cpu socket when I put it in. This was after I specifically told my nephew that you had to be careful doing this. I’m an idiot. Tomorrow, I think I’m going to take it to work to see if I can perhaps straighten the pins using our microscope. If that doesn’t work (and I have a feeling it won’t), I’ll probably just have to buy a new motherboard.

Bootstrap

I’ve been playing around with Bootstrap for the past few days and have grown to like it. I just switched over one of my work webpages to it and have to do the other one. Once I have those done, I’ll probably redesign coldandheartless with it as well. It is nice to be able to easily read and navigate my sites on my phone.

PHP Notes

Mainly I use Rails for stuff on the web. But now I’m making a simple website and I’m using php for it. One of the things I really like about Rails is the use of a layout to keep pages consistent. I’m sure there’s a php framework I can use for this. But all I’m really want to do on my current site is have some static html pages loaded. I’m mainly using php to load the navigation bar. The one difference here is that I want the site to be responsive. So I’m using bootstrap for this. I want to make a function that lays everything out and then loads a specific page in the right place. Basically, I’m looking to recreate the Rails yield function.

Holiday Work

My original plan for today was to go and cut down a Christmas tree. But since my nephew (who wanted to actually cut the tree down), has not yet finished his homework for tomorrow, this plan is now on hold. So last night, I started looking at the hosting for this website. I was on Rackspace (since they bought Slicehost years ago) and was paying around $44/month. It was ok, but I my virtual server was running Centos 5.5. I know that Centos 7 is out now and I figured I should upgrade. Since this was going to mean basically making a new server and copying everything over, I looked around at my other options. Paying another $44 to Rackspace for another server seemed pricey. So instead, I set up a new server on Linode and have been moving everything there. I’m hoping Linode is going to cost me less than $20/month, but I’ll see after a few months how it’s looking. Right now, I’m copying all of my old data from my laptop to the new host. This will take a few more hours, but then I think I can delete the old Rackspace host, as I have everything set up on the new one.

Responsive Webpages

I’ve started using the twitter-bootstrap gem to get responsive webpages. It worked fine on my laptop and resized things correctly as I changed the size of the browser window. However, when I checked it on my phone, it was showing the full-size page. To fix this, I needed to add the following to the head in my layout.

WordPress Updates

I had a very old computer (running FC3), hosting some very old wordpress blogs that got broken into. The good news is that I had backups of all the blogs. But since the computer was still working, though not allowed to be online, I could also copy the data directly from that computer. I ended up copying data from both places to get the blogs back up. Here’s what I did.

Kickstart Changes from RHEL6 to RHEL7

I’ve just started installing RHEL7 on some systems at work. I usually use a kickstart script to set everything up, but the syntax of the command has changed with RHEL7. Here’s the way to get the kickstart file from our satellite server using both RHEL6 and RHEL7.

To All Who Have Ever Received Email From Me

I’m sorry. I’m sorry for my apostrophes being turned into question marks because of a stupid setting of Apple’s. I finally got a little time today and had a chance to figure out what was going on. If you go to System Settings – Keyboard – Text, there’s a selection called “Use smart quotes and dashes”. In my opinion, this should always default to off. But due to Apple’s arrogance, they had it on by default. So if you ever read my email on a non-Apple computer, all of my apostrophes would show as question marks. This bugged the heck out of me when I’d get a reply from someone and see all those question marks. So I finally took some time today to get rid of them. Yay!

Deleting Autorun.inf Files

I don’t know why Windows 7 or the antivirus software I have, doesn’t let me delete autorun.inf files. To delete the file, do the following:

Mavericks Terminal Copy/Paste Rich Text Format

After upgrading to OS X 10.9, I found that whenever I copy/pasted text from a terminal window to TextEdit or an email message, it would paste using the same colors/background as was in the terminal. In my case, this meant that the text was white on a gray background. This was annoying, since I just wanted to see the text. To fix this, enter the following into a terminal.

NFS and Files Owned by Nobody

After upgrading a server to RHEL6, I found that if other RHEL6 computers tried to NFS-mount a shared directory, all files were owned by nobody:nobody. To fix this, edit the file /etc/idmapd.conf and add a Domain line, something like this:

Windows Disk Mounting Across Subnets

I have some windows computers at work that I use for backups. I recently moved one to another building that’s on a different subnet. Trying to mount the disk using the name of the computer didn’t work. The fix was to use the ip address instead of the name of the computer. For example, mounting \eshop\backups didn’t work. But mounting \192.168.2.30\backups, worked just fine.

Scrolling Graph in Processing

I want to create a graph where the old data scrolls off the left side of the window while the newest data is plotted on the right side of the window. Eventually, I’m going to use this for a display to plot the readings of a temperature probe. But for now, I just want to see if I can make it work using Processing. So instead of trying to read from the serial port, I’m just going to plot a bunch of random points.

Arduino and Processing

I’m getting started with collecting data using an Arduino board, but displaying it using Processing. Eventually, I want do collect the data from a Raspberry PI board, but I’m starting with an Arduino because I think it will be easier.

Testing PyROOT is Working

If you’ve compiled ROOT to use python, you need to find out if it’s working correctly. The following code will do that:

Changing Password Encryption

Per my earlier post about changing the encryption methods of passwords, I had a chance to test out the directions I had to see if they really worked. In fact, they worked perfectly. And to check that things actually changed, I took a look at the crypted password before and after I logged in.

Rails Program Upgrades

I had a computer that was hosting a number of simple rails programs that I needed to upgrade. So, I updated everything and reloaded the mysql data and everything was good. That is, until I tried to login. I had a number of unsuccessful attempts and just assumed it was because I forgot the password. There were actually three programs that I had to reinstall and after the third one, I realized that I hadn’t forgotten the password but that something had changed.

Fixing Carriage Return/New Line Problems

Sometimes if I open a text file in vi, the text shows up like this:

Ruby/Rails Upgrades

I have a few apps running on rails 3.2.12 and ruby 1.9.2. Since I need to make some changes to them, I thought I’d update them to rails 4.1 and ruby 2.1. I first upgraded the apps to rails 4.0 and ruby 2.0. That worked fine. Now I want to upgrade to ruby 2.1. First I’m doing it on my laptop. Here is how I compiled and installed it.

Open DNS with Windows 7

I had a problem with a windows 7 computer that was resolving dns.

Rails Constantize Method

I learned a new inflector method the other day, constantize. Here’s the method I used it in.

Paperclip and Nested Attributes

I have an app that has a model (called cases) that has_many documents associated with it. I have had no problems in creating the case and the associated documents. I had quite a bit of trouble when I was trying to replace one of the documents with and updated one. But I finally got that straightened out. Not sure if this is how a real programmer would do it, but it works for me.

Hate Things that Depend on Whitespace

I’m writing a rails app and was trying to use a scope with a variable. My code looked like this:

Using TileMill

Need to go to http://metro.teczno.com/ and download the osm.pbf file for Chicago. Then import it:

Tilemill

I’m trying to make a map for a conference and thought I’d use TileMill. As far as I can tell, the first step (after installing TileMill) is to install postgresql. Here’s where I am with that.

Robot in Action

I finally built my robot. I had taken pictures of the process, but never got around to posting them. Instead, here’s the first video I made.

Drunken Jogging

I started using the RunKeeper app to track my jogs, as my sister uses it and likes it a lot. It is also able to track bike rides, which I also do. So this seemed like a great solution. And to top it off, on my first run, it said my pace was a bit faster than I thought I was doing, so I was pretty happy.

My Robot

My niece and nephew were both talking about building a robot and it made me realize that I wanted to build a robot as well. After looking around, I had intended to buy the new Arduino robot, but it wasn’t in stock. Instead I found a hexapod robot called Hexy, which looked even more fun. So I ordered it and it arrived today.

Mass Mailing in Rails

I have a need to send out a bunch of individual emails from the same email address. I thought it would be good practice for me to see if I could do this as part of a rails app. The interesting thing is that I don’t want to save anything to a model. I just want to be able to upload a csv file, get all the names and email addresses out and send the same email with attachment to all of them. Here’s how I did it.

Handy Trick

If you have some sample code in a ruby file that you want to run ONLY when that file is called directly, enclose it in the following if statement.

Rails4 and Assets

I spent a ridiculous amount of time trying to get a background image to show on a production server running a new rails4 app. Everything looked fine on my laptop, but once I deployed to the server, the image wouldn’t show. I only had one image on the site, but I’m pretty sure that if I had more, none of them would have showed.

Ruby Methods

I’m still learning where methods go when writing ruby on rails applications. I read something earlier today (and had read it before) that you need to think “tell, don’t ask” when it comes to methods. So basically when working with an object, if you want it to do something, you tell it to do that. This method will then go into the model and get called with @object.method. So, in my application, after an applicant is saved. I want to send a message to the object to send email to that applicant. I had this in the controller, but now I’m pretty sure that this belongs in the model. It ends up looking like this:

Pittsburgh Trip

I just got back from a long weekend spent in Pittsburgh. I went there to attend Steel City Ruby Conf, which was pretty good. The first day had a lot of self-described “touchy-feely” talks, which I wasn’t crazy about, but understood why they were being given. Though Julie Pagano’s talk on Front-End Development was pretty good and Jim Weinrich’s “Friendly Flying Robots” was a lot of fun. The talks on Day 2 were much more what I was looking forward to. The talk on git by the Steven Ball was really informative and I’m hoping I can start using some of his tips right away. Avdi Grimm’s talk on Pair Programming has pretty much convinced me that I should give it a try as soon as I get some time. And Leon Gersing’s inspiring talk was the perfect finish. So, based on the strength of those talks, I feel it was a pretty good conference.

Fixing Inflections for Acronyms

In my app, there are a list of files that people need to upload. I had set things up so that they could pick the type of file from a dropdown list. The list of files are:

Ruby Dates

In one of my apps, the price of registration for an event goes up after a particular date. So I have to check if today’s date is after the given date. Here’s how I’ll do this:

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:

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:

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.

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.

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:

Mac Keyboard Shortcuts

Command – arrow keys = change to different terminal windows

Site Update

I had a little time yesterday so I updated the user interface for the colandheartless site. It didn’t take too long and I’m very happy with how it turned out. The site is basically just serving up static webpages, so it’s just some basic css/html. I did make all the pages php, but that’s just so that I could put a function at the top of the page to display the header and navigation bar. It’s really the only php that I know, but it’s so handy that I use it all the time. Anyway, I wanted to update things so that I have slightly better organization for when I add new stuff. Specifically, I’d like to continually make pages that document the process of making the map game I’ve been thinking about and all the stuff that I’ve had to learn to be able to make the game. I could do this in the blog, but I’d also like to have a freer format for things than the blog provides. With the new site, I can pretty much do whatever I want.

It Takes Time

I have, for the past few days, been immersing myself in adding parts to my arduino to extend functionality. There’s a game involving a map that has been floating around in my head for a very long time. It’s finally time for me to do something about it, so I’m starting to learn the things necessary to make it happen. I successfully hooked up a shift register to add a lot more leds, which will be necessary and now am hooking up a different type of shift register to add more buttons. This has proved a bit more difficult, but now, in my advanced age, I know that it takes time for things to sink in. Today was one of those great days where after struggling for a while, the light bulb went off over my head and I think I understand how things work.

Regex in Ruby

This is something simple that I should know off the top of my head, but seemed to have forgotten today. So I’m writing it here, to hopefully, help me to remember.

On one of the webapps I’ve written, someone signed up but had an apostrophe in their name. I had already accounted for spaces in names, but not apostrophes. So, I decided that I should fix things for any non-word character.

The method that cleans up the name is this:

def fullname_no_spaces
  [firstname.gsub(" ","_"), lastname.gsub(" ","_")].join("_")
end

This just substitutes any spaces it finds with an underscore. To have it replace any non-word character with an underscore, I just changed it to this:

def fullname_no_spaces
  [firstname.gsub(/\W/,"_"), lastname.gsub(/\W/,"_")].join("_")
end

That fixed my problems. For further reference, here are the regex values I could use:

^  beginning of a line or string 
$  end of a line or string 
.  any character except newline 
\w  word character[0-9A-Za-z_] 
\W  non-word character 
\s  whitespace character[ \t\n\r\f] 
\S  non-whitespace character 
\d  digit, same as[0-9] 
\D  non-digit 
\A  beginning of a string 
\Z  end of a string, or before newline at the end 
\z  end of a string 
\b  word boundary(outside[]only) 
\B  non-word boundary 
\b  backspace(0x08)(inside[]only) 
[ ] any single character of set 
*   0 or more previous regular expression 
*?  0 or more previous regular expression(non greedy) 
+  1 or more previous regular expression 
+?  1 or more previous regular expression(non greedy) 
{m,n}   at least m but most n previous regular expression 
{m,n}?  at least m but most n previous regular expression(non greedy) 
?  0 or 1 previous regular expression 
|  alternation 
( )  grouping regular expressions 
(?# )  comment 
(?: )  grouping without backreferences 
(?= )  zero-width positive look-ahead assertion 
(?! )  zero-width negative look-ahead assertion 
(?ix-ix)  turns on (or off) `i' and `x' options within regular expression.

I use a few of these a lot, but I need to remember all of them because they’re really handy. Perhaps, I’ll make a printout and hang it in my office.

Windows 8

I had read a bunch of bad things about Windows 8, so I thought I’d use my Technet subscription to install it and see for myself. When it first starts, it does truly suck. I don’t know what that first window that comes up is, but it looks ridiculous on a laptop. However, my clicking on my account name, I got to the familiar desktop. I’ll have to see if there’s a way to just make that be the default. The next weird thing was the lack of a start button. This meant that I couldn’t figure out how to get to the Control Panel. So I ended up installing a free program called Classic Shell. This gave me the start button and let me get to the Control Panel, which looks remarkably like Windows 7. That’s good. Anyway, I created a link on my desktop to Control Panel. I tried duplicating this link to see if I could have created it without installing Classic Shell, but that didn’t work.

Cloudflare

I just put coldandheartless.com on Cloudflare. It sounds like something that would be really helpful and I figured I’d give the free version a try before I move another domain to the paid version. It was incredibly easy to set up, which was great. Took basically a single click in my Badger account to enable Cloudflare and then put in the new dns values. I’ll admit that I don’t exactly know how it all works, but so far it seems pretty cool. I did see that there’s a wordpress plugin for Cloudflare and I’ll probably install that next.

Switching to Mac OS X 10.8

Today, I downloaded and installed Mac OS X 10.8. I won’t call it an upgrade because it’s not. About two hours ago, I attempted to install 10.6 on my one-month-old laptop. Sadly, it did not work. Every time I tried to boot to the old OS, the system crashed. So, I’m stuck with this piece of shit operating system. Here’s the thing. I thought 10.7 was pretty bad. It made no real changes, except things that appeared to be eye-candy, and which, for me, made the product worse. So, what do I hate about 10.8?

Test Pattern with Processing

We have a couple of students who needed a test pattern printed out. The pattern was basically a circle cut into a given number of pieces of pie. They initially requested 100 “pieces”, but weren’t exactly sure if that was going to be what they wanted. There was no chance I’d be able to draw this by hand, so I wanted to write something that would generate the pattern and be easy to edit so they could generate patterns with a different number of pieces. I thought that Processing would be a good way to do this and it turned out to be very easy, once I remembered two things. One, all angles in Processing should be in radians, so 360 degrees is 2 * PI radians. And two, that [0,0] is the upper left corner of the drawing. Once I had those settled, I wrote the following:

New Laptop

My new MacBook Pro (WITHOUT retina display) came yesterday. It’s SO nice having a matte screen again. I cannot say how much I hate seeing reflections of lights or myself in my screen. So this has been great. I still have my old laptop and I have a time machine backup for it. However, I decided not to use time machine to restore the computer. One, because there’s tons of stuff installed that I don’t really want any more. So, this will force me to clean up. Two, I did restore with time machine a while back, when the hard drive failed. It didn’t work perfectly. And I had to reinstall some software packages and clean up other stuff anyway. So, I decided to just avoid it altogether. This also got me to look at some programs that I was using to see that they won’t run under 10.7. The program I use to encrypt stuff is one such program, so I need to find an alternative for that. There were a couple others, but I think it’s good to set things up again. It helps me to remember why I did it.

Change in Long Listings

I was just doing some work on one of the computers that I’ve installed RHEL6 on and noticed something weird. Here is a listing on an RHEL5 node:

Working with rvm
ok:~ maryh$ rvm update
ok:~ maryh$ rvm reload
RVM reloaded!
ok:~ maryh$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p358]
[ruby-]1.8.7-head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2-p180
[ruby-]1.9.2-p290
[ruby-]1.9.2-p318
[ruby-]1.9.2[-p320]
[ruby-]1.9.2-head
[ruby-]1.9.3-preview1
[ruby-]1.9.3-rc1
[ruby-]1.9.3-p0
[ruby-]1.9.3-p125
[ruby-]1.9.3[-p194]
[ruby-]1.9.3-head
ruby-head
New Laptop Coming

I ordered a new MacBook Pro today. I specifically, did not order the one with the retina display. On those, you cannot fix anything. The ram is soldered to the board, the storage is some special thing and the battery cannot be replaced. Additionally, it no longer has an on-board ethernet port. You have to get a dongle to convert a thunderbolt port for that. I’d also have to get another dongle to hook up my external monitor. Lastly, somewhere I read that the fancy retina display still shows reflections. The blog post I read about it, said something to the effect of, still make sure you turn that overhead light behind you off. Since that’s the kind of thing that drives me nuts, I was pretty sure that no matter how nice it looked, it probably wasn’t for me. I had intended to go to and Apple Store and see it for myself, but after looking at all the other drawbacks listed above, I just decided I didn’t care. I’ve had this current MacBook Pro for 5 1/2 years. In that time, through AppleCare, I’ve had the logic board replaced and the dvd replaced. Once AppleCare expired, I’ve replaced the hard drive a few times, the lcd screen after I cracked it, the battery about 3 or 4 times, the power supply twice and the dvd is broken again, but I don’t care. I just don’t like that I’m not able to repair something that I supposedly own. And carrying a bunch of dongles also doesn’t appeal to me. I will have to get one for the monitor (my current one was the last to actually have a dvi connector on it, which was great), but I guess I’ll live with that.

Transit of Venus

We had perfect weather to see the transit of Venus today. I took my telescope and solar filter down to Mark’s house and had some fun with Jack and Abby. They both have now seen the transit and know that they won’t see it again, unless they live to 117 and 113 respectively.

Don’t Know Why This Didn’t Work Yesterday
[~]# gem install rails -v "3.1.3"
Ransack with Nested Attributes

In my app, I track plates which have a number of properties. They also have a location because I need to track where each plate has been. However, for the most part, what I really care about is where the plate is now, its current location. When I do my ransack search on the plates, I want to be able to have some check boxes with the possible locations. So, for example, people could search for all the plates that were annealed at a certain temperature and are located at Chicago. This means I have to search the locations for a given plate, but only for the latest location. I tried a number of different ways to do this in ransack and didn’t have much luck. I got it working how I wanted, but I’m fairly certain that this isn’t the best way to do it.

Ruby Enumerators

I have a rails app that handles a lot of information about a set of experimental plates. Along with holding information about each plate, I have another table locations, that’s nested with the plates, as in plates has_many locations and locations belongs_to plates. The locations is a separate table because these plates can get shipped to different locations a lot. This is a way for us to track where all the plates are. Most importantly, we want to know which location for a give plate has the latest date, because this will tell us where the plate currently is.

Ransack Update

I have an earlier post describing the way I set up a ransack search that sets up check boxes for possible search values in a given field. This was my first time using ransack and to say I had no idea what I was doing was not too far off. I’ve recently had to use it for another app and took some time looking into it again. And I think I’ve found the correct way to do a search like this.

Rails Forms with Check Boxes

In my latest rails app, I want to compare a number of objects. My first solution was to create a new search page with a form on it.

Dropdown Lists

In the event that I want to make a simple dropdown list in a form in rails, I can use this:

IPhone Saga Continues

I was feeling pretty full of myself after replacing the screen on my iphone. Alas, I now have new troubles. It seems that my iphone thinks that headphones are plugged in all the time. This means that I cannot take calls, listen or speak on my phone without putting it on speaker. I thought that this was related to my changing the screen, but I don’t think it is. First of all, I didn’t have this problem after I replaced the screen. It appeared about a week later. Secondly, I searched this issue online and found that lots of people have it. Just another great apple product.

A Full Day

Earlier this week, I had a bad day. I had two cars that I couldn’t drive, my bike had a flat, my iphone was in pieces, the power supply for my laptop was working sporadically (ended up buying a new one) and I was dreading doing my taxes. Today is much, much better.

Ransack Gem

Recently, I started using the ransack gem (https://github.com/ernie/ransack) for searching in one of my apps. I’m putting this here as an example, in case I ever need to make any more changes. The basics of ransack are pretty easy to do and work decently well. First step, add a search method to your controller. It should look something like this:

Changing link_to to button_to

In one of my rails apps, I send out email to a particular user. But, I can look at the message before it goes out. Then, at the bottom of this preview page is a link to actually send the message. I’m pretty sure that since this action is changing a boolean value on the user along with sending the email, that I should be using a button instead of a link. However, just switching the link_to to button_to won’t work because link_to uses a GET request, but button_to uses a POST request. So I need to change the button_to to use GET. The way to do that is like this:

Detaching Rails Processes

In my latest app, I’m emailing reports to people who click on a link. (Yes, I know this should be a button, but I just did it with a link because it was easy. If I have time, I’ll change it to a button.) Anyway, I’m attempting to use Process.fork to do this. What I have that works is:

New DNS Registrar

I finally had my fill of all the crap of Godaddy. Actually, that’s not quite true. That was a push, but the thing that really got me to switch is just the terrible website that one has to use to do anything with Godaddy. I found a new registrar Badger.com and decided on a whim to switch to them. I got one free credit (so I could transfer one domain for free) from Hacker News and I ended up buying two more for $8 each. I then started the process and was amazed to find that I had my three domains transferred in about 10 mintues. And they added an extra year to my domains. Their website is nice and clean. It’s easy to find stuff and they don’t try to sell me more crap each time I login. I can’t believe I waited this long to switch, but right now, I’m glad I did.

*#$!^&*! Spam

I hadn’t been blogging much, so I didn’t realize that I was getting slammed with trackback and pingback spam. After my last post, I noticed that there were over 800 comments. I knew this was going to just about all be spam, so I had to figure out what was happening. Since I had already turned off comments, I knew that wasn’t how it was coming in. I went to the dashboard and noticed that pingbacks and trackbacks were still on, so I turned them off and thought I was finished. Only after deleting the over 800 comments, did I see them keep coming. So I had to do a little more research to find that the checkboxes only turned off trackbacks and pingbacks for future posts. The earlier posts still had it on, which is why I kept getting the spam. These had to be turned off manually, which was going to be a pain, since I have a number of posts. But then I found a simple mysql command to turn them all off at once.

A Device Attached to the System is Not Functioning

I have a server running openldap and samba, acting like a windows domain controller. I have had no problems with adding windows 7 computers and users until today. One user could not login and this was the error.<pre class=brush:bash> A device attached to the system is not functioning. </pre>

Toggling a Div On/Off and Setting Default State

In order to have a section of a webpage toggle on and off, I need to use the toggle function that is provided by jquery.

Nested Attributes, Forms and Validations

I have a simple app where people can apply for a position. The table for this is applicants. Then, all users are allowed to rate each applicant. The ratings are in a table called ratings, which just has an applicant_id, user_id and score. So our tables are:

Moving to Ruby 1.9.3 and Rails 3.1.1

I’ve used rvm to install ruby 1.9.3-p0. Unfortunately, after installing, I get these errors:

My New Rails Deploy Method

I recently learned that capistrano can temporarily take down the web server while it’s being updated. This sounded like a very good idea to me, so I’ve started to use it. The only change I needed to make was to my /etc/httpd/conf/httpd.conf file. My virtual host now looks like this:

WordPress Issue

I’ve changed the permalinks on my blog to show the year, month and title. This edited my .htaccess file so that the links worked. But my new problem is that images are not showing. So, I’m making this post as a little test. I’m posting a new image to see if it works.

Odd Jobs

I am one of those people who considers herself completely replaceable. So, at work, I tend to try to continually make myself useful, so that even if I’m not needed to do what I was originally hired for, I can do something else that is required. I don’t think that I’m an expert at anything, but I like to learn enough so that I can solve problems that come up. Basically, I consider myself a generalist.

Things that Drive Me Nuts (or Why I’d Rather Build My Own Computers)

I recently purchased two Dell Optiplex 380s. Dual core pentiums with 3gb of ram and windows 7 professional for $434 each. I was quite busy and needed to get them quickly for my Mom’s office. Normally, I prefer to build my own systems because I know exactly what I’m getting. But the Dells were the right price and easy to order. After I ordered the Dells, I also ordered four Western Digital enterprise drives (WD5003ABYX) to use for a mirrored raid in each system. I did check that the optiplex systems had space for two more internal drives. I also knew that I’d be buying a separate raid card to put in the systems. I didn’t order that ahead of time because I wasn’t exactly sure what slots would be present/available in the system.

Validating Nested Attributes

I am sure that there’s a better way to do this, but I got this working and I wanted to document it.

Server Updated

I had noticed that my webpages from my server at Slicehost were very, very slow. A quick look showed that I was out of memory and using a lot of swap space. A few times, I even caused my system to crash because I ran out of memory. Today, I cloned my server to a new one with more memory. This is my first post using the new server. I’m testing things to make sure everything is working. So far, so good.

Multiple Rails Versions

If I have a number of different versions of rails, I can create projects for a particular version with:

Supermicro X7SPE-H D525 and Antec ISK300-150

This motherboard does NOT fit in this case. After rereading the specs, the motherboard is in the Flex ATX size and the case is mini ITX. While I thought I read that these were compatible, I can now state emphatically that they are not. So, my decision now is whether to return the case or modify it. If I knew I could find another case that fit the motherboard, I’d do that. But I’m not clear that I’ll be able to find a flex ATX case. In which case, I’m going to have to modify something anyway, so why not this cheapo case that I have.

Rails3, ldap and authlogic

I have an openldap server running and wanted to use it for authentication on a rails 3 application.

Mac OS X Server and WordPress

I have to say that I’m not at all happy with Mac OS X as a web server. My immediate complaint is that it’s not serving up WordPress themes correctly. I know I have them working properly, but when I go to other computers, I see that they’re not correct. I guess it’s time for me to move back to linux where I know things work properly.

Rails3 and Gemfile

I’ve had some problems with the new bundle install in rails 3. Specifically, on my laptop, in the development environment, I use sqlite. But in production, I use mysql. I was getting all sorts of errors on my laptop about the mysql gem not working and on the production server the errors were about a problem with the sqlite gem. Ideally, I wanted the development server to ignore mysql and the production server to ignore sqlite. Here’s how it was done.

Rails and params hash (from Google Cache)

Originally posted January 7, 2010

iPhone Update (from Google Cache)

Originally posted June 28, 2009

Happy New Year and New Year Spamassassin Issues (from Google Cache)

Originally posted January 1, 2010

Blown Power Supply (from Google Cache)

Originally posted October 14, 2009

RubyGems Notes (from Google Cache)

Originally posted October 15, 2009

I’ve been trying to do some stuff with ruby on rails and getting my program up and running here on coldandheartless. I had all kinds of trouble when I finally got to the deployment stage. The first errors I got were:

yo:site maryh$ cap deploy:setup
/Library/Ruby/Site/1.8/rubygems.rb:280:in `activate’: can’t activate net-sftp (= 1.1.0, runtime)
for [], already activated net-sftp-2.0.2 for ["capistrano-2.0.0"] (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:35:in `require’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/
gems/capistrano-2.0.0/lib/capistrano/upload.rb:2
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/
capistrano-2.0.0/lib/capistrano/configuration/actions/file_transfer.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/
capistrano-2.0.0/lib/capistrano/configuration.rb:12
… 7 levels…
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/
capistrano-2.0.0/bin/cap:3
from /usr/bin/cap:19:in `load’
from /usr/bin/cap:19

After screwing around for a very long time, I found that I seem to have some old versions of gems that were messing me up. And I when I tried to uninstall them, I got this error:

yo:gems root# gem uninstall capistrano -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Remove executables:
cap, capify

in addition to the gem? [Yn] Y
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions into the /System/Library/Frameworks/Ruby.framework/
Versions/1.8/usr/lib/ruby/gems/1.8/bin directory.

So I went to go and look at the above directory and it’s true that I don’t have write permissions because there was no bin directory there at all. After I created the bin directory, I was able to uninstall the gems. So now I should be able to uninstall the old stuff and put the newest files on.

Working with httpd.conf (from Google Cache)

Originally posted October 16, 2009

Comcast, SurfBoard SB6120 and Airport Extreme (from Google Cache)

Originally posted Nov. 28, 2009.

Business is Open!

I got my first consulting work check today. It wasn’t much, but it was something. I’ll have to build on this to get the business going.

A New Coldandheartless

It might be a bit obvious now, but my coldandheartless server died a painful death last week. I finally got around to seeing if I could fix anything and found that the system drive had completely failed. I tried rescuing files from the drive and it didn’t work. The good news is that I had the webpages on a separate disk which was still fine. So I could copy all of those files to my new server. Unfortunately, my wordpress database was not backed up (my bad) and I was unable to restore any of the files. The good news is that I did find one old backup (from sometime in 2008) that I could use to get back some of my posts. So there is now about a two-year gap in the blog. Oh well. Lesson learned. Now, I have to devise a new backup scheme. I haven’t yet decided how to do it, but I’m sure I’ll come up with something.

NXServer/Client Issues

If, say, your server crashed while you had an open nxclient session, you may have the problem of not being able to start another one. Here is the solution.

Mac Problems

I have had my MacBook Pro for just over a year now and have been very happy with it. All of that changed lately, after I tried to update the operating system to 10.5.2. This was just another update (though a large one), that I tried to install with software update. My first problem was that it didn’t work. After a while, the screen went black and basically nothing was happening. I forced a reboot and then, the computer would not boot at all. I left it in disgust for a while and then when I returned, it went on fine.

The XO Laptop

I just received my new XO laptop that I bought last month. It’s definitely for kids. I have pretty small hands and the keyboard on the laptop is small even for me. I’m pretty impressed with it though. It’s running a version of Fedora, Fedora core 7 I think. But it has a terminal to use and lots of other stuff. I think for kids in developing countries, where cost is the main factor, that these things will work pretty well. Though, it’s funny that it doesn’t come with any sort of documentation. The kid just has to play around with it. I like doing that, but I don’t know how many others do.

New Toy

Yesterday I bought two laptops through the “Give One Get One” program of “One Laptop Per Child”. One of the inexpensive laptops will be sent to me and the other goes to a needy child. Here’s the link:

Faster?

Today my dsl from Speakeasy was updated. The installation went ok. The guy from Covad was terriffic. He really knew his stuff and got everything set up properly, though it took a bit of time. The Speakeasy group, on the other hand, disappointed me.

Back to the Default Theme

As is obvious, I am back at the default theme for the blog. I liked the Beautiful Sunrise theme, but I got html errors sometimes when logging in for administrative purposes. That just bugged the heck out of me, so I went back to the default.

Don’t Like This Theme

I just noticed that my categories don’t show in this theme. So, now I don’t like it. I’m going to have to search for a new one.

Possibly Another iPhone Crack

Janet’s friend Becca is working with a Dutch doctor at the World Boxing Championships going on in Chicago right now. He was asking her about getting an unlocked phone that he could use in the Netherlands. I started laughing at dinner when she mentioned it and told her that I didn’t know about other unlocked phones, but that I could unlock an iPhone, if he wanted that. Becca didn’t think she did, so I asked John and he said that anyplace will sell and unlocked phone, it just costs a bit more. Though today Becca sent me a text message saying that the doctor would like an iPhone after all. I figured. They’re pretty cool. Anyway, if I crack an iPhone for him, he’s going to get me really good (maybe ringside) seats. So this might be fun. He’s supposed to buy it tomorrow, so maybe I’ll see the boxing later this week.

New, New Theme

The fact that my previous theme didn’t show the year of the post ended up really bothering me. So, I found a different new theme. This one does show the year and has a little menu for searching older posts, which I love. I’ve had this blog for over two years, so the listing of all the months was starting to get a little out of control. My only gripe with this theme is that there isn’t a link to login or for the admin stuff. Right now, I just put a wp-admin at the end of the blog link. I guess I can make a simple page that will take me to the login page.

My New Theme

As is obvious, I have changed the theme of my blog. I downloaded one called beautiful-sunrise-10 and really like the look of it. My one complaint is that the year of the post is not shown with the date. This may end up bugging me more than it does now. And if it does, I’ll probably go back to the default theme, which was ok. The other issue I have is that I’m getting errors like this:

WordPress Upgrade Failed

I tried to upgrade my wordpress to the new version and sadly it didn’t work. I ended up putting the new version in an entirely new directory. But then, I still was unable to change the colors or appearance of the new blog. I then decided that the upgrade was pointless because the main reason that I wanted to do it was to change the appearance. So, the look will remain the same.

WordPress Backup

I’m upgrading wordpress, the software that runs this blog and want to note the commands to backup the database.

iPhone to the Netherlands

John’s friend Mark is going back to the Netherlands today. But since his sim chip worked in John’s iPhone last night, he decided to buy himself one before leaving. So, I met him at John’s apartment and we cracked his phone and got it working. One note is that you should have internet access easily available to do this. Whenever iTunes starts, it wants to access the iTunes Store and you won’t get the annoying error messages if you’re hooked to the internet. Also, since we had no access, I had to use my laptop to “Create Network” to make a wireless network so that I could ssh to the iPhone. To do this, I also had to manually set the ip address, netmask and gateway on the iPhone. It all worked, but would have been quicker if we just had a wireless network to use.

iPhone and EDGE

John’s iPhone works fine on the T-mobile EDGE network. Just use these settings:

Breaking New Toys

My brother John got his second iPhone last week. He returned the first one because he got lousy reception from AT&T in his house. Now that he’s living in a new apartment, he tried it again. And, of course, he still has crappy reception with AT&T. So, he asked me if I’d help him to unlock his phone so that he could use it with T-mobile. Sounded like fun, so I was in. (One drawback was that I wasn’t working on my bathroom while doing this.)

Working with Ruby

To set up a new project: ruby cookbook (using cookbook as the project name)

Working with Ruby

Now that ruby and mysql appear to be working ok, I need to set up a new database. First of all, look at the config/database.yml file. The root user password (or whichever mysql user that you’re going to use) must be put in this file. Then, the database must be created:

Website Design

I need to do some major web design work, so I’m trying to decide how I’m going to tackle the project. I want to use a database and other dynamic stuff, so I was thinking that I’d use php and mysql. But after reading some webpages, I think I’m going to try to learn about Ruby on Rails. It’s more complicated to start off, but should do lots more of the things that I want. So, to get started, I’m loading it on my mac. First step is to load Xcode, then I have to fix the version of ruby that comes with the mac.

I am an idiot

So, after running the migration assistant and copying all of my data, everything was fine except for X11.  Since I use X11 at work on a daily basis, it was very important for me to get this installed.  I decided that I would delete everything I could find from the old X11 stuff and install it new.  Then, I also grabbed the latest updates from Apple.  Reboot and NOTHING.

New Laptop

My incredibly nice boss bought me a new MacBook Pro, which I just received today. I am now in the process of trying to set my new laptop up just like my old one. I thought I would really look forward to playing with my new toy, but I’m actually dreading it a little. My old PowerBook ran pretty much the same software, so things aren’t really going to be any different. I just have to schlep all my data from the old laptop to the new one. I did use the Apple Migration Assistant to move my programs and things. This worked ok. I still had to go through and delete old versions of things and old programs that I no longer wanted. My iphoto library has come over fine and I’m now waiting for my music library to come over.

Repairing Mac Disk (not boot disk)

Command to use to try to repair a mac disk

Using rsync on OS X

To use rsync to backup a directory on a mac, syntax is:

Server Upgrade

The machine hosting this blog has now been upgraded to Fedora Core 6. Coldandheartless has been down for a few days because I’m having an electrical problem at home. Right now, my house does not have a main circuit breaker for the entire house. My entire circuit panel is scheduled to be replaced next week. Anyway, since I was making some changes to the computer, I thought I’d upgrade it as well. So, thankfully, the upgrade from FC3 to FC6 went pretty well. There were very few things I had to fix.

Switch Installed

The new switch I ordered arrived the other day. I set it up and now am able to successfully have coldandheartless’ mail working. I’m still having some problems with getting webmail working, but since no one is going to be using that, I’m not overly concerned with this problem.

Upcoming Computer Projects

I’ve ordered a new switch to use so that I’ll be able to properly set up coldandheartless so that mail will work. This should be a pretty easy fix once the switch arrives.