Posted on 01/13/2011 at 07:37PM

My new alarm clock utility for the Macintosh is now available on the Mac App Store.

My primary goal for QuickAlarm was to create a quick and simple way of setting reminder alarms on my Mac. I believe that an alarm should consist of: a time, a date, a message, and a tone. So I assembled all of those items into a single dialog where they can be set within seconds.

See QuickAlarm for a complete description.

Development

QuickAlarm was primarily written in MacRuby along with some Objective C routines. MacRuby has come a long way and I believe it is almost ready for most industrial strength applications.

Some of MacRuby's advantages include:

  • It is Ruby! It has concise syntax unlike Objective-C. I estimate that I reduced my number of lines of code by at least 1/2. Fewer lines of code also means fewer bugs.

  • It integrates seamlessly with Cocoa. For example:

    menuItem = NSMenuItem.alloc.initWithTitle( "Pending Alarms", action:nil, keyEquivalent:"")

  • It can be compiled using the LLVM compiler to byte code. This is good if you want to obfuscate your code in a commercial application.

  • Apple will accept a MacRuby app in the Mac App Store. Unfortunately, this still isn't the case in the IOS App Store.

  • Seamlessly integrates with C++ and Objective C that you include in your project.

  • MacRuby integrates seamlessly into XCode. Build, run, and submit to the MacApp store all from XCode.

Disadvantages:

  • MacRuby is still an interpreted language. If you want maximum performance, you should write your heavy lifting code in C, C++ or Objective C. And leave the UI duties to MacRuby.

  • The MacRuby framework does not come preinstalled in MacOS 10.6.6. Therefore you can't count on the end user having it installed on their machine thus forcing you to include that framework in your package. And it weighs in at a hefty 50Mbytes. This also requires some tricks that you must perform in XCode to copy the framework into your build process.

  • I had some problems getting MacRuby to work with BridgeSupport (communication with external programs like iTunes, etc). I ended up writing that code in Objective C.


Tags: objective c, xcode, quickalarm, macintosh, macruby, mac app store


Posted on 01/08/2011 at 03:12PM

I have published a new open source Twitter client web app to github: http://github.com/rsepulveda2/Twitter-Mobile

My goal was to create a standalone Twitter client web app that is optimized for mobile devices such as the iPhone, Android phone, etc.

   

The app utilizes the new jQuery Mobile javascript library. This library provides a standardized mobile device UI and is designed to work on most of the popular mobile devices on the market today.

The app also utilizes the Twitter @anywhere javascript library as a means of communicating with twitter.com. The library allows your javascript program to: login/logout of twitter, send tweets, follow users, receive tweets/statuses of people that you are following, etc.

The app was designed to be standalone. It generates its own pages to be displayed on the mobile device utilizing data obtained from twitter.com. There is no interaction with the "home" server after the initial page load.

I accomplished most of these design goals in a fairly short amount of time. The app has a similar look and feel to the Twitter/Tweetie app on MacOS and IOS (iPhone OS).

Twitter-Mobile's capabilities:

  • login to twitter by redirecting to twitter.com, then return to this app.

  • display your home Timeline as the main screen (This is the most recent tweets of the people that you follow).

  • Click on @user links embedded in tweets. This brings up a page of tweets most recently sent by that user.

  • Click on #keyword links embedded in tweets. This brings up a new page of the most recent tweets containing this keyword.

  • View embedded links in tweets.

  • Click on the thumbnail or tweet author to bring up his most recent tweets

  • Click on the top right most button to reply to a tweet

  • Click on the bottom right most button to retweet

  • Search twitter for any string. This brings up the most recent tweets containing this string.

  • Send a normal tweet to the world.

  • On a screen containing only tweets from a specific user. You can:

    Send a public tweet directed to that user

    Send a private message to that user

    View that user's profile.

Upcoming features:

  • UI and error recovery refinements

This is experimental code and may contain bugs.

To view the source code and related notes, visit the github link http://github.com/rsepulveda2/Twitter-Mobile

You can try the application at http://macdevshop.com/twitter/index.html using your mobile device or normal computer browser.

Please send your feedback to: rsepulveda2@gmail.com


Tags: javascript, twitter, client, tweet, web, app, jquery, jquery mobile, @anywhere


Posted on 01/08/2011 at 06:55AM

For part 1 of RSA-form plugin

New partials

I have added 2 new partials to Rsa-form. A registration form partial and a password entry keypad partial.


Screenshot of the Registration Partial

To include the registration form partial on your registration webpage. Include the following line in your html:

