Category: Reminders to myself

Bak Kut Teh – Chinese Pork Rib Soup

Posted: January 27th, 2012     Food   Reminders to myself

I’ve been experimenting with making bak kut teh – basically pork rib soup. It’s super yummy. I finally got it down tonight.

Ingredients (serves 2)

  • ~900 grams of pork ribs
  • 1 bulb of garlic (yes, a whole bulb) – take out all the cloves and peel them
  • 5 star anise
  • 3 cinnamon sticks
  • 1 tablespoon of white peppercorns
  • 1 tablespoon of black peppercorns
  • 1 teaspoon of ginger
  • A pot of boiling water filled about 1/3 – enough to cover the pork ribs

Cut the pork ribs into individual pieces. Throw into boiling water. Throw in everything. Cover, cook for 1 hour. If you lose water while cooking, just add more. No biggie. This is not a precise dish.

Give each person a bowl of soup with pork ribs.

Serve with steamed rice. Make soy sauce available to put in the soup or rice.

The above is super easy and very very tasty.

Ubuntu 11.10 Sound Blaster X-Fi ridiculous workaround

Posted: January 24th, 2012     Reminders to myself

Since I installed Ubuntu 11.10, my Sound Blaster X-Fi sound card stutters and doesn’t play back sound. The way to fix this is to open terminal and run “ubuntu-bug”. That’s it. Plays back fine until next reboot.

Ridiculous bug.

Steak on Mushrooms with Red Wine Sauce and Caesar Salad

Posted: January 15th, 2012     Food   Rambling   Reminders to myself

One of my new year resolutions in 2012 is to try a new recipe every weekend. I decided this weekend to try a steak on mushrooms with red wine sauce. I found this recipe on Epicurious and adapted it to stuff I could easily buy at the local grocery store. I also made a caesar salad from scratch. This serves as a reminder to myself so that I can cook the same thing again.

Steak on Mushrooms with Red Wine Sauce

  • 3 tablespoons extra-virgin olive oil
  • 12 ounces mixed mushrooms, cut up
  • Table salt
  • Ground black pepper
  • 4 tablespoons butter
  • 1.5 pounds steak
  • 3 garlic cloves diced
  • 1x 6″ sprig rosemary
  • 1 cup red wine
  • 3/4 cup chicken stock
Heat 2 tablespoons of olive oil in skillet on medium heat. Sautee mushrooms, put on some salt and pepper. Put aside.
Melt about 1 tablespoon of butter in the same skillet. Put in steak, garlic and rosemary. Cook roughly 3 mins per side, until medium rare. Transfer steak, garlic and rosemary to cutting board.
In the same skillet, put in wine. Boil for 3 mins. Pour in chicken stock. Bring to boil for about 5 mins, boiling it down. Mix in 3 tablespoons of butter. Put in mushrooms. Season with salt and ground black pepper.
Put mushrooms and some sauce onto serving plates. Slice meat. Put on top of mushrooms.
Eat with a good, hearty red wine. We had a cabernet savignon.
 
 

Caesar Salad from Scratch

This recipe is adapted from this one.
  • 2 egg yolks
  • 2 tablespoons dijon mustard
  • bacon bits (buy a packet)
  • 4 cloves chopped garlic
  • 4 tablespoons balsamic vinegar
  • 3 tablespoons lemon juice
  • dash of worcestershire sauce
  • 1 cup olive oil
  • 2-3 tablespoons of parmesan cheese
  • Romain lettuce
  • Croutons
Mix egg yolk, mustard, bacon, garlic, balsamic vinegar, lemon juice and worcestershire sauce in bowl. Slowly add olive oil while mixing. Add parmesan cheese.
Wash and chop romain lettuce. Spin in salad spinner.
Serve as a bed of lettuce and croutons. Let guests put on the dressing themselves.
The above is awesome. Very tasty caesar salad and much much better than store bought caesar dressing.

Rails, Bootstrap and will_paginate

Posted: December 29th, 2011     Reminders to myself   Web Development

If you’re using Ruby on Rails, you’ll likely use the will_paginate plugin. If you use Twitter’s Bootstrap CSS framework as well, you’ll notice that the pagination is all messed up. This gist fixes it:

  # application_helper.rb
  # https://gist.github.com/1205828
  # Based on https://gist.github.com/1182136
  class BootstrapLinkRenderer < ::WillPaginate::ViewHelpers::LinkRenderer
    protected
 
    def html_container(html)
      tag :div, tag(:ul, html), container_attributes
    end
 
    def page_number(page)
      tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
    end
 
    def gap
      tag :li, link(super, '#'), :class => 'disabled'
    end
 
    def previous_or_next_page(page, text, classname)
      tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
    end
  end
 
  def page_navigation_links(pages)
    will_paginate(pages, :class => 'pagination', :inner_window => 2, :outer_window => 0, :renderer => BootstrapLinkRenderer, :previous_label => '&larr;'.html_safe, :next_label => '&rarr;'.html_safe)
  end

Deploying Ruby on Rails 3.1 on Ubuntu

Posted: December 27th, 2011     Reminders to myself   Web Development

This serves as a reminder for me on getting Ruby on Rails 3.1.3 running on Ubuntu (tested on 10.01 LTS).

Install git using apt-get:

sudo apt-get install git-svn

Install build dependencies:

