- By Edmond Lau
 - Highly Recommended 👍
 - http://www.theeffectiveengineer.com/
 
- They are the people who get things done. Effective Engineers produce results.
 
| #301 Redirects for .htaccess | |
| #Redirect a single page: | |
| Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
| #Redirect an entire site: | |
| Redirect 301 / http://www.domain.com/ | |
| #Redirect an entire site to a sub folder | |
| Redirect 301 / http://www.domain.com/subfolder/ | 
| Bacon = require 'Bacon' | |
| _ = require 'underscore' | |
| $ = require 'jquery' | |
| # Reference: http://unixpapa.com/js/key.html | |
| # IE = IE keycodes (webkit, IE) | |
| # MZ = Mozilla keycodes (gecko) | |
| # Opera = Opera keycodes (opera) | |
| # US locale specific. About as well as can be done without browser detection. | 
| # this will show current branch name of repository in shell prompt | |
| # add this in ~/.bashrc | |
| export PS1="\\[\033[1;55m\]\w\$(__git_ps1 ' [%s]') \$ " | 
| // call gameLoop in fixed intervals | |
| interval = 1000/30; | |
| timer = setInterval(gameLoop,interval); | 
| function gameLoop(){ | |
| //draw ojects | |
| clearCanvas(); | |
| drawBall(); | |
| placeBar(); | |
| // collision detection | |
| checkCollision(); | 
| // cross browser event listener for keyboard events | |
| if(window.addEventListener){ | |
| window.addEventListener('keypress',moveBar,false); | |
| if($.browser.webkit){ | |
| window.addEventListener('keydown',moveBar,false); | |
| } | |
| } | |
| else if(window.attachEvent){ | |
| window.attachEvent('keypress',moveBar,false); | |
| } | 
| // get the canvas from options passed to costructor | |
| canvas = $(options.canvas)[0]; | |
| // check if the browser supports canvas and | |
| // get the contect | |
| if(canvas.getContext('2d')){ | |
| ctx = canvas.getContext('2d'); | |
| } | 
| // function to draw ball | |
| function drawBall(){ | |
| ctx.fillStyle = 'orange'; | |
| ctx.beginPath(); | |
| ctx.arc(ball.x, ball.y,radius,0, 2*PI,false); | |
| ctx.fill(); | |
| } | 
| // collission detection logic | |
| function checkCollision(){ | |
| if(ball.y+radius==C_HEIGHT && ( | |
| (ball.x < bar.x) || (bar.x + barWidth) < ball.x ) ){ | |
| stopGame(); | |
| } | |
| else if(ball.y+radius==C_HEIGHT ){ | |
| updatePonits(); | |
| } | |
| } |