Building Web Applications

I’ve been working on a series of posts on my consulting site, Red27.net, about building web applications. These posts are really focused toward less technical folks. However, I wanted to post about it here to get any additional feedback people might have. Also, feel free to forward on to people that might find the info useful. Here’s a summery of the first few posts.

Internet Basics: Websites

This targets the basics of websites, like domain names, hosting, DNS, the basic connectivity of the web.

I know we’re starting at a really basic level, but I want to build a solid foundation for the coming information. The internet is comprised of servers, large computers, and users, you.

Internet Basics: Email

This one is short and just talks about the importance of having an email with your domain and the power of Google App for your Domain.

What makes web applications work?

This post gets more into the programming aspects of web applications, HTML, CSS, JavaScript on the client and PHP, Python, Ruby, C#, Java on the server.

http://red27.net/2010/12/internet-basics-email/

Web applications are a client/server based model. The client is your web browser and the server is the web application server. There are a lot of technologies that make web applications work, but there are a few primary ones that we’ll talk about here.

There will be more coming in the next few weeks and I’ll do another post here in a month or so. Please do forward on and post any feedback.


Setting Up My Fujitsu ScanSnap S300 in Ubuntu 10.10

Mostly a post to help my future self and others trying setup a ScanSnap S300 in Ubuntu

Things should mostly be setup by default, but there is one tricky bit. You need a file from the windows drivers. I had an old hard drive w/ my previous install to copy from. You might need to set it up in a virtual machine or another windows machine to get the file.

Make a directory for the file at /usr/share/sane/epjitsu/

Copy from C:\Windows\SSDriver\S300\300_0c00.nal to /usr/share/sane/epjitsu

chmod 755 /usr/share/sane/epjitsu/300_0c00.nal

Make sure you scanner is found using

sane-find-scanner

If it is you can do scanimage -L or sudo scanimage -L to see if things are working.

HTH someone

http://www.documentsnap.com/fujitsu-scansnap-in-linux/


Tips from the MountainRB ruby on rails workshop

Yesterday I was at the MountainRB ruby workshop, which was basically an intro to rails class. It was a really good workshop and here are some tips I picked up.

Cucumber

Change the config/cucumber.yml file to display pretty output, making it easier to see the failed step.

default: -format pretty

use Background: in cucumber features for tasks that need to happen for every scenario. Use just like Scenario

Background: Make sure that we have a topic
  Given I go to the topics page
  And I follow "New Topic"
  And I fill in "Title" with "Rails Fixtures" 
  And I fill in "Description" with "Introduce how to add test data with fixtures."
  And I press "Create"

Rails templates

When you create a new rails application you can specify a template that runs after the initial generation. It can handle a lot of the initial setup. Here’s the one used used in the workshop http://gist.github.com/609269.txt

rails new APP_NAME -m TEMPLATE_URL

View a models attributes

From inside the rails console you can view a models attributes by calling class on an instance of the Model.

ruby-1.9.2-p0 > (User.new).class

Routes

rake routes will show the routes defined for the application.

        login        /login(.:format)          {:action=>"new", :controller=>"user_sessions"}
         logout        /logout(.:format)         {:action=>"destroy", :controller=>"user_sessions"}
