Skip to content

Instantly share code, notes, and snippets.

@MarcinMM
MarcinMM / gist:1271824
Created October 8, 2011 03:44
Replace with callback to prettify URLs and image-ify images
var imageRegex = /\.(png|jpg|jpeg|gif)$/;
str= str.replace(/(\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|])/gim,
function(str) {
if (str.match(imageRegex)) {
return('img src=' + str + 'end img src');
} else {
return('<b>[</b><a href="' + str + '" class="autolink" target="_blank">' + str.replace('http://','') + '</a><b>]</b>');
}
});
@MarcinMM
MarcinMM / gist:1132219
Created August 8, 2011 17:19
Dweller: multi-layer image prototype
class MonsterGraphic extends Graphic {
public var creatureSprite:Spritemap;
public var armorSprite:Spritemap;
public var weaponSprite:Spritemap;
override public function render(target:BitmapData, point:Point, camera:Point):void {
creatureSprite.render(target, point, camera);
armorSprite.render(target, point, camera);
weaponSprite.render(target, point, camera);
}
var path:Array = new Array();
var openList:Array = new Array();
var closedList:Array = new Array();
var closedListD:Dictionary = new Dictionary();
var neighborList:Vector.<Node>;
trace("path from: " + this.x + "-" + this.y + " to " + endNode.x + "-" + endNode.y);
var currentNode:Node = this;

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@MarcinMM
MarcinMM / cave_usage.as
Created May 6, 2011 18:04
Cellular automata cave usage examples
// Create cave of size 200x100 tiles
var cave:FlxCaveGenerator = new FlxCaveGenerator(200, 100);
// Generate the level and returns a matrix
// 0 = empty, 1 = wall tile
var caveMatrix:Array = cave.generateCaveLevel();
// Converts the matrix into a string that is readable by FlxTileMap
var dataStr:String = FlxCaveGenerator.convertMatrixToStr( caveMatrix );
@MarcinMM
MarcinMM / caves.as
Created May 6, 2011 18:03
Cellular automata cave algorithm
package
{
/**
* This class uses the cellular automata algorithm
* to generate very sexy caves.
* (Coded by Eddie Lee, October 16, 2010)
*/
public class FlxCaveGenerator
{
private var _numTilesCols:uint = 10;