Saturday, May 30, 2009

Free PC Security

AVG - analyzes by virus signature
ThreatFire - analyzes by behavior analysis
Comodo Firewall Pro - firewall

(Note: These programs are all non-conflicting.)

Tuesday, May 26, 2009

JavaScript: Drag Within Limits Script

Paste this into the HEAD:


<script>
function hookEvent(element, eventName, callback)
{
  if(typeof(element) == "string")
    element = document.getElementById(element);
  if(element == null)
    return;
  if(element.addEventListener)
    element.addEventListener(eventName, callback, false);
  else if(element.attachEvent)
    element.attachEvent("on" + eventName, callback);
}

function unhookEvent(element, eventName, callback)
{
  if(typeof(element) == "string")
    element = document.getElementById(element);
  if(element == null)
    return;
  if(element.removeEventListener)
    element.removeEventListener(eventName, callback, false);
  else if(element.detachEvent)
    element.detachEvent("on" + eventName, callback);
}

function cancelEvent(e)
{
  e = e ? e : window.event;
  if(e.stopPropagation)
    e.stopPropagation();
  if(e.preventDefault)
    e.preventDefault();
  e.cancelBubble = true;
  e.cancel = true;
  e.returnValue = false;
  return false;
}

function Position(x, y)
{
  this.X = x;
  this.Y = y;
 
  this.Add = function(val)
  {
    var newPos = new Position(this.X, this.Y);
    if(val != null)
    {
      if(!isNaN(val.X))
        newPos.X += val.X;
      if(!isNaN(val.Y))
        newPos.Y += val.Y
    }
    return newPos;
  }
 
  this.Subtract = function(val)
  {
    var newPos = new Position(this.X, this.Y);
    if(val != null)
    {
      if(!isNaN(val.X))
        newPos.X -= val.X;
      if(!isNaN(val.Y))
        newPos.Y -= val.Y
    }
    return newPos;
  }
 
  this.Min = function(val)
  {
    var newPos = new Position(this.X, this.Y)
    if(val == null)
      return newPos;
   
    if(!isNaN(val.X) && this.X > val.X)
      newPos.X = val.X;
    if(!isNaN(val.Y) && this.Y > val.Y)
      newPos.Y = val.Y;
   
    return newPos;  
  }
 
  this.Max = function(val)
  {
    var newPos = new Position(this.X, this.Y)
    if(val == null)
      return newPos;
   
    if(!isNaN(val.X) && this.X < val.X)
      newPos.X = val.X;
    if(!isNaN(val.Y) && this.Y < val.Y)
      newPos.Y = val.Y;
   
    return newPos;  
  }  
 
  this.Bound = function(lower, upper)
  {
    var newPos = this.Max(lower);
    return newPos.Min(upper);
  }
 
  this.Check = function()
  {
    var newPos = new Position(this.X, this.Y);
    if(isNaN(newPos.X))
      newPos.X = 0;
    if(isNaN(newPos.Y))
      newPos.Y = 0;
    return newPos;
  }
 
  this.Apply = function(element)
  {
    if(typeof(element) == "string")
      element = document.getElementById(element);
    if(element == null)
      return;
    if(!isNaN(this.X))
      element.style.left = this.X + 'px';
    if(!isNaN(this.Y))
      element.style.top = this.Y + 'px';  
  }
}

function absoluteCursorPostion(eventObj)
{
  eventObj = eventObj ? eventObj : window.event;
 
  if(isNaN(window.scrollX))
    return new Position(eventObj.clientX + document.documentElement.scrollLeft
                        + document.body.scrollLeft,
                        eventObj.clientY + document.documentElement.scrollTop
                        + document.body.scrollTop);
  else
    return new Position(eventObj.clientX + window.scrollX,
                        eventObj.clientY + window.scrollY);
}

