Skip to content

Instantly share code, notes, and snippets.

View girasquid's full-sized avatar
🦐

Luke Hutscal girasquid

🦐
View GitHub Profile
package text {
import flash.text.TextFormat;
public class SimpleFormat extends TextFormat {
public function SimpleFormat(options:Object):void {
for(var k:Object in options) {
if(this.hasOwnProperty(k)) {
this[k] = options[k];
}
}
package {
import flash.display.Sprite;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFormat;
public class FontDetector extends Sprite {
[SWF(width='640', height='480', backgroundColor='#FFFFFF', frameRate='60', pageTitle="What fonts are on your system?")]
public function FontDetector():void {
@girasquid
girasquid / log.as
Last active January 3, 2016 19:59
AS3 logging helper
// util/log.as
package util {
import flash.system.Security;
import flash.external.ExternalInterface;
public function log(message:String):void {
flash.system.Security.allowDomain('*');
flash.system.Security.allowInsecureDomain('*');
ExternalInterface.call('console.log', message);
}
}

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
@girasquid
girasquid / CharacterFromRPGMakerSpritesheet.js
Created September 16, 2013 03:10
This is a simple MelonJS ObjectEntity that uses an RPG Maker spritesheet file to draw itself standing and walking in four different directions.
game.CharacterFromRPGMakerSpritesheet = me.ObjectEntity.extend({
init: function(x, y, settings) {
this.parent(x, y, settings);
this.renderable.addAnimation("stand-down", [0]);
this.renderable.addAnimation("down", [0, 1, 2, 3], 3);
this.renderable.addAnimation("stand-up", [12]);
this.renderable.addAnimation("up", [12, 13, 14, 15], 3);
function MatrixIndexOf(matrix, object) {
for(var i = 0; i < matrix.length; i++) {
for(var j = 0; j < matrix[i].length; j++) {
if(matrix[i][j] === object) {
return [i, j];
}
}
}
return -1;
}
@girasquid
girasquid / log.js
Last active December 18, 2015 18:49
// This helper function lets you make sure that if you're in a situation with a lot of log statements (like inside a loop),
// you'll only see a maximum of MAXIMUM_DUPLICATE_LOG_MESSAGES with the same message before they're quietly discarded.
// (I find it helps with debugging)
var counts = {}
var MAXIMUM_DUPLICATE_LOG_MESSAGES = 10;
function log(message) {
if(counts.hasOwnProperty(message)) {
counts[message]++;
} else {
counts[message] = 0;
#!/usr/bin/env python
from StringIO import StringIO
import csv
DUMMY_CSV = """
huh, wat, etc
huh, wat, etc
"""
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'aws/s3'
require 'uri'
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
@girasquid
girasquid / template.rb
Created September 25, 2012 04:41
How to fix unicode errors in Tilt templates
require 'tilt'
template = Tilt.new('views/emails/albums.erb')
template.instance_variable_set(:@default_encoding, 'utf-8')
context = {
:hi => 'hello',
}
html_content = template.render(binding, context)