Skip to content

Instantly share code, notes, and snippets.

View mattmccray's full-sized avatar

Matt McCray mattmccray

View GitHub Profile
@mattmccray
mattmccray / optimize_lip.sh
Last active December 12, 2015 06:09
Shell script to optimize MangaStudio 5 files.
# The MangaStudio 5 (ms5) file format is actually just sqlite3 database.
#
# When you save and re-save them, they tend to accumulate a bit of cruft.
# This script will loop through the specified .lip files and run the 'vacuum;'
# command on each one, removing the cruft!
#
# WARNING: Use at your own risk! I've not had any problems, but it has not
# been tested exhaustively.
#
# Installation:
#!/usr/bin/env ruby
require 'thor'
require 'sprockets'
require 'fileutils'
def require_engine(name)
begin
require name
puts " o #{name} enabled"
class EventEmitter
emit: (event, args...) ->
return false unless @events?[event]
listener args... for listener in @events[event]
return true
addListener: (event, listener) ->
@emit 'newListener', event, listener
((@events?={})[event]?=[]).push listener
@mattmccray
mattmccray / hxn.sh
Last active December 16, 2015 01:09 — forked from jdonaldson/hxn.sh
export OLDPATH=$PATH
export HAXE_NIGHTLY=$HOME/bin/haxe_nightly
export USE_HAXE_NIGHTLY=false
hxn(){
if [ -z "$USE_HAXE_NIGHTLY" ] || $USE_HAXE_NIGHTLY; then
echo "Changing to Haxe stable version"
export HAXE_STD_PATH=$OLD_HAXE_STD
export PATH=$OLDPATH
export USE_HAXE_NIGHTLY=false
else
@mattmccray
mattmccray / giraffe.d.ts
Last active December 25, 2015 09:39
TypeScript definitions for Giraffe (https://github.com/barc/backbone.giraffe)
// Type definitions for Giraffe
// Project: https://github.com/barc/backbone.giraffe
// Definitions by: Matt McCray <https://github.com/darthapo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../backbone/backbone.d.ts" />
declare module Giraffe {
interface GiraffeObject {
@mattmccray
mattmccray / example.coffee
Last active December 25, 2015 22:39
Support js modules in: browsers, web workers, and commonjs (node) environments in one line of code!
MyModule= {} # Whatever
# Magic export
@MyModule= (@module or module or {}).exports= MyModule
@mattmccray
mattmccray / router.js
Last active December 26, 2015 14:29
Simple Backbone/Exoskeleton Router for use with React (http://facebook.github.io/react/)
var _missing= function(data){ return React.DOM.pre(null, "Route not found: "+ data.route) },
_router= null,
_started= false,
_nextId= 1;
function handleRouteChange(container, component) {
var routeParams= Array.prototype.slice.call( arguments, 1 )
React.renderComponent(
component({ routeParams:routeParams }, null),
container
@mattmccray
mattmccray / Cakefile
Last active August 29, 2016 17:54
CoffeeScript example for simple/enjoyable React.js prototyping (NOT recommended for production use).
# Cake task to generate destructuring code based on all the tag-like elements found in the target file.
# This will generate some false positives, so you'll want to inspect the results closely.
# If anyone wants to tweak the RegExp, or the whole detection block, I'd love to see it!
__= require 'coffee-script/lib/coffee-script/helpers'
_= require 'underscore'
React= require 'react'
tagRE= /[\W]{1}(\([\w]*)/g
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@mattmccray
mattmccray / package.json
Created February 17, 2014 04:03
TOML vs JSON
{
"name": "ogre-js-docs",
"version": "0.1.0",
"description": "Docs for ogre.js",
"main": "server.js",
"scripts": {
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Matt McCray <[email protected]>",