function dragObject(element, attachElement, lowerBound, upperBound,
                    startCallback, moveCallback, endCallback, attachLater)
{
  if(typeof(element) == "string")
    element = document.getElementById(element);

  if(element == null)
    return;
 
  if(lowerBound != null && upperBound != null)
  {
    var temp = lowerBound.Min(upperBound);
    upperBound = lowerBound.Max(upperBound);
    lowerBound = temp;
  }

  var cursorStartPos = null;
  var elementStartPos = null;
  var dragging = false;
  var listening = false;
  var disposed = false;
 
  function dragStart(eventObj)
  {
    if(dragging || !listening || disposed)
      return;

    dragging = true;
   
    if(startCallback != null)
      startCallback(eventObj, element);
   
    cursorStartPos = absoluteCursorPostion(eventObj);
   
    elementStartPos = new Position(parseInt(element.style.left),
                                   parseInt(element.style.top));
   
    elementStartPos = elementStartPos.Check();
   
    hookEvent(document, "mousemove", dragGo);
    hookEvent(document, "mouseup", dragStopHook);
   
    return cancelEvent(eventObj);
  }
 
  function dragGo(eventObj)
  {
    if(!dragging || disposed)
      return;
   
    var newPos = absoluteCursorPostion(eventObj);
    newPos = newPos.Add(elementStartPos).Subtract(cursorStartPos);
    newPos = newPos.Bound(lowerBound, upperBound)
    newPos.Apply(element);
    if(moveCallback != null)
      moveCallback(newPos, element);
       
    return cancelEvent(eventObj);
  }
 
  function dragStopHook(eventObj)
  {
    dragStop();
    return cancelEvent(eventObj);
  }
 
  function dragStop()
  {
    if(!dragging || disposed)
      return;

    unhookEvent(document, "mousemove", dragGo);
    unhookEvent(document, "mouseup", dragStopHook);
    cursorStartPos = null;
    elementStartPos = null;
    if(endCallback != null)
      endCallback(element);
    dragging = false;
  }
 
  this.Dispose = function()
  {
    if(disposed)
      return;

    this.StopListening(true);
    element = null;
    attachElement = null
    lowerBound = null;
    upperBound = null;
    startCallback = null;
    moveCallback = null
    endCallback = null;
    disposed = true;
  }
 
  this.StartListening = function()
  {
    if(listening || disposed)
      return;

    listening = true;
    hookEvent(attachElement, "mousedown", dragStart);
  }
 
  this.StopListening = function(stopCurrentDragging)
  {
    if(!listening || disposed)
      return;

    unhookEvent(attachElement, "mousedown", dragStart);
    listening = false;
   
    if(stopCurrentDragging && dragging)
      dragStop();
  }
 
  this.IsDragging = function(){ return dragging; }
  this.IsListening = function() { return listening; }
  this.IsDisposed = function() { return disposed; }
 
  if(typeof(attachElement) == "string")
    attachElement = document.getElementById(attachElement);
  if(attachElement == null)
    attachElement = element;
   
  if(!attachLater)
    this.StartListening();
}
</script>


Paste this into the BODY:

 <div style="position:relative;width:641px;height:250px;border:1px solid black;">
  <input type="button" value="Stop Listening" onclick="buttonClicked();"
     id="dragButton" style="position:absolute;right:0px;"/>
  <div id="exampleA" style="position:absolute;top:10px;
     left:10px;width:50px;height:50px;background-color:Red;"></div>
  <div id="exampleB" style="position:absolute;top:10px;
     left:70px;width:50px;height:50px;background-color:Blue;">
    <div id="exampleBHandle" style="position:absolute;
       height:20px;width:50px;left:0px;top:0px;cursor:move;background-color:Red;">
      &nbsp;Handle
    </div>
  </div>
</div>


<script>

function buttonClicked()
{
  var button = document.getElementById('dragButton');
  if(exampA.IsListening())
  {
    exampA.StopListening(true);
    exampB.StopListening(true);
    button.value = "Resume Listening";
  }
  else
  {
    exampA.StartListening();
    exampB.StartListening();
    button.value = "Stop Listening";
  }
}

function exampleAEnd()
{
}

var exampA = new dragObject("exampleA", null, new Position(0,0),
    new Position(591,200), null, null, exampleAEnd, false);

var exampB = new dragObject("exampleB", "exampleBHandle");
</script>


