Skip to content

Instantly share code, notes, and snippets.

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@shameerc
shameerc / .htaccess
Last active August 29, 2015 14:12 — forked from ScottPhillips/.htaccess
#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.
@shameerc
shameerc / .bashrc
Created September 3, 2012 10:09
Show Git branch name on shell prompt
# 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);
@shameerc
shameerc / game_loop.js
Created October 1, 2011 09:51
Animation function
function gameLoop(){
//draw ojects
clearCanvas();
drawBall();
placeBar();
// collision detection
checkCollision();
@shameerc
shameerc / event_listener.js
Created October 1, 2011 09:50
cross browser event listener for keyboard events
// 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');
}
@shameerc
shameerc / draw_ball.js
Created October 1, 2011 09:48
function to draw ball
// function to draw ball
function drawBall(){
ctx.fillStyle = 'orange';
ctx.beginPath();
ctx.arc(ball.x, ball.y,radius,0, 2*PI,false);
ctx.fill();
}
@shameerc
shameerc / collision_detection.js
Created October 1, 2011 09:48
Collision detection
// 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();
}
}