Skip to content

Instantly share code, notes, and snippets.

View AlphaGit's full-sized avatar

Alpha AlphaGit

View GitHub Profile
// ArkanoidPlayer
ArkanoidPlayer.prototype = Object.create(DrawableBlock.prototype);
ArkanoidPlayer.prototype.constructor = DrawableBlock;
function ArkanoidPlayer(drawingContext, color, blockHeight, blockWidth, stageWidth, stageHeight) {
var self = this;
self.stageWidth = stageWidth;
self.stageHeight = stageHeight;
self.cornerX = 0;
self.cornerY = 0;
//DrawableCircle: DrawableEntityBase
DrawableCircle.prototype = Object.create(DrawableEntityBase.prototype);
DrawableCircle.prototype.constructor = DrawableEntityBase;
function DrawableCircle(drawingContext, color, radius, centerX, centerY) {
DrawableEntityBase.call(this, drawingContext, color);
var self = this;
self.radius = radius;
self.centerX = centerX;
self.centerY = centerY;
// helper: grid calculator for coordinate system
function GridCalculator(realHeight, realWidth, numColumns, numRows) {
var self = this;
self.numColumns = numColumns;
self.numRows = numRows;
var getNumRows = function() {
return self.numRows;
}
Ball.prototype = Object.create(DrawableCircle.prototype);
Ball.prototype.constructor = DrawableCircle;
function Ball(drawingContext, color, radius, stageHeight, stageWidth) {
var self = this;
self.centerBall = function() {
self.centerX = (stageWidth - radius*2) / 2;
self.centerY = (stageHeight - radius*2) / 2;
}
self.centerBall();
@AlphaGit
AlphaGit / remvsem1.css
Last active December 18, 2015 00:09
rem vs em: rem
html { font-size: 18px; }
p { font-size: 0.8rem; }
p small { font-size: 0.5rem; }
@AlphaGit
AlphaGit / remvsem1.css
Created June 2, 2013 20:45
rem vs em: em
html { font-size: 18px; }
p { font-size: 0.8em; }
p small { font-size: 0.625em; }
@AlphaGit
AlphaGit / web.config
Last active December 26, 2015 15:49
ManagedFusion.Rewriter configuration
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="managedFusion.rewriter" type="ManagedFusion.Rewriter.Configuration.ManagedFusionRewriterSectionGroup"/>
</configSections>
<!-- ... más configuraciones... -->
<system.webServer>
<!-- ... más configuraciones... -->
<modules>
@AlphaGit
AlphaGit / ManagedFusion.Rewriter.txt
Last active December 26, 2015 15:49
ManagedFusion.Rewriter.txt configuration file example
RewriteEngine On
# Uncomment these lines to enable logging
# RewriteLog "log.txt"
# RewriteLogLevel 9
RewriteRule ^/api/(.*) http://api.anotherserver.com/$1 [QSA,P,NC]
RewriteRule ^/testing/(.*) http://blog.alphasmanifesto.com/$1 [QSA,P,NC]
@AlphaGit
AlphaGit / linesInd3.js
Created April 13, 2014 02:09
Creating lines in d3.js
svg.append('line')
.attr('x1', arrowOrigin.x)
.attr('y1', arrowOrigin.y)
.attr('x2', arrowDestiny.x)
.attr('y2', arrowDestiny.y)
.attr('stroke-width', 2)
.attr('stroke', 'black');
@AlphaGit
AlphaGit / arrangeInLayers.js
Last active August 29, 2015 14:00
Arrange nodes of an acyclic graph in layers of dependencies
// example as described in http://blog.alphasmanifesto.com/2014/04/12/what-now-graficando-dependencias/
function arrangeInLayers(graph) {
var nodesToVisit = graph.slice(0);
var visitedNodes = [];
var layers = [];
var currentLayer = [];
while (nodesToVisit.length) {
for (var i = nodesToVisit.length - 1; i >= 0; i--) {