<%= render :partial => 'rsa_form/register' %>

And for those that want to design their own custom html around the password entry partials. You can simply include one of both of these lines in your html.

<%= render :partial => 'rsa_form/password1', :locals => { :name => "password]"}  %>
<%= render :partial => 'rsa_form/password2', :locals => { :name => "password_confirmation"}  %>

Here is an example of a completely custom registration page using the password partials.

<% form_tag users_path,:id=>"rsa_register_form" do -%>

      <%= label_tag 'login' %>
      <%= text_field_tag 'user[login]' %>

      <%= label_tag 'email' %>
      <%= text_field_tag 'user[email]' %>

      <%= label_tag 'password' %>
      <%= render :partial => 'rsa_form/password1', :locals => { :name => "user[password]"}  %>

      <%= label_tag 'password_confirmation' %>
      <%= render :partial => 'rsa_form/password2', :locals => { :name => "user[password_confirmation]"} %>

      <%= submit_tag 'Sign up' %>
<% end -%>

<script>
       $("form").jCryption( {getKeysURL:"/rsakey",formFieldSelector:':input:not([name=authenticity_token])',beforeEncryption:validate_inputs});       
</script>

Validate form before submission

Now you can validate the form's inputs with your browser prior to submission. This can reduce server load since the client will not contact the server until all inputs are validated. In order to do this, call jCryption with the beforeEncryption option:

$("#myencryptedform").jCryption( {getKeysURL:"/rsakey",formFieldSelector:':input:not([name=authenticity_token])',beforeEncryption:validate_inputs});

jCryption will now call validate_inputs() prior to encryption and submission. If an error is found, the submission will be cancelled. validate_inputs() is located in /javascripts/rsa-form.js and can be modified to your hearts content.

I have also added several javascript helper routines which can be used to test password, string, URL, and e-mail address validity. See /javascripts/rsa-form.js for more details.

Submitting your encrypted form's using AJAX

Say that I want to submit a form to the server using a post request to the same controller and action as normal but this time using AJAX. I want the controller to return javascript that will be executed by the client. (Such as displaying an alert or modifying the DOM on the clients browser). To do this:

  • Add the following javascript to your html or to a javascript file such as /javascripts/application.js IMPORTANT: Make sure that you add this code AFTER the call to $(form).jCryption();. If you don't, then this routine will be executed first and submit the normal unencrypted data.
$("#rsa_login_form").submit( function (){
  $.post( $(this).attr("action"), $(this).serialize(), null, 'script');
  return false;
});

  • Add code to your controller to differentiate between a normal GET/POST action and an AJAX GET/POST action. For example:
respond_to do |format|
  format.html { redirect_back_or_default('/') } # normally execute this redirect
  format.js   { @route = "/" }                  # setup a variable that will be used in the javascript view
end

  • Create a view that will be returned from the AJAX request.

Assuming that we are using a controller called 'session' and an action named 'create', create this file:

/app/views/session/create.js.erb

That contains some javascript that will be executed on the client, for example:

alert("You are successfully logged in");  // displays an alert
document.location = "{%=@route%}";        // does a redirect to the specified route

And that's about it!

There are many options available for AJAX calls, such as doing a GET instead of a POST. Returning 'json', 'xml', 'text' instead of returning 'javascript'. Please refer to the jQuery documentation for more information.


Tags: ajax, form, rsa, authentication, rails, validation


Posted on 01/08/2011 at 06:53AM

I just pushed my latest project to GitHub. Rsa-form http://github.com/rsepulveda2/rsa-form

This plugin is useful when submitting sensitive data such as login credentials from the browser to your server when your server doesn't have SSL. Please note that Rsa-form is NOT a replacement for SSL since it doesn't use authentication.

Rsa-form also includes a login widget that can be added to your login page to reduce the chance of a keylogger capturing passwords (see below for details).

To use Rsa-form:

Just create a form, then add the following javascript to your page. (Using either "script" tags or adding it to one of your javascript files such as /javascripts/application.js)

jQuery(document).ready(function() {
  $("#myencryptedform").jCryption({getKeysURL:"/rsakey",formFieldSelector:':input:not([name=authenticity_token])'});
});

When the user submit's the form, the browser will request an RSA public key from the server. jCryption will then encrypt the serialized form data using the RSA public key and return the encrypted data to the server.

To decode the data on the server side, make the following call in your controller:

params.merge!( RsaForm.decrypt_form( params[:jCryption], session[:key_pair])) if params[:jCryption]

