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 xMin:int = Math.ceil(_cameraX/_tileSize) - _entityRenderLeeway; | |
var yMin:int = Math.ceil(_cameraY/_tileSize) - _entityRenderLeeway; | |
var xMax:int = xMin + _stageWidth/_tileSize+2 + _entityRenderLeeway; | |
var yMax:int = yMin + _stageHeight/_tileSize+2 + _entityRenderLeeway; | |
for (var i:uint = 0; i < _loot.length; i++) { | |
if (_loot[i].x >= xMin && _loot[i].x <= xMax && _loot[i].y >= yMin && _loot[i].y <= yMax) { | |
_loot[i].image.visible = true; | |
if (!_loot[i].isBeingPickedUp) { | |
_loot[i].image.x = Math.floor(_loot[i].x * _tileSize - Loot.IMAGE_SIZE - _cameraX); |
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
//How to accomplish perfomant tile rendering with the Starling engine. | |
package { | |
import flash.display.BitmapData; | |
import flash.geom.Matrix; | |
import flash.geom.Point; | |
import flash.ui.Keyboard; | |
import starling.display.Image; | |
import starling.display.Sprite; |
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
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN | |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |
inet 127.0.0.1/8 scope host lo | |
inet6 ::1/128 scope host | |
valid_lft forever preferred_lft forever | |
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 | |
link/ether 12:31:3d:03:40:17 brd ff:ff:ff:ff:ff:ff | |
inet 10.117.79.229/23 brd 10.117.79.255 scope global eth0 | |
inet6 fe80::1031:3dff:fe03:4017/64 scope link | |
valid_lft forever preferred_lft forever |
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
require 'open-uri' | |
require 'ImageUtilities' #ImageUtilities is a module that is used to grab screenshots of a given URL. It is an external API. | |
require 'cgi' | |
require 'LatestCache' #LatestCache is a module that is used to update the cache for entries that have been submitted recently. | |
class EntriesController < ApplicationController | |
before_filter :authenticate, :only => "destroy" #User must have admin privileges to destroy an entry. | |
# This index method is hit via ajax call from javascript. It is the "HOT", or front page entries. | |
def index | |
page = params[:page] #Url Param can tell us which entry to start from. This is in the case that the user is scrolling down the page. Eatch "batch" of entries is a "page". |
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
def isPalindrome(value) | |
list = value.split("") | |
j = 0 | |
i = list.length-1 | |
while j <= i | |
if value[j] != value[i] | |
return false | |
end | |
j+=1 | |
i-=1 |
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
class QuickSort | |
def recurse(low, high) | |
i = low | |
j = high | |
pivot = @list[(low + (high-low)/2).floor] | |
while i <= j | |
while @list[i] < pivot | |
i+=1 |
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
//Constants | |
PriorityQueue.MAX_HEAP = 0; | |
PriorityQueue.MIN_HEAP = 1; | |
/** | |
* This is an improved Priority Queue data type implementation that can be used to sort any object type. | |
* It uses a technique called a binary heap. | |
* | |
* For more on binary heaps see: http://en.wikipedia.org/wiki/Binary_heap | |
* |
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
def findOperations(string) | |
operations = 0 | |
list = string.split("") | |
startIndex = 0 | |
endIndex = list.length-1 | |
while startIndex < endIndex | |
if list[endIndex]=="0" | |
if list[startIndex] == "1" | |
list[startIndex], list[endIndex] = list[endIndex], list[startIndex] | |
operations = operations+1 |
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
class Node | |
attr_accessor :endOfWord, :children | |
def initialize() | |
@endOfWord = false | |
@children = {} | |
end | |
end | |
class Dictionary |
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
//Dictionary implemented using a Trie Tree. | |
public class Dictionary { | |
private HashMap<Character,Node> roots = new HashMap<Character,Node>(); | |
/** | |
* Search through the dictionary for a word. | |
* @param string The word to search for. | |
* @return Whether or not the word exists in the dictionary. | |
*/ | |
public boolean search(String string) { |