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.
Nerd - Developer - Entrepreneur
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.
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.
One of the biggest frustrations that I have as a professional web developer is Internet Explorer – more specifically IE8, which is currently refusing to die because it is “good enough but not quite”. Here we are, trying to move forward with new technology on HTML5 standards that work across most modern browsers, except things don’t look or work quite right in IE8. Corporations still give out computers to employees with IE8 pre-installed. Enough is enough. Let’s make 2012 the year that we, as a body of web professionals, begin to retire IE8.
From now on, every site that I deliver for clients will have, by default, an IE8nomore header (or variant), which will only show up when a user with IE8 or less browses to the site. If a client specifically wants me to support IE8, they will need to pay extra for it. It’s that simple. Clients need to be educated that IE8 is just bad software. If they have the chance to tell you that a site you created doesn’t work in IE8, you’re too late. You need to put the header in by default so that when they, or their colleagues browse to your site, they immediately see that their browser is outdated. It’s psychological. They need to upgrade. You don’t need to lower your standards.
If you’re a professional web developer, make it your resolution. Let’s rid the world of standard-less browsers. Let’s nail IE8 and please be done with it.
IE8nomore header
IE6nomore header (the original)
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 => '←'.html_safe, :next_label => '→'.html_safe) end
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.2Make sure to switch into the correct version of Ruby:
rvm use 1.9.2
Install Rails:
gem install railsThis takes a while….
Install Apache:
sudo apt-get install apache2
Install Phusion Passenger:
gem install passengerpassenger-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 installMake sure to setup your DB using:
rake db:setup RAILS_ENV="production"
Restart apache:
sudo service apache2 restartLoad your browser and visit the site. Hopefully it works, if it doesn’t, check logs/production.log and trace from there.
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:precompileIf 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.
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.
I’m doing another course at Concordia to keep my brain active. This term, I was asked to implement the Video Textures SIGGRAPH paper by Schodl et al (2000). Schodl’s paper introduces a new medium called a “video texture” (not to be mistaken with a texture map that uses an video file as its source). Basically the paper involves taking arbitrary input video footage and turning it into infinitely looping videos. I implemented the video texture synthesis in C++ on Mac OS X, utilizing the OpenCV framework. I also integrated the video textures in an OpenGL application.
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:
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:
Enjoy.
I’ve been coding PHP for a long time. Since 1999 actually. That means that for most of my adult life, I’ve been working with this programming language in the web-o-sphere in general. I’ve gotten to work on many applications and continue to do so. I’ve also gotten to use many off-the-shelf apps including WordPress, Expression Engine and VBulletin. Today, I’d like to rant about two conventions that these all have in common, and why we need to be rid of them.
This happens in WordPress, Expression Engine and VBulletin. Basically, the idea is that all settings must be stored in a database table because…well…it’s supposed to be easier. The user updates a setting in the admin control panel, and it stores those settings in a database. The problem with storing paths in a database like this is that it makes the app less portable. For example, say you want to move an installation of any of the above-said apps to a different domain, it’s not as simple as tarballing the entire application, running mysqldump and restoring on the other side. You’d think that changing the config file would get it to work but this is only half the battle. WordPress and Vbulletin, for example, stores the actual URL of the application in the database, so when it does any redirect (e.g. when you login to the admin control panel), it will redirect to your OLD site.
WordPress does something else that I consider evil. When you upload images, it stores the full web path in the meta data. This is also a problem when you move to another domain because all your images are now pointing to the old domain. I’ve had to write scripts that change all metadata values and wordpress settings when porting from one domain to another. It’s annoying.
Why is this an issue though?
Development. For most people, the above shouldn’t matter because you have a blog that you installed on a webserver; you update it and all’s well. You never run a local copy of the site for development. As a developer though, I have to usually get local and staging copies of the website running. This means that I’m constantly having to do all kinds of shenanigans to get these instances running on different servers.
I used to think that this was simply a bad design limited to a couple of web apps but it seems like a whole plethora of web apps suffer from this. While working for Gnomon, we bought into Expression Engine, thinking that this would be the silver bullet that kills WordPress. Nada. EE is just as BADLY designed! (not just for the reasons above, but many others)
PHP has a neat function called serialize(). It takes data and turns it into a string. The data can be read back in easily. This is great for many things. For example, if you have user accounts and each user has their own settings, it’s probably useful to just serialize their settings data and save it as a single string in the database.
Crucial site settings though, should NEVER be serialized in a database. I would go as far to say that as a rule of thumb, if the setting is crucial enough to make or break an installation of an app, it should be in a config file. This relates to my first rant as well. Many settings can be put in the database, but some settings (like paths), should just be in flat config files that can be quickly changed when moving the app.
I was absolutely shocked when using Expression Engine that crucial app-breaking settings like upload paths were not only stored in the database but SERIALIZED. I ended up writing a script that can move an entire installation of EE from one server to another in a single command line, and it’s really long because it had to connect to the database, unserialize the data, make modifications, re-serialize the data, write back to database.
It shouldn’t be this hard.
My recommendation is to follow this rule of thumb: if the setting is crucial enough to make or break an installation of an app, it should be in a config file.
Absolute paths like upload paths, etc. should be stored in a config file.
If the application needs a site-wide URL, this should be in a config file.
Individual asset links in the database should link to the relative location (i.e. minus the hostname.) e.g. not http://leonardteo.com/image1.jpg, but /image1.jpg instead. Even better, just store ‘image1.jpg’ and use a configuration setting to determine what the path to that image is.
The litmus test should be: Tarball an application, dump the database. Copy everything to a different computer/hostname. Restore everything. If you can’t get the site up and running again without accessing and changing values in the database, fail.
On a closing note, one of the benefits of running critical site settings in config files, is that you can switch configurations based on the hostname.
E.g. in your config file:
switch ($_SERVER['SERVER_NAME']){
case 'cgacontest.local':
define('SITE_MODE', "LOCAL");
break;
case 'cgacontest.test':
define('SITE_MODE', "TEST");
break;
case '3dsmaxdesign.cgarchitect.com':
define('SITE_MODE', "LIVE");
break;
}
With the above code, we can switch between site modes and run different configurations automatically based on the hostname. This means that when it comes to deployment, I simply push any changes to the server without having to change configuration.