Rails US State Select

select(:user, :state, [
['Select a State', 'None'],
['Alabama', 'AL'],
['Alaska', 'AK'],
['Arizona', 'AZ'],
['Arkansas', 'AR'],
['California', 'CA'],
['Colorado', 'CO'],
['Connecticut', 'CT'],
['Delaware', 'DE'],
['District Of Columbia', 'DC'],
['Florida', 'FL'],
['Georgia', 'GA'],
['Hawaii', 'HI'],
['Idaho', 'ID'],
['Illinois', 'IL'],
['Indiana', 'IN'],
['Iowa', 'IA'],
['Kansas', 'KS'],
['Kentucky', 'KY'],
['Louisiana', 'LA'],
['Maine', 'ME'],
['Maryland', 'MD'],
['Massachusetts', 'MA'],
['Michigan', 'MI'],
['Minnesota', 'MN'],
['Mississippi', 'MS'],
['Missouri', 'MO'],
['Montana', 'MT'],
['Nebraska', 'NE'],
['Nevada', 'NV'],
['New Hampshire', 'NH'],
['New Jersey', 'NJ'],
['New Mexico', 'NM'],
['New York', 'NY'],
['North Carolina', 'NC'],
['North Dakota', 'ND'],
['Ohio', 'OH'],
['Oklahoma', 'OK'],
['Oregon', 'OR'],
['Pennsylvania', 'PA'],
['Rhode Island', 'RI'],
['South Carolina', 'SC'],
['South Dakota', 'SD'],
['Tennessee', 'TN'],
['Texas', 'TX'],
['Utah', 'UT'],
['Vermont', 'VT'],
['Virginia', 'VA'],
['Washington', 'WA'],
['West Virginia', 'WV'],
['Wisconsin', 'WI'],
['Wyoming', 'WY']])
Posted on October 30, 2008 at 10:21 pm

Intrepid Ibex to have optional “Dark room” theme

UPDATE

There is an existing theme that is very similar to the Dark room theme, available for Ubuntu 8.04 Hardy Heron.

Check it out, Shiki-colors.

Good news, as the next release of Ubuntu (8.10) is going to be packaged with an optional theme to please the eyes. The default theme will still be the bright and orangy “Human” theme, with a few updates.. but you will be able to select the “Dark room” theme in System > Preferences > Appearance.

via [lifehacker]

Posted on October 17, 2008 at 11:16 am

OpenGL Matrix as Desktop Background

For the last month or so I’ve been using the GL Matrix screensaver built into Gnome as my desktop background, and I’m probably not ever going back to a standard background. Other then the fact that it only takes up 10~15 megabytes to run, it doubles as a screensaver. Finding good 1680×1050 backgrounds isn’t an easy task either..

At any rate, if you would like to use the GL Matrix screensaver as your background you must first disable the nautilus desktop:

gconftool-2 --type bool --set /apps/nautilus/preferences/show_desktop false

Now let’s make the desktop entry for our xserver autostart:

gedit ~/.config/autostart/glmatrix.desktop

Just paste the following into your editor and then save it:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=No name
Name[en_IN]=Desktop matrix
Exec=/usr/lib/xscreensaver/glmatrix -root
X-GNOME-Autostart-enabled=true

Once you have done that, restart Gnome by hitting Ctrl+Alt+Backspace.

Going back to the original nautlius desktop is simple:

gconftool-2 --type bool --set /apps/nautlius/preferences/show_desktop true && nautilus
Posted on September 28, 2008 at 8:35 pm

Preliminary Data with Migrations in Rails

At one time or another, you will most likely want your application to set-up with some preliminary data. One common example is a settings or options table within your database, or a default admin user that will be created upon install.

To get this done, is actually a lot easier then you may think..

Simply create a new migration such as:

script/generate migration add_default_user

Now all you need to do is add the data into the migration.

class AddDefaultUser < ActiveRecord::Migration
  def self.up
      User.create(
        :username => 'default', 
        :password => 'password'
       )
  end
 
  def self.down
  end
end

Once you have your migrations the way you like just run

rake db:migrate

to finish the job.

One thing to consider is deleting any records you have added to this migration in the self.down method, depending on your applications requirements. However, I think that this may also be accomplished when the (user) migration is removed.

Posted on at 8:20 pm

Put Sessions into Database with Rails

Adding sessions into the database is a great way to speed up your application, and it’s very easy to do in Rails 2.x. It can be done in the following, 3 easy, steps:

rake db:sessions:create

rake db:migrate

Now go into config/environment.rb and uncomment the following line:

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with 'rake db:sessions:create')
config.action_controller.session_store = :active_record_store

It’s is easy as that, now all of your sessions will be added to the database instead of files accessed at system level.

Cheers

Posted on August 30, 2008 at 4:33 pm

Connecting to an SMTP server using class.smtp.php

For one of my current projects I’m going to be writing a custom email class that will both send and receive email from an external/internal mail server. In order to make the module ultra-portable I’m going to be using an SMTP connection to take care of both tasks.

Right now I’m tutoring on the very excellent PHPMailer program that I’ve used many a time. It’s a very good module that has real good support backing it with frequent updates and bug patching via codeworxtech. The module I plan on building is going to be full PHP5, unlike PHPMailer which is written for PHP4. Ok so now we’ve got some background, let’s get to the code.

First thing we’ll need to load the file up and instantiate the class:

include('class.smtp.php');
$smtp = new SMTP();

Next we have to connect to the smtp server:

$smtp->Connect('mail.yourserver.com');

Finally we will authorize our smtp user via the Authenticate function:

$smtp->Authenticate('username', 'password');

Now, if we query the module for a connection status it should return true ( == 1 ).

echo $smtp->Connected();

So that’s all it takes to establish and log into an SMTP server via class.smtp.php. The module makes really good use of the fsockopen() function within PHP and I plan on taking a similar approach to my SMTP module.

Download class.smtp.php here.

Posted on June 26, 2008 at 10:21 pm

/girls

ls -a /girls | grep 'chill'
Posted on at 6:36 pm

geocode class

Came upon this rather slick geocode class written in PHP5 for use with google maps.

Thought I would share it.

Posted on June 21, 2008 at 9:51 pm

Paragraph breaks, #commentlist

Just fixed the weird spacing on the p tag within posts, and commentlist list-style-position to outside.

Should help clean things up a bit.

Posted on at 8:56 pm

$blog

if($blog->lastUpdate > '2 months') { 
echo 'DUDE WTF';
else {
echo 'n_n';
}
Posted on June 20, 2008 at 10:47 pm
Next Page >>