sudo apt-get install gcc g++ build-essential libssl-dev libreadline5-dev zlib1g-dev linux-headers-generic libsqlite3-dev

Install rvm (Ruby Version Manager)

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

Put RVM into .bash_rc file so that you can run it easily:

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_rc

Reload bash settings:

source ~/.bash_rc

That should install rvm. Now you can use it to install Ruby:

rvm install 1.9.2

Make sure to switch into the correct version of Ruby:

rvm use 1.9.2

Install Rails:

gem install rails

This takes a while….

Install Apache:

sudo apt-get install apache2

Install Phusion Passenger:

gem install passenger
passenger-install-apache2-module

Follow the instructions on screen.

Setup Apache virtual hosting the way you normally do. Make the DocumentRoot the rails public directory.

<VirtualHost *:80>
        ServerName ec2-107-21-154-173.compute-1.amazonaws.com
        RailsEnv production
        DocumentRoot /home/ubuntu/depot/public
        <Directory /home/ubuntu/depot/public>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
 
</VirtualHost>

When deploying an app make sure to run bundle install to make sure all the dependencies are installed. This includes mysql, etc.

Rails 3.1 needs a Javascript runtime.

Add this to your gemfile:

gem 'execjs'
gem 'therubyracer'

Run:

bundle install

Make sure to setup your DB using:

rake db:setup RAILS_ENV="production"

Restart apache:

sudo service apache2 restart

Load your browser and visit the site. Hopefully it works, if it doesn’t, check logs/production.log and trace from there.

Asset Pipeline Gotchas

The new asset pipeline in Rails may cause your app to fail.

When you deploy an app, make sure that you precompile the assets using:

bundle exec rake assets:precompile

If you are including css files that are not in your application.css manifest, you need to manually include them in your config/environments/production.rb:

config.assets.precompile += ['960.css']

Note: After recompiling assets you will need to restart your rails app. Do this either by restarting apache or creating/modifying “tmp/restart.txt” in your rails app. Passenger will look at the timestamp for restart.txt and restart rails accordingly.

Rcconf – Tool to edit Linux boot services

Posted: November 15th, 2011     Reminders to myself   Web Development

I know I’ll forget this because I only have to edit runlevel services once in a blue moon. Use a tool called rcconf. You may have to install it using apt-get.

VBulletin single sign on

Posted: November 1st, 2011     Reminders to myself   Web Development

I figure I would write this because I searched around for a suitable solution and it’s quite frustrating to find. VBulletin (the company) runs a very tight community and generally don’t help people who want to hack or extend the software. In my case, I am integrating VBulletin into a client’s custom application and trying to get single sign on to work. Do a search and you’ll find VBulletin telling people who have asked the same question “we won’t help you. Go to vbulletin.org.” When you do get to vbulletin.org, you can’t see any code because you’re not a licensed user. Very frustrating.

So…here it is.

VBulletin stores two cookie vars that can be used for single sign on:

  • bb_userid – look in the ‘user’ table, it is the field ‘userid’
  • bb_password – md5(user.password . COOKIE_SALT)

When a user visits the forum, it can login based on the above.

Once you authenticate that the user can login in your app, read the user row from the vbulletin database. Take the password (which is already hashed) and concatenate the COOKIE_SALT constant to it. You can find COOKIE_SALT defined in /includes/functions.php. You then md5 hash this string and set the cookie as bb_password.

When setting your cookie, remember to set the domain to one that vbulletin can read. If you’re using different subdomains (e.g.   www.leonardteo.com for the main app and forums.leonardteo.com for the forums) simply set the domain to “.leonardteo.com”. In VBulletin, you’ll want to go into the admincp and change the cookie domain to the same.

By setting these two cookies, you should be able to login with your app and it will automatically login to VBulletin as well.

Logout
Make sure you set the logout routine as well. Your logout routine needs to clear three cookies:

  • bb_userid
  • bb_password
  • bb_sessionhash

Enjoy.

Flush DNS Cache in OS X

Posted: July 26th, 2011     Reminders to myself

Reminder to self….

sudo dscacheutil -flushcache

Deleting files in Unix in 1 command

Posted: July 15th, 2011     Reminders to myself   Web Development

I find myself constantly doing this with files that some OS’s and programs spew all over a directory structure. E.g. .DS_Store, .svn, etc.

find . -name "filename" -exec rm -rf {} \;

Running Nginx and PHP5 on Ubuntu

Posted: July 8th, 2011     Reminders to myself   Web Development

Very simple to set up Nginx, PHP5 and MySQL on Ubuntu. Hats off to the Ubuntu guys for making it so simple.

  1. sudo apt-get install nginx
  2. sudo apt-get install php5-cgi  (you might need to also need to install php5)

Test that nginx works by opening your browser and going to http://localhost/

Edit /etc/nginx/sites-available/default

Search for the bits that say “# pass the PHP scripts to FastCGI server….” uncomment those configuration bits.

Create index.php in /usr/share/nginx/www/

In it, put:

 <?php  phpinfo();

In a web browser go to http://localhost/index.php     It should give you a “bad gateway error”. This is because php fastCGI isn’t running. Go back to your terminal and type “php5-cgi -b 127.0.0.1:9000 &”  This should start php fastCGI in the background. Now visit http://localhost/index.php again and you should see the php info screen.

 
Leonard Teo
CEO, Ballistiq
Montreal, Canada