This decodes the form data and adds it to your params hash. Your controller will work just as before.

Installation instructions:

Install the rsa-form plugin:

./script/plugin install git://github.com/rsepulveda2/rsa-form.git

install the javascript dependencies:

Download jquery.js and jquery.jcryption.js then put them in your /public/javascripts/ folder.

Add the following lines to your application.html.erb:

<script src="/javascripts/jquery-1.4.4.js" type="text/javascript"></script> 
<script src="/javascripts/jquery.jcryption.js" type="text/javascript"></script>

or the equivalent

<%= javascript_include_tag "jquery-1.4.2", "jquery.jcryption", "application" %>

Install the RSA ruby gem by adding the following line to your /config/environment.rb:

config.gem "rsa"

Stop your server

shell% rake gems:install

Restart your server

Rsa-form login widget

Login Widget

The Rsa-form login widget can be added to your login page as a partial. The users password is entered using a combination of letters from the keyboard and numbers clicked on the numeric keypad. The keypad ordering is changed everytime the page is refreshed. The page can be auto-refreshed if desired. This widget also uses the RSA encryption for added security.

To add the login widget to your login webpage, include the following line:

<%= render :partial => 'rsa_form/login' %>

Add the following to your html header (application.html.erb):

<link href="/stylesheets/rsa-form.css" media="screen" rel="stylesheet" type="text/css" /> 
<script src="/javascripts/rsa-form.js" type="text/javascript"></script>

And thats about it. Your controller will receive the data as:

params[:login] and params[:password]

Remember to add this line to your controller:

params.merge!( RsaForm.decrypt_form( params[:jCryption], session[:key_pair])) if params[:jCryption]

You can customize the look and feel of the login widget by:

  • Changing it's css file: /stylesheets/rsa-form.css

  • Replacing the graphics for the keys in the keypad. The following files can be replaced: /images/(0.png - 9.png, clr.png, del.png)

  • Rewriting the widget's html. Copy the /vendor/plugins/rsa-form/app/views/rsa_form directory to your /app/views directory.

    Make modifications to the /app/views/rsa_form/_login.html.erb file.

    To avoid breaking the javascript, don't modify the "img" elements, and don't change the id attribute of the password text field tag and the form tag.

See part 2 of RSA-form rails plugin


Tags: rsa, form, github, authentication, login


Posted on 12/22/2010 at 10:25AM

Ultraviolet is a syntax highlighting engine that generates website/blog embeddable html and CSS. It utilizes the syntax files of the popular programmer editor TextMate for more than 50 languages and 20 themes.

I ran into the problem after adding the following line to my config/environment.rb file:

config.gem 'ultraviolet', :lib=>'uv'

And running the standard installation scripts:

rake gems:install
rake db:migrate

The following error was generated:

/usr/bin/rake:19
Missing these required gems:
  ultraviolet  

You're running:
  ruby 1.8.7.174 at /usr/bin/ruby
  rubygems 1.3.7 at /home/rsepulve/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8

I knew that i had already installed the ultraviolet gem so I examined the verbose error listing and noticed the following:

libonig.so.2: cannot open shared object file: 
No such file or directory - /usr/lib/ruby/gems/1.8/gems/oniguruma-1.1.0/lib/oregexp.so
/usr/lib/ruby/gems/1.8/gems/oniguruma-1.1.0/lib/oregexp.so

I looked for this shared object/library on my machine and found it in /usr/local/lib instead of /usr/lib.

This particular library belongs to the 'oniguruma' regexp package which is one of 'ultraviolet's dependencies. This package must be downloaded and installed prior to installing 'ultraviolet'.

I solved the problem by relocating the library from the /usr/local/lib tree to the /usr/lib tree. This was accomplished by rerunning configure and make install for oniguruma using the --prefix option.

/configure --prefix='/usr'
make install

Bingo! everything installs without an error and here are the results:

<div class="editBlogPost">
		<div class="blogEditLeftPanel">
			<% if @blog_post.errors.size > 0 %>
				<div id="errorExplanation">
					<h2>The blog post could not be saved:</h2>
					<ul>
						<% @blog_post.errors.full_messages.each do |msg| %>
							<li><%= msg %></li>
						<% end %>
					</ul>
				</div>
			<% end %>
			<p>
				<%= f.label :title %><br />
				<%= f.text_field :title %>
			</p>
			<p>
				<%= f.label :body %><br />
				<%= f.text_area :body %>
			</p>

Tags: gems, centos, ruby, ultraviolet, rails, textmate