Difference between revisions of "User:Dhhodgin"

From CDOT Wiki
Jump to: navigation, search
(Releases)
(code blocks)
Line 54: Line 54:
 
* Helped Anna with PImage copy math which will ultimately be used in my 0.3 copy() code
 
* Helped Anna with PImage copy math which will ultimately be used in my 0.3 copy() code
  
=== code blocks ===
 
Here is a list of code blocks I have written for the processing.js project
 
==== nfc() ====
 
Specification for nfc() in processing [http://processing.org/reference/nfc_.html here].<br />
 
nfc() is a function used to format numbers with commas every 3rd digit and optionally how many decimal places to show right of the decimal place.  It accepts int, int[], float, and float[] types and returns either a single string or array of strings depending on the input.
 
  
  p.nfc = function( num, right ){
 
    var str;
 
    var decimals = right >= 0 ? right : 0;
 
    if (typeof num == "object"){
 
      str = new Array();
 
      for(var i=0; i < num.length; i++){
 
        str[i] = p.nfc(num[i], decimals);
 
      }
 
    }
 
    else if (arguments.length == 2){
 
      var rawStr = p.nfs(num, 0, decimals);
 
      var digits = ("" + Math.floor(Math.abs(rawStr))).length;
 
      var ary = new Array();
 
      ary = rawStr.split('.');
 
      // ary[0] contains left of decimal, ary[1] contains decimal places if they exist
 
      // insert commas now, then append ary[1] if it exists
 
      var leftStr = ary[0];
 
      var rightStr = ary.length > 1 ? '.' + ary[1] : '';
 
      var commas = /(\d+)(\d{3})/;
 
      while (commas.test(leftStr)){
 
        leftStr = leftStr.replace(commas, '$1' + ',' + '$2');
 
      }
 
      str = leftStr + rightStr;
 
    }
 
    else if (arguments.length == 1){
 
      str = p.nfc(num, 0);
 
    }
 
    return str;
 
  }
 
 
Example of this function and test is [http://matrix.senecac.on.ca/~dhhodgin/dps909/nfc_test.htm here].<br />
 
'''Known issues:''' None.
 
==== shorten() ====
 
Specification for shorten() in processing [http://processing.org/reference/shorten_.html here].<br />
 
Arrays in JS have no type, the elements in them can contain any type and do not all have to match.  Arrays are also passed by reference which means a reference to the object is passed in not the entire object.  so my code creates a new array and then copies the passed in array first and then pops one element off the new array and the newary object is returned. This is built to accept a processing type of String, int, boolean, char, byte, and float. Support for arrays of objects will be added in 0.2.
 
 
  p.shorten = function( ary ) {
 
    var newary = new Array();
 
    // copy ary into newary
 
    for ( var i = 0; i < size; i++ ) {
 
        newary[ i ] = ary[ i ];
 
    }
 
    newary.pop();
 
    return newary;
 
  }
 
 
Example of this function and test is [http://matrix.senecac.on.ca/~dhhodgin/dps909/shorten_test.html here].<br />
 
'''Known issues:''' This has not been tested with arrays of objects.  I'm assuming it will copy object elements in an array by reference and not produce a proper deep copy. I plan to fix this by 0.2. (confirmed, needs deep copy support for arrays of objects).
 
 
==== expand() ====
 
Specification for expand() in processing [http://processing.org/reference/expand_.html here].<br />
 
Expand takes an array as its argument and returns a copy of the array with its length doubled.  There is an optional 2nd parameter to specify the new size of the array as well.
 
 
  p.expand = function( ary, newSize ) {
 
    var newary = new Array();
 
    for ( var i = 0; i < ary.length; i++ ) {
 
        newary[ i ] = ary[ i ];
 
    }
 
    if (arguments.length == 1) {
 
      // double size of array
 
      newary.length *= 2;
 
    }
 
    else if (arguments.length == 2) {
 
      // size is newSize
 
      newary.length = newSize;
 
    }
 
    return newary;
 
  }
 
 
Example of this function and test is [http://matrix.senecac.on.ca/~dhhodgin/dps909/expand_test.htm here].<br />
 
'''Known issues:''' Not yet tested with arrays of objects.
 
 
==== unhex() ====
 
Specification for unhex() in processing [http://processing.org/reference/unhex_.html here].<br />
 
unhex takes a string representing a 8 digit hex code as its only argument and returns an int representation of the string.  JavaScript supports 64 bit floats as var's so it took a little number crunching to make it output an exact replication of the Java implementation with signed int's.
 
 
  p.unhex = function( str ) {
 
    var value = 0;
 
    var multiplier = 1;
 
    var num = 0;
 
    for (var i = str.length-1; i >= 0; i--){
 
        try{
 
            switch(str[i]){
 
                case "0": num = 0; break;
 
                case "1": num = 1; break;
 
                case "2": num = 2; break;
 
                case "3": num = 3; break;
 
                case "4": num = 4; break;
 
                case "5": num = 5; break;
 
                case "6": num = 6; break;
 
                case "7": num = 7; break;
 
                case "8": num = 8; break;
 
                case "9": num = 9; break;
 
                case "A":
 
                case "a": num = 10; break;
 
                case "B":
 
                case "b": num = 11; break;
 
                case "C":
 
                case "c": num = 12; break;
 
                case "D":
 
                case "d": num = 13; break;
 
                case "E":
 
                case "e": num = 14; break;
 
                case "F":
 
                case "f": num = 15; break;
 
                default:return 0; break;
 
            }
 
            value += num * multiplier;
 
            multiplier *= 16;
 
        }catch(e){;}
 
        // correct for int overflow java expectation
 
        if (value > 2147483647)
 
        {
 
            value -= 4294967296;
 
        } 
 
    }
 
    return value;
 
  }
 
 
Example of this function and test is [http://matrix.senecac.on.ca/~dhhodgin/dps909/unhex_test.htm here].<br />
 
'''Known issues:''' None.
 
 
==== nfs() ====
 
Specification for nfs() in processing [http://processing.org/reference/nfs_.html here].<br />
 
nfs() is a function used to format numbers as strings with padding of 0's on either the left or right of the decimal place.  It accepts int, int[], float, and float[] types and returns either a single string or array of strings depending on the input.
 
 
  p.nfs = function( num, left, right){
 
    var str;
 
    // array handling
 
    if (typeof num == "object"){
 
      str = new Array();
 
      for(var i=0; i < num.length; i++){
 
        str[i] = p.nfs(num[i], left, right);
 
      }
 
    }
 
    else if (arguments.length == 3){
 
      var negative = false;
 
      if (num < 0)
 
        negative = true;
 
       
 
      str = "" + Math.abs(num);
 
      var digits = ("" + Math.floor(Math.abs(num))).length;
 
      var count = left - digits;
 
      while (count > 0){
 
        str = "0" + str;
 
        count--;
 
      }
 
      // get the number of decimal places, if none will be -1
 
      var decimals = ("" + Math.abs(num)).length - digits - 1;
 
      if (decimals == -1 && right > 0)
 
        str = str + ".";
 
      if (decimals != -1)
 
        count = right - decimals;
 
      else if (decimals == -1 && right > 0){
 
        count = right;
 
      }
 
      else
 
        count = 0;
 
      while (count > 0){
 
        str = str + "0";
 
        count--;
 
      }
 
      str = (negative ? "-" : " ") + str;
 
    }
 
    else if (arguments.length == 2){
 
      str = p.nfs(num, left, 0);
 
    }
 
    return str;
 
  }
 
 
Example of this function and test is [http://matrix.senecac.on.ca/~dhhodgin/dps909/nfs_test.htm here].<br />
 
'''Known issues:''' None.
 
  
 
== Week 1 stuff ==
 
== Week 1 stuff ==

Revision as of 19:51, 6 December 2009

Contact Information

Name Daniel Hodgin
Email dhhodgin [AT] learn [DOT] senecac [DOT] on [DOT] ca
Email2 hodgin.daniel [AT] gmail [DOT] com
IRC dhodgin
BLOG blog

About Me

I'm a 5th Semester BSD student taking DPS909. Working part time on an ASP.NET c# application.

Technical Qualifications

Programming Languages

  • C
  • C++
  • C#
  • Java
  • PHP/PERL
  • SQL
  • XHTML/CSS
  • JavaScript
  • Processing

FSOSS Research Paper

Research paper on FSOSS

DPS909 Projects

[Processing.js] - Active project
[Fennec and @font-face] - on hold

Releases

0.1 - Full Details shorten(), expand(), nfs(), unhex(), bug fixes on nf() and fill()
0.2 - Full Details nfc(), exp(), log(), map(), asin(), acos(), atan(), tan()
0.3 - wip: blendColor(), blend(), copy(), filter()

Contributions

  • Wrote shorten() to help out Andor with his workload.
  • Created the template for processing.js tests
  • Organized 0.1 release code table and project test table areas.
  • Wrote GIT tutorial on adding code to GIT from a fresh fork tutorial
  • Helped Al get Lighthouse setup and got invites sent out to everyone to better prepare for 0.2 release code and bug tracking
  • Wrote tutorial on lighthouse, and ticket state explanations messages
  • Helped with triage on lighthouse tickets
  • Helped Anna with PImage copy math which will ultimately be used in my 0.3 copy() code


Week 1 stuff

  • Create Zenit Wiki (done)
  • Create Blog (done)
  • Blog on introductory readings (done)
  • Listen in on a Weekly Call (done)
  • Update wiki (done)

Week 2 stuff

  • Create MDC account (done)
  • join Mozilla Fennec mailing list (done)
  • week 2 lab (done)
  • watch learning to be at the festival and blog about it (done)

Week 3 stuff

  • watch online lectures about build system by Paul Reed (done)
  • build Firefox at school on Linux (fedora) (done)
  • build Firefox minefield at home on windows 7 (done)
  • choose subject for project and write project plan on blog (done)

Week 4 stuff

  • spend time searching through MXR and familiarizing myself with it (done)
  • lab, working with patches (to do)

Week 5 stuff

  • create Bugzilla account (done)
  • Find 3+ bugs related to your project, and add them to your project wiki page (done)
  • CC yourself on two bugs that relate to your project 517086 476478 (done)
  • Watch a user in Bugzilla for the week and blog about the experience (blassey) (done)
  • Be working on your 0.1 release. Ask for help if you're stuck (done)
  • Register for FSOSS or join as a volunteer. (done)

Week 6 stuff

Week 7 stuff

Week 8 stuff

Week 9 stuff

  • tba