Rhino Javascript Engine

A friend of mine thinks he can beat my score on the gild.com triangle numbers challenge. His only excuse is getting rhino setup on his MacBook to test the JS. So here is a quick and dirty approach.

  • Grab the Rhino source here.
  • Un-zip/tar to a cool directory. I use: ‘/Users/username/Development/Tools/Rhino’
  • Edit your .bash_profile file:
    export PATH=$PATH:/Users/username/Development/Tools/Rhino
    alias rhino='java -jar /Users/username/Development/Tools/Rhino/js.jar'
  • Now grab his source from: https://gist.github.com/981382
  • Add a print statement.
    print(fibs(12));
  • Run from the console using:
    rhino fibs.js

Questions, Comment…

UPDATE
I found an issue when trying to test a js file. Because ‘rhino’ is an alias bash will not run it as a command. I found a better solution here: WorkingRhino. Check it out, or just follow my instructions below:

  • Remove the rhino alias from .bash_profile or .profile.
  • Create a shell script in ‘/Users/username/Development/Tools/Rhino’ named rhino
  • Copy/Paste this:
    #! /bin/bash
    dir=$(dirname $0)
    export CLASSPATH=${CLASSPATH}${CLASSPATH:+:}${dir}/*
    echo using CLASSPATH=$(printenv CLASSPATH) > /dev/stderr
    [ "$1" = "-f" ] || { RLWRAP="rlwrap -C js" ;}
    exec $RLWRAP java ${JAVAOPTS} \
    org.mozilla.javascript.tools.shell.Main -strict "$@"
  • Make rhino executable with chmod u+x rhino
Posted in Uncategorized | 1 Comment

Triangle Numbers Puzzle

I’ve just finished coding my solution to the Triangle Numbers Puzzle challenge posted on gild.com here. I’ll post my solution along with how I did when the contest is over in about 8 days.

Update:

CONGRATULATIONS!

Your submission was a successful solution to the puzzle.
You scored 618 out of 800 points.

View my solution here.

Posted in Uncategorized | Leave a comment

Vidarr – A Silence Alarm for OS X

I just started working on Vidarr, a silence alarm for Mac OS X users. Its an open source project hosted on code.google.com check it out: http://goo.gl/bmHuC

Im very excited to help these guys out. The first issue ill be on is Issue 1: Universal SMTP Access.

Stay tuned…

Posted in Uncategorized | Leave a comment

What is HTML 5?


HTML5 Powered with Connectivity / Realtime, CSS3 / Styling, Device Access, Graphics, 3D & Effects, Multimedia, Performance & Integration, Semantics, and Offline & Storage

What most people think about when they hear HTML5 are rainbows and fairy dust, the ability to sprinkle a little jQuery on your page and magically transform it into a time machine. HTML 5 is the new specification for web designers, developers alike. It includes new API’s that provide geolocation aware sites, new graphics capabilities, media playback, offline storage, & more. HTML 5 has heavy separation of Functionality (Javascript), Presentation (CSS), & Structure (HTML).

some new elements include: audio, canvas, video…
canvas is used for rendering dynamic bitmap graphics on the fly, such as graphs or games.
video and audio for multimedia content. Both provide an API so application authors can script their own user interface, but there is also a way to trigger a user interface provided by the user agent. source elements are used together with these elements if there are multiple streams available of different types.

some new attributes: html:manifest, script:async…
The html element has a new attribute called manifest that points to an application cache manifest used in conjunction with the API for offline Web applications.
The script element has a new attribute called async that influences script loading and execution.

some attribute changes: draggable, dropzone, onevent-name, script, style…
The draggable and dropzone attributes can be used together with the new drag & drop API.
HTML5 also makes all event handler attributes from HTML4, which take the form onevent-name, global attributes and adds several new event handler attributes for new events it defines. E.g. the play event which is used by the API for the media elements (video and audio).
The type attribute on script and style is no longer required if the scripting language is ECMAScript and the styling language is CSS respectively.

API’s…
HTML5 introduces a number of APIs that help in creating Web applications. These can be used together with the new elements introduced for applications:

  • API for playing of video and audio which can be used with the new video and audio elements.
  • An API that enables offline Web applications.
  • An API that allows a Web application to register itself for certain protocols or media types.
  • Editing API in combination with a new global contenteditable attribute.
  • Drag & drop API in combination with a draggable attribute.
  • API that exposes the history and allows pages to add to it to prevent breaking the back button.

If you have some extra time see it in action HTML 5 Rocks.

Click the link below and check out some sample sites that implement many of the HTML 5 features mentioned above:
Ultra Modern Websites

Posted in Uncategorized | Leave a comment

Drupal – HTTP Error 0 when uploading files

Ran into this issue today with a site I am developing. Read through a lot of posts, on a lot of different sites. Steps I’ve tried include:

  1. Fixed write permissions on /tmp and sites/default/files.
  2. Install and enable pecl upload progress.
  3. Disable/Re-Enable IMCE & module.
  4. memory_limit already set to 512M.
  5. Installed the jquery update module
  6. Replaced jquery.form.js.
  7. Set the value of baseurl in settings.php
  8. Modified vhost file ServerName
  9. Last but not least…

I downloaded filefield-6.x-3.0-alpha2 and replaced filefield-6.x-3.9. Ran into 2 undefined functions:

theme_filefield_widget()

field_file_urlencode_path()

copy/pasted from them from the corresponding filefield-6.x-3.9 files. Everything is running fine so far. The real test is in the morning when the rest of the developers are working on the site.

Posted in Uncategorized | 1 Comment

30 Day Challenge…

I am challenging myself to complete the 12 parts of the SCJP, in a month. Here are the chapters:

  1. Packaging, Compiling, and Interpreting Java Code
  2. Programming with Java Statements
  3. Programming with Java Operators and Strings
  4. Working with Basic Classes and Variables
  5. Understanding Variable Scope and Class Construction
  6. Working with Classes and Their Relationships
  7. Understanding Class Inheritance
  8. Understanding Polymorphism
  9. Representing Object-Oriented Concepts with UML
  10. Understanding Java- Related Platforms and Integration Technologies
  11. Understanding Client-Side Technologies
  12. Understanding Server-Side Technologies

I hope to finish a chapter every 2 days. No breaks. I hope to do a write up on each chapter as I do them. Wish me luck.

Posted in Uncategorized | Leave a comment

Organization…

I woke up this morning thinking about how little i’ve accomplished this weekend. It manifested and the next thing I know, im wondering why I didnt make better use of my playtime as a kid. So I got a grip on it and decided I need major change, starting with minor things. Firstly, no more Starbucks…

On the car ride to work, I did a lot of thinking about organization. I use a helpdesk to track technical issues at work, a bug tracking system for software projects. I have my Mac, an Android phone, an iPad, and I bought these devices to make me a more efficient and productive person, but I dont make the best use of them. So secondly, get using them…

I read through these sites quickly this morning and found most of it pretty basic and useful:

12 Ways to Organize you Work of Home Life

How to Organize your Life

5 Core Life Zones

5 Stress-reducing strategies for the holidays

Lasty, I wrote the following out on a sticky note, and put it on my monitor:
ToDo List
So, what are some of the things you do to get organized and stay that way?

Posted in Uncategorized | Leave a comment

Self Extracting Jar Application

About a year ago, a client of mine needed to send sensitive files over the internet. They wanted something simple enough that the recipient wouldn’t need any special software installed to access the files. I started working on a java app that would be contained in an executable jar file. It worked as expected and they were happy. I’ve fixed it up a little more and decided to make the application along with the source available.

Details of the app are:

The sender simply double clicks on the jar file (SelfExtractingJar.jar), supplies an Encryption key or Password, and selects a file from the file system. Deliver the newly created *.jar file and the encryption key anyway they like. The recipient double clicks on the encrypted .jar file, supplies the encryption key and a directory to decrypt/extract. The application cleans up after itself and close.

Below are links the the application itself and the public github repo.

You can grab the app (SelfExtractingJar.jar):
dropbox file: http://goo.gl/qjy4m

If youre a developer and would like to contribute to the project check out the github repo:
github repository: http://goo.gl/8edPo

Posted in Uncategorized | Leave a comment

Recursion…

I am growing more and more interested in Algorithms, and with algorithms comes Recursion or so im finding. I found source for Factorial.java and broke it down visually. Hope this helps anyone working with recursion for the first time.


public static long factorial(long N) {
if (N == 1) return 1;
return N * factorial(N-1);
}

So whats happening here:

Lets say your main method looks something like this:


public static void main(String[] args) {
long factors = 5;
factorial(factors);
}

5 is tested and is not equal to 1 so it moves to N * factorial(N-1)
- 4 is tested and is not equal to 1 so it moves to N * factorial(N-1)
– 3 is tested and is not equal to 1 so it moves to N * factorial(N-1)
— 2 is tested and is not equal to 1 so it moves to N * factorial(N-1)
—- 1 is tested and is equal to 1 so it returns 1
— (N==2) N * (factorial(N-1) returned 1) 1 = 2 and returns 2
– (N==3) N * (factorial(N-1) returned 2) 2 = 6 and returns 6
- (N==4) N * (factorial(N-1) returned 6) 6 = 24 and returns 24
(N==5) N * (factorial(N-1) returned 24) 24 = 120 and returns 120

So 5*4*3*2*1 = 120

Make sense? I hope. If not feel free to comment and ill try to clear it up.

Posted in Uncategorized | 1 Comment

Time…

Just started reading “175 Ways to Get More Done In Less Time!“. I love these books on productivity… If only I could find the time to write a PHP app, to help make better use of my time… Hmm

Posted in Uncategorized | Leave a comment