Skip to content

Instantly share code, notes, and snippets.

@jskuse
jskuse / directory_commit.rb
Created May 17, 2014 11:19
Ruby class for game developers etc. who want to use dropbox for synchronising big assets with a tiny bit of safety. Uses a cache of hashes to detect conflicts etc. and prompt accordingly. Useful for integrating into Rake tasks.
require "json"
require "digest/md5"
require "fileutils"
class DirectoryCommit
def initialize(working_path, sync_path, ignore = nil)
@hash_file = '.filehashes-' + working_path.gsub(/[^\w]/, '')
@working_path = working_path
@jskuse
jskuse / get_registration_point.jsfl
Last active August 29, 2015 14:01
Get the registration point for an element on the Flash stage
function getRegistrationPoint(element) {
var t = element.matrix;
if (t.b == 0 && t.c == 0) {
return { x: (element.x - element.left) / t.a, y: (element.y - element.top) / t.d };
}
var doc = fl.getDocumentDOM();
var previousSelection = doc.selection;
doc.selection = [element];
doc.enterEditMode();
var reg = getRegistrationPoint(doc.selection[0]);