Welcome, Guest :: Blog Home | Login | Register

Articles
Mono 2.6 + MonoDevelop 2.2 on openSUSE 11.2
2009-12-16 11:00:21 Permalink

Tags: opensuse mono asp .net


Mono 2.6 has been released this morning. This is great news for those of us interested in developing .NET web framework on dedicated Linux workstations, such as the most excellent OpenSuse 11.2.

Installation is simple using zypper from the command line, as follows.

Code:
zypper ar -f -n Mono http://download.opensuse.org/repositories/Mono/openSUSE_11.2 repo-mono

Code:
zypper mr -p 10 repo-mono

Code:
zypper refresh

Code:
zypper dup -r repo-mono




To run asp.NET applications on your Linux box, you will need to install mod_mono for Apache2.

On OpenSuse you can run:

Code:
zypper install apache2-mod_mono


[ Comments (0) ]


Forcing Git To Ignore File Mode Changes
2009-11-22 18:54:22 Permalink

Tags: git


Quick note on Git file mode changes...

In situations which require you to change the file mode on your local git repository (example: if you mount a local machine and need to set mode to 777 for user to be able to write file modifications), Git will recognize all files as modified (git status) after mode changes. Here's how we can force Git to ignore mode changes.

Code:
git config core.filemode false


Simple!

