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
app.factory('userService', ['$q', '$timeout', '$http', '$rootScope', function($q, $timeout, $http, $rootScope) { | |
var userService = {}; | |
userService.tryLoginFromCookie = function() { | |
var promise = $q.defer(); | |
$http({method: 'POST', url: '/login'}). | |
success(function(data, status, headers, config) { | |
$timeout(function() { | |
$rootScope.$broadcast('login', data); |
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
Array.prototype.sample = function() { | |
return this[Math.floor(Math.random() * this.length)]; | |
} |
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
//For node.js | |
if (typeof window === 'undefined' && typeof module !== 'undefined' && module.exports) { | |
module.exports = EasyStar; | |
} |
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
function getAspectRatio() { | |
var ar = .8; | |
this.magicNumberNeverDeclaredAnywhere = 10; | |
ar * this.magicNumberNeverDeclaredAnywhere / 4; //divded by 4 bc why not lol. im new here u guys seem cool | |
var forSomeReasonAFunction = function(value) { | |
value = value * value / value; | |
this.value = value; |
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
//Sieve of Eratosthenes | |
function findPrimesUpTo(value) { | |
var primes = []; | |
primes.push(false,false); | |
for (var i = 2; i < value; i++) { | |
primes.push(true); | |
} | |
for (var i = 2; i < Math.sqrt(value); i++) { | |
if (primes[i] == true) { |
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
package test; | |
import flash.display.BitmapData; | |
import flash.display.Bitmap; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
class Main extends Sprite { | |
private var _bitmaps:Array<Dynamic>; |
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
//Extend function | |
Function.prototype.extend = function(parent) { | |
this.prototype = Object.create(parent.prototype); | |
this.prototype.constructor = this; | |
return this; | |
}; | |
//Base Class | |
var BaseClass = function() {}; | |
BaseClass.prototype.sharedMethod = function() { |
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
/// <reference path="./.node-definitions/node.d.ts" /> | |
/** | |
* See the node.js TypeScript definition needed for this | |
* example here: https://github.com/borisyankov/DefinitelyTyped | |
*/ | |
import Http = module('http'); | |
class MyServer { |
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
if (chunkX < _centerChunkX - MAX_WORLD_SIZE/2 || chunkX > _centerChunkX + MAX_WORLD_SIZE/2 || chunkY < _centerChunkY - MAX_WORLD_SIZE/2 || chunkY > _centerChunkY + MAX_WORLD_SIZE/2) { | |
worldChunks[chunkX + "_" + chunkY] = _waterChunk; | |
return _waterChunk; | |
} |
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 function showMap(playerX:uint,playerY:uint,worldProxy:WorldProxy):void { | |
if (!_isMapShowing) { | |
if (!_map) { | |
_map = new Sprite(); | |
_playerBlip = new Sprite(); | |
addChild(_map); | |
addChild(_playerBlip); | |
var renderSize:uint = WorldProxy.MAX_WORLD_SIZE + 5; | |