Skip to content

Instantly share code, notes, and snippets.

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
@prettymuchbryce
prettymuchbryce / gist:4422628
Last active December 10, 2015 10:39
Performant tile rendering with Starling
//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;
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);
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;
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;
}
@prettymuchbryce
prettymuchbryce / gist:5542020
Last active April 29, 2021 14:50
hello TypeScript & node.js
/// <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 {
//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() {
@prettymuchbryce
prettymuchbryce / gist:6471566
Created September 7, 2013 00:10
Haxe bug (HTML5/Javascript target)
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>;
//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) {
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;