This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<style> | |
.chart rect { | |
stroke: #FFF; | |
fill: steelblue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Demo</title> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<style type="text/css"> | |
body { | |
font: 14px Helvetica Neue; | |
text-rendering: optimizeLegibility; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beautify: (string, indent = 0) -> | |
switch ch = string[0] || '' | |
when '' then "" | |
when '{' or '[' then "#{ch}\n#{Array(++indent+1).join('\t')}#{@beautify(string[1..], indent)}" | |
when '}' or ']' then "\n#{Array(--indent+1).join('\t')}#{ch}#{@beautify(string[1..], indent)}" | |
when ',' then "#{ch}\n#{Array(indent+1).join('\t')}#{@beautify(string[1..], indent)}" | |
when ':' then " : #{@beautify(string[1..], indent)}" | |
else "#{ch}#{@beautify(string[1..], indent)}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var person = (function(){ | |
return new function() { | |
this.name = 'Justin'; | |
} | |
})(); | |
(function(person){ | |
var type = person.type = {}; | |
type['job'] = 'JavaScript Developer'; | |
type['likes'] = ['Closures', 'Anonymous Functions']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code me, yo! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code me, yo! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool Nearby(Point enemyLoc, Point playerLoc, int distance, Direction direction) | |
{ | |
//it helps human understanding and debugging to do all your calculations seperately, instead of one massive hard to read switch/if statements | |
bool isNearby = false; | |
//get the deltas | |
int deltaX = playerLoc.X - enemyLoc.X, | |
deltaY = playerLoc.Y - enemyLoc.Y; | |
//determine direction, you may need to flip which one is negative and positive for it to work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script> | |
<style> | |
.chart rect { | |
stroke: #FFF; | |
fill: steelblue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<style> | |
.chart rect { | |
fill: steelblue; | |
stroke: white; | |
} | |
</style> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// knowing three things is essential for JavaScript OOP | |
// --- | |
// #1 the concept of "closures" (and functional scoping in general) | |
// #2 knowing how the keyword "this" works, and how to use it. | |
// #3 knowing when to use the keyword "new" | |
// example of an OOP style JavaScript class implementation | |
var ProtoClass = (function(){ | |
// these would be your "private" variables, (in the sense that it can no longer be modified from the outside) | |
// if you send any of this stuff to the client, its clearly visible with any decent browser Developer Tools |
OlderNewer