Recipe: Egg fried rice


  • 2 eggs
  • 1 green onion
  • 1/2 tbsp olive oil
  • 1 bowl cooked brown rice

Wash the green onion; chop it into 1/2 cm. long bits. Beat the eggs lightly, add the onion to eggs, mix them and add a pinch of salt. Cook the egg on a nonstick pan at medium/high flame with oil. Fry the eggs similar to scramble eggs. Add 1 bowl of cooked white rice (about the same amount as it was of eggs)


Button for getting a PDF back (Zend/PHP)

When using PHP with Zend, the requests for having a button that creates a PDF are like a train that’s never late. Often there are two cases:

  1. Easy: The PDF is created on the backed and stored there. Just pick your favorite PDF library (I use tcpdf). Then the file can be saved on the server, and you can keep track of it by creating a database table for it. For the purpose of downloading it, just make a route (and action) on Zend that handles the request, normally by ID.
  2. Easier but with a catch. The PDF is created every time and not stored on the server. Once that you verify that the PDF object was created, TCPDF has an output method that makes the response for you. The catch is that on the controller you need to set the return view model to terminal (via setTerminal(true)), and directly get out of the controller’s action via return $this->getResponse(); Otherwise, the PDF will contain (after EOF) some HTML, which is not clean, and it could trigger errors (such as unable to find the phtml for the action).

For option 1, consider having a separate class for handling the PDF files together with their corresponding database table, because, if later you have other sections that will make PDFs, you would not want to be repeating such code again and again.

Please upload this excel file to the database

An occasional request to a website I maintain at a non-for-profit organization is to upload records to a MySQL database. The data is given to me as an attachment in an Excel file. These are the steps that get the task done in the fastest time.

  1. Make sure that I get the file to my Gmail account (either directly, or I just forward it from my .edu email to my personal Gmail).
  2. Click on the attachment (in Gmail), not the download, but the “Edit with Google Sheets” button.
  3. As needed, “fix” data, such as date values, and remove formatting (if any).
    1. Arrange the columns to match those of the table into which you want to load the records to.
  4. Download (from Google Sheets) as tab-separated values. “File” -> “Download as” -> “Tab-separated values (.tsv, current sheet)”
    • The benefits are:
      • not having to open Excel locally at all (or OpenOffice, LibreOffice)
      • not having to deal with windows/unix line endings upon exporting from your favorite (local) spreadsheet
  5. Open the terminal (ideally OSX, or Linux, but cywin gets the job done too under Windows).
  6. Get rid of the first line, which usually is the header line.
  7. “Copy” the file to the linux box where MySQL is located (such as via scp, or sftp).
  8. Login to the linux box where MySQL is located.
  9. Backup the database (and copy the backup to another linux box before the next step)
  10. Login to MySQL, and use the command LOAD DATA INFILE to load the data
    • Example: Load data infile ‘/tmp/strains.txt’ into table strains;
    • Pay attention to the message indicating how many records were inserted. It should match the number of records that you expected to insert.
    • Pay attention to the other messages such as “Warnings”. When “Warnings” is not a zero, then do a command: “Show warnings;” to help you identify what the problem was. It could be that lines are truncated because the field in the table was too small, or that you don’t have a value in a column that does not accept nulls.
  11. Check your data. Then tell your boss (or yourself) that the task is “done”.
  12. Disadvantages of this approach:
    • Your google-sheets will be cluttered with the opened excel files. (Not easy to get rid of those things, I’ve tried and just decided not to bother; if needed, just rename the file to something that starts with “z_useless_” so that it is listed alphabetically at the end, and you can remember that you don’t need it).
    • You may have to read the additional options of the LOAD DATA command, when you have columns that have values that depend on other fields. However, MySQL is quite powerful, with functions for strings, and simple arithmetic.

Installing Ubuntu on an old Macbook

I have an old macbook (year 2006) that had a crashed hard-disk over two years ago. At the time, the new disk with a clean install of OSX was very fast to start up, and it was not even a SSD.

The laptop was functional in my secondary office, at which I go maybe once at week. Normally, I’d use it to connect to a random linux server via the terminal.

However, it was clear that the laptop was unusable for web browsing due to the lack of software updates available.

I attempted to install but it only works for 64 bits. On the other hand, Ubuntu works, and here are a few of my notes:

  • Etcher is quite amazing for making a bootable USB drive: select the image file, then the destination USB drive, and click on the “flash” button.
    • This video was very useful: link
  • Etcher would not do the trick when trying to make a bootable USB for Unbuntu. Then I tried UNetbootin, which would not display the USB disk.
  • I had to “fix” the USB disk (erase volume, unmount, erase partition) via command line usage of diskutil
    • diskutil list: shows you the list of disks
    • diskutil eraseDisk: did not work, gave me an error on: Unable to begin erase operation: The target disk is too small for this operation (-69771)
    • diskutil eraseVolume FAT32 ABCD /dev/disk2: did the trick
    • diskutil unmount disk2: this is needed for the next step to work
    • sudo diskutil partitionDisk disk2 1 MBR FAT32 ABCDE R
    • Kudos to a stackExchange response (great, as usual) that was key to solve this
  • The USB drive then showed up on UNetbootin, for which I recommend downloading separately the .iso file (before using UNetbootin).

Cooking meals for an epsilon

My Statistics professor at graduate school said that stats scientists refer to their children as epsilon, because they are tiny.

Main dishes:

  • Turkey corn dog
  • Pasta (with/without beef)
  • Chicken nuggets
  • Steak fingers
  • Meatballs with gravy
  • Turkey and cheese roll ups
  • Fish sticks
  • Meatlof
  • Diced chicken
  • Spaghetti with meatballs
  • Soft beef tacos
  • Baked chicken strips
  • Salmon
  • Mac and cheese (avoid it)
  • Pizza (avoid it)


  • Baked fries
  • Tator tots
  • Bread
  • Rice
  • Pinto beans
  • Mashed potatoes
  • Corn


  • Mixed veggies
  • Salad
  • Green beans
  • Steamed broccoli
  • Fruit slices