`Stephen

[ Comments (0) ]


Jquery Ajax Forms For Catalyst Apps
2009-10-11 16:28:02 Permalink

Tags: catalyst jquery ajax


I've been working on a private, personal project for a few weeks now and would like to share some simple steps for slick, "in-place" form submissions via Jquery. For an example, you can click on either the "Resume" or "Code Samples" links to the left. Both screens require the user to enter a valid email address in order to view the main content.

The form used for this task will validate input data, submit validated data to a catalyst controller, and then either, depending on the response from the controller, display the main content or show an error. All this is done "dynamically" from the same screen. The main effect of this setup is very much like a native desktop client application, rather than the classic web based application work flow.

In my private (unreleased) application I am taking this process much farther, resulting in an extremely powerful and efficient web base application than runs similar to many desktop applications.

First we set up the jQuery script:

Code:
<script type="text/javascript">

$(document).ready(function(){
  $('#emailLoading').hide();
  $('#saving_settings').hide("fast");
  $('#email_valid').hide("fast");
  
  $('#email').blur(function(){
    $('#emailLoading').show();
    if( !$('#email').val() ) {
      $('#emailResult').html('
<span style="color:#f00;font-weight: bold;font-size:12px;">Required field</span>');
      $('#emailLoading').hide();
    } else {
      $.post("[% Catalyst.uri_for('/formvalidation/email_session') %]", {
	  email: $('#email').val()
      }, function(response){
	if( response == 'FAIL' ) {
	  $('#emailResult').html('
<span style="color:#f00;font-weight: bold;font-size:12px;">E-mail not valid</span>');
	  $('#emailLoading').hide();
	} else {
	  $('#emailResult').html('<img src="[% Catalyst.uri_for('/static/images/accepted.png') %]">
<span style="color:#0c0;font-weight: normal;font-size:10px;">E-mail valid</span>');
	  $('#emailLoading').hide();
	}
      });
    }
  });
  
  $("#email_session").bind('submit', function(event){
    $('#email_form').hide("fast");
    $("#saving_settings").show('fast');
    $.post("[% Catalyst.uri_for('/formvalidation/email_session') %]", {
	email: $('#email').val(),
	store: 1
    }, function(response){
      if( response == 'FAIL' ) {
	$('#email_form').show("fast");
        $("#saving_settings").hide('fast');
	$('#emailResult').html('
<span style="color:#f00;font-weight: bold;font-size:12px;">E-mail not valid</span>');
	$('#emailLoading').hide();
      } else {
	$('#email_valid').show("fast");
        $("#saving_settings").hide('fast');
      }
    });
    return false;
  });
  
});

</script>


Next we setup the form:

Code:
<fieldset>
  <legend>jQuery Catalyst Forms</legend>
  
[% IF Catalyst.session.email.valid %]
  
  <!-- User has access, show protected screen -->
  Main content...
  
[% ELSE %]
  
  <div id="email_form" style="height: 500px;">
    <form id="email_session">
  <table border=0>
    <tr>
      <td colspan=3>Please enter e-mail address to continue:</td>
    </tr>
    <tr>
      <td colspan=3> </td>
    </tr>
    <tr>
      <td><input type="text" name="email" id="email">
          <span id="emailLoading"><img src="[% Catalyst.uri_for('/static/images/loader.gif') %]" alt="..." /></span>
      <span id="emailResult"></span></td>
      <td style="text-align: left;vertical-align: top;"><button id="x_submit">Submit</button></td>
      <td>  </td>
    </tr>
  </table>
    </form>
  </div>
  <div id="saving_settings">Saving Settings <img src=[% Catalyst.uri_for('/static/images/ajax-loader.gif') %]></div>
  
[% END %]
  
  <div id="email_valid">
    <!-- User has access, show protected screen -->
    Main content...
  </div>

</fieldset>


Next we setup a new Catalyst controller, mine is called FormValidation.pm, and add the following code:

Perl Code:
package stephensykes::Controller::FormValidation;

use strict;
use warnings;

use parent 'Catalyst::Controller';

=head1 NAME

stephensykes::Controller::FormValidation - FormValidation Controller

=head1 DESCRIPTION

Used to validate forms via jQuery.

=head1 METHODS

$.post("[% Catalyst.uri_for('/formvalidation/email_session') %]", {
    email: $('#email').val()
}

=cut

=head2 index

=cut

sub email_session : Local {
    my ( $self, $c ) = @_;
    
    my $email = $c->req->param('email');
    my $store = $c->req->param('store');
    
    my $response;
    
    use Email::Valid;
    
    my $email_valid = Email::Valid->address( -address => $email, -mxcheck => 1 );
    
    if( !$email_valid )
    {
        $response = 'FAIL';
    }
    else
    {
        if( $store )
        {
            $c->session->{email}->{valid} = 1;
            
            $c->model('StephenSykesDB::EmailSessions')->create({
                session_id => undef,
                email      => $email_valid,
            });
        }
        
        $response = 'OK';
    }
    
    $c->res->content_type('application/text');
    $c->res->body($response);
}

=head1 AUTHOR

Stephen Sykes

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

1;


It's that simple.

[ Comments (0) ]


Remote Git Repository Setup
2009-08-23 20:14:59 Permalink

Tags: git linux


I've been doing a lot of work moving from SVN to Git for source code version control. The following is a quick and easy how-to for setting up a remote git repository. This example shows how to import an existing SVN repo into a new git repo.

1) [Local machine] Export clean code base from remote SVN repository:

Code:
cd /var/git/
svn export http://svn.domain.com/trunk myapp.git
cd myapp.git
git init
git add .
git commit -m "initial import"


2) [Remote server]: Make remote git repository:

Code:
ssh user@ipaddress
mkdir /var/git/myapp.git && cd /var/git/myapp.git
git --bare init


3) [Local machine] Add/push local repo to remote repo:

Code:
git remote add origin user@ipaddress:/var/git/myapp.git
git push origin master


4) Give out git repo info to developers:

Code:
git clone user@ipaddress:/var/git/myapp.git


That's all that's required for source code versioning via Git. Each developer can now clone from the master branch of the remote server (see step 4) and go to work! More on how to commit revisions soon.

~Stephen

[ Comments (0) ]


OpenBlog Catalyst App \@ GitHub
2009-08-16 18:33:56 Permalink

Tags: catalyst perl software


The Catalyst MVC driven software OpenBlog is now available as open source project at GitHub.

Here is the public clone URL:
git://github.com/sasykes/OpenBlog.git

Please contact me if you plan to modify or use the software. I am interested to see if anyone would be interested in future use/development.

~Stephen

[ Comments (0) ]


Domain Lister \@ GitHub
2009-08-12 22:01:12 Permalink

Tags: catalyst perl software


The Catalyst MVC software driven domain name auction/listing software I developed for MySQLSoftware.net is now available as open source project at GitHub.

Here is the public clone URL:
git://github.com/sasykes/Domain-Lister.git

Please contact me if you plan to modify or use the software. I am interested to see if anyone would be interested in future use/development.

~Stephen

[ Comments (0) ]


Free Agent
2009-08-02 15:16:37 Permalink

Tags: catalyst perl programming work


I'm now a 'free agent' and looking for a Perl programming gig. If you know of any Perl shops that might be hiring, please give me a shout!

Preferences:
1) Catalyst MVC Web Framework based projects.
2) Modern shop.
3) Telecommute.

~Stephen

[ Comments (0) ]


Template::Plugin::HighlightPerl v0.03
2008-04-25 03:32:19 Permalink

Tags: perl template toolkit cpan


Version 0.03 is now available on CPAN. This version fixes a bug where no line breaks were added when no code tags are used. This version is stable and probably will be the last update for a while.

Don't forget to restart httpd service after upgrade. ;)

[ Comments (0) ]