Source: http://www.switchonthecode.com/tutorials/javascript-draggable-elements

Other links: http://vasir.net/blog/mootools/creating-a-dragable-dropable-resizbleable-div-in-javascript-using-mootools/

Monday, May 18, 2009

Google View Image

Go to a Google search page. In the top-left hand corner, right click the Google logo and click View Image (in Firefox).

Thursday, May 14, 2009

Tuesday, May 12, 2009

JavaScript: Toggle Visibility Script 2

<html><head><title>link box</title>
<style>
#messageBox{
    border-right: 1px solid #000000;
    position: absolute;
    width: 217px;
    height: 100px;
    z-index: 1;
    background-color: #C0C0C0;
    border-style: solid;
    border-width: 1px;
    display:none;
}
#closeButt{
     width: 100%;
     height: 10px;
     z-index: 1;
     cursor: pointer;
     left: 0px;
     top: 0px;
     background-color: #808080;
}
#contents{
    width: 100%;
    height: auto;
    z-index: 2;
}
</style>
<script language="javascript">
function show(obj,msg){
messageBox.style.top=obj.offsetTop
messageBox.style.left=obj.offsetLeft+obj.offsetWidth+5
contents.innerHTML=msg+"<p>"+obj.href
messageBox.style.display="block"
}
</script></head><body>
<p><a onmouseover="show(this,'this is my message#1')" href="http://www.google.com">link1: go to google</a></p>
<p><a onmouseover="show(this,'this is my message#2')" href="http://www.msn.com">link2: go to msn</a></p>
<p><a onmouseover="show(this,'this is my message#3')" href="http://www.dreamincode.com/">link3: go to DIC</a></p>
<div id="messageBox">
    <div onclick="messageBox.style.display='none'" id="closeButt">x Click to close</div>
    <div id="contents"></div>
</div></body></html>
Source: ahmad_511; http://www.dreamincode.net/forums/showtopic44814.htm

Sunday, May 10, 2009

How is Scout Finch from To Kill a Mockingbird smart?

http://answers.yahoo.com/question/index?qid=20080331145908AAcMzZq

Google View Image

Go to a Google search page. In the top-left hand corner, right click the Google logo and click View Image (in Firefox).

JavaScript: Toggle Visibility Script

<html><head>
<script language="JavaScript">
    function toggle(id) {
        var state = document.getElementById(id).style.display;
        if (state == 'none') {
        document.getElementById(id).style.display = 'block';
        } else {
        document.getElementById(id).style.display = 'none';
        }
    }
</script>
</head><body>
<a href="#" onclick="toggle('toggled'); return false;">Toggle</a>
<div id="toggled" style="background-color: yellow; border: 1px solid black; width: 200px; height: 100px; position: absolute;top: 100px; left: 100px;">
Can you see me now?</div>

<a href="#" onclick="toggle('toggled2'); return false;">Toggle2</a>
<div id="toggled2" style="background-color: yellow; border: 1px solid black; width: 200px; height: 100px; position: absolute;top: 350px; left: 350px;display:none">
Can you see me now 2?
</div></body></html>
Source: http://classes.design.ucla.edu/Fall06/161A/examples/javascript/toggle.html

Sunday, May 03, 2009

Math Inequalities

Is x > 2 the same equation as x ≥ 2.01?

Spider-Man: WOS Intro Song

[[Links]]
The song in the first clip of Spider-Man: Web of Shadows the video game is Beethoven’s Moonlight Sonata.

JavaScript: Post-it Notes Script

[[Links]]
http://www.benjaminkeen.com/software/post_its/ (Multiple Post-its)

Saturday, May 02, 2009

Tug-of-War Variations

  1. Have two water-filled balloons under everyone's two arms. If anyone's balloons pop, he/she is out.
  2. Have one designated person from each team try to make somebody on the opposite let go. Once someone lets go, he/she cannot come back.
  3. Have one ball thrown back and forth between teams. Throwers must call out a name, throw the ball to that person, and the catcher may let go to catch the ball and throw again. He/she may re-join the game.
Source: http://www.inquiry.net/outdoor/games/ripley/6_informal.htm