user_sessions GET    /user_sessions(.:format)  {:action=>"index", :controller=>"user_sessions"
user_sessions POST   /user_sessions(.:format)  {:action=>"create", :controller=>"user_sessions"}

Notes

Rails will cascade saves in a transaction by default

The resource generation option will create the model and migration, while adding a blank controller and empty views directory.

rails generate resource

heroku open shows the current heroku app in the browser.

Resources

http://bit.ly/ruby-resources – Resources from DevChix

http://railsapi.com – Rails documentation

http://boulderruby.org – Boulder user group

http://groups.google.com/group/derailed – Denver user group

http://RailsBridge.org - an inclusive and friendly Ruby on Rails community


Resize/Clone a VirtualBox hard disk with the current snapshot

After wasting a ton of time, I’m noting this here to hopefully help myself or someone else in the future.

Making the new virtual hard disk

In VirtualBox open the virtual media manager and create a new disk with the larger size. Note it’s location.

Open a command prompt to c:\program files\oracle\virtualbox and run

VBoxManage showvminfo <Machine Name>

Find the primary master line, and note the UUID.

Clone that using your UUID and the path to the new disk

VBoxManage clonehd 73880a2b-ba46-459e-b71b-816ceadecb5a c:\users\dusty.virtualbox\harddisks\CloneDisk.vdi –existing

Resize

There may be better instructions elsewhere, but this worked for me.

  1. Attach a Linux live cd to the cdrom of the machine.

  2. Change the hard disk image to your new image file.

  3. Boot

  4. Start GParted

  5. Right click the swap and select swapoff, note the size and delete.

  6. Delete the extended partition.

  7. Resize the primary partition.

  8. Add an extended partition back.

  9. Add a swap partition back.

  10. Apply the changes.

  11. Shutdown, remove the live image from the machine, restart.

Reference:

http://forums.virtualbox.org/viewtopic.php?t=585

http://forums.virtualbox.org/viewtopic.php?f=1&t=791&p=103299#p103299

http://www.attackr.com/resize-an-existing-vdi-virtualbox-image-easily/


WordPress Quick Install and Setup On Ubuntu

Here’s some quick notes for installing WordPress on Ubuntu 10.

Official install doc: http://codex.wordpress.org/Installing_WordPress

I choose hosting on Linode, which has been an awesome experience so far, they have really good help guides too.

Server

You’ll need MySql, PHP, Apache installed.

apt-get install apache2 apache2-doc apache2-utils

apt-get install libapache2-mod-php5 php5 php-pear php5-xcache php5-suhosin php5-mysql

apt-get install mysql-server

Run MySql Secure Installation

mysql_secure_installation

Enable Rewriting

a2enmod rewrite

Enable image support for php.

sudo apt-get install php5-gd

/etc/init.d/apache2 restart

Get It

wget http://wordpress.org/latest.tar.gz > tar -xzvf latest.tar.gz

Database

mysql -u adminusername -p

CREATE DATABASE databasename;
 
GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"localhost"
IDENTIFIED BY "password";
  
FLUSH PRIVILEGES;

Setup Apache

Create the web root directories

mkdir /var/www/red27.net/public_html -p <br />mkdir /var/www/red27.net/logs

Create an apache virtual host config

See what’s there in the sites-available

ls /etc/apache2/sites-available/

Copy an existing config

cp /etc/apache2/sites-available/candland.net /etc/apache2/sites-available/red27.net

Edit to match the correct location.

vim /etc/apache2/sites-available/red27.net

Copy the WP files to the site root

cp downloads/wordpress/* /var/www/red27.net/public_html/ -r

Change owner

chown -R www-data /var/www/red27.net/public_html/

Config WordPress

Rename the wp-config.php file

mv /var/www/red27.net/public_html/wp-config-sample.php /var/www/red27.net/public_html/wp-config.php

Edit the wp-config.php, set the correct db connection values, and replace the security lines from here

vim /var/www/red27.net/public_html/wp-config.php

Enable the site

a2ensite red27.net

Restart apache

/etc/init.d/apache2 restart

Visit the site and configure WordPress!


AutoTest Powershell Script

This script will watch a source directory for changes, just *.cs files in this case and then execute a script when a change is detected. This handles the issue of the change event being triggered twice for one change. I’m just calling my default Psake script, but you can put any build/test script call in place of it.

function watch-folder {
    param([string]$path, [string]$filter = "*.*", $command)
    get-eventsubscriber -force | unregister-event -force
    $global:lastGen = [datetime]::Now
    $expandedPath = convert-path $path
    write-host "Watching" $expandedPath\$filter
    $fileSystemWatcher = new-object System.IO.FileSystemWatcher
    $fileSystemWatcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite
    $fileSystemWatcher.Path = $expandedPath
    $fileSystemWatcher.Filter = $filter
    $fileSystemWatcher.IncludeSubdirectories = $true
    $action = {
        $timeGenerated = $event.TimeGenerated

        if ($timeGenerated - $global:lastGen -gt (new-timespan -sec 1)) {
            write-host ***************************************** -foreground Green
            write-host $eventArgs.FullPath -foreground Green
            write-host $eventArgs.ChangeType at $event.TimeGenerated -foreground Green
            write-host TESTING $event.MessageData -foreground Green
            $result = &amp; $event.MessageData | out-string -stream
            if ($LastExitCode -gt 0) {
                $result | select-object -last 70 | out-host
                write-host FAILED -foreground Red
                write-host ***************************************** -foreground Red
            }
            else {
                write-host SUCCESS -foreground Green
                write-host ***************************************** -foreground Green
            }
        }

        $global:lastGen = $timeGenerated
    }
    [void](Register-ObjectEvent -InputObject $fileSystemWatcher -EventName Created -SourceIdentifier ThisFileWatcher -Action $action -MessageData $command)
    [void](Register-ObjectEvent -InputObject $fileSystemWatcher -EventName Changed -SourceIdentifier ThisFileWatcherA -Action $action -MessageData $command)
    [void](Register-ObjectEvent -InputObject $fileSystemWatcher -EventName Deleted -SourceIdentifier ThisFileWatcherB -Action $action -MessageData $command)
}

watch-folder ".\src" "*.cs" {
  psake
}

wait-event "ctrl-c"

Thanks to this post PowerShell, events and file watcher.


ViEmu + ReSharper + VS2010 Review

I’ve been using the ViEmu plugin with ReSharper in VS2010 for a couple of weeks now. Overall, I really like combo. However there are a few things that annoy me with ViEmu. The selections modes are not the same between ViEmu and selecting text with the mouse, looks like a licensed copy might fix that. The replace function is missing the ‘c’ confirm option. The other things are mostly key bindings that ViEmu overrides, this can be changed with the _viemurc file. You need to create that file in the c:\users[username] directory, then add the bindings you’d like. I’ve added some for ReSharpers goto type command, and changed Ctrl+V back to paste.

map <C-n> gS:vsc ReSharper.ReSharper_GotoType<CR>
imap <C-n> gS:vsc ReSharper.ReSharper_GotoType<CR>
map <C-v> gS:vsc Edit.Paste<CR>

BYW, You can find the commands you’re looking for from the VS toos:options:keyboard menu.

I’m think I’m going to get a license for ViEmu, anyone else have any tips for it?


Brutalist Framework