Skip to content

Instantly share code, notes, and snippets.

public class DataHandler extends EventDispatcher {
private static var _instance:DataHandler;
private static var allowInstantiation:Boolean;
private var xmlPath:String;
private var xml:XML;
private var xmlLoader:URLLoader;
private static var _xmlpath:String;
public function setXMLPath (thisXML:String) : void {
_xmlpath = thisXML;
@alonecuzzo
alonecuzzo / OMFG
Created November 9, 2010 22:22
OMFG PAUL
public class DataHandler extends EventDispatcher {
private static var _instance:DataHandler;
private static var allowInstantiation:Boolean;
private var xmlPath:String;
private var xml:XML;
private var xmlLoader:URLLoader;
private static var _xmlpath:String;
public function setXMLPath (thisXML:String) : void {
_xmlpath = thisXML;
@alonecuzzo
alonecuzzo / gist:1401446
Created November 28, 2011 18:35
full text search, multi indexing mongo - ruby
class Recipe < MongoRecord::Base
collection_name :recipes
fields :name, :directions, :words
def to_s
"recipe: #{name} directions: #{directions[0..20]}..."
end
def Recipe.make collection, name, directions
collection.insert({:_id => Mongo::ObjectID.new, :name => name,
:directions => directions,
:words => (name + ' ' + directions).split.uniq})
@alonecuzzo
alonecuzzo / gist:1402206
Created November 28, 2011 21:42
mongoid wrapping
if(strcasecmp(get_class($id), "mongoid")) {
$_id = $_id->{'$id'};
}
$this->data=Db::$tours->findOne(array('_id'=>new MongoId($_id)));
E.add('loan-calculator-flash', 'click', function (event) {
E.preventDefault(event);
swfobject.embedSWF("/assets/calc/calculator.swf", "flashcontentLoan", "870", "540", "8.0.0", "expressInstall.swf", {
'url': "/assets/calc/loan.swf",
'calc': "Loan",
'LowAPR': C.getLowAPR(),
'HighAPR': C.getHighAPR(),
'LoanAmount': C.getLoanAmount(),
'term': C.getTerm(),
'debtList': C.getCreditorAmount(),
@alonecuzzo
alonecuzzo / rc4.py
Created November 9, 2012 20:57
My RC4 attempt
class RC4(object):
#initilization- take in the key and assign it
def __init__(self, key):
self._key = key
def _setKey(self, key):
self._key = key
@alonecuzzo
alonecuzzo / db.c
Created November 26, 2012 22:03
exiting with a return value other than zero
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define MAX_DATA 512
#define MAX_ROWS 100
struct Address {
@alonecuzzo
alonecuzzo / gist:4250902
Created December 10, 2012 14:38
Quit Adium After 15 minutes of Idle Time
global quit_after, check_every
set quit_after to 900
set check_every to 10
display dialog "Check is performed every " & check_every & " seconds. Adium will be quit after " & quit_after & " seconds of system inactivity."
on reopen
display dialog "Check is performed every " & check_every & " seconds. Adium will be quit after " & quit_after & " seconds of system inactivity."
end reopen
@alonecuzzo
alonecuzzo / gist:4286396
Created December 14, 2012 15:52
This can be used to delete a specific event from a Backbone View. It basically solves the issue of not being able to specify an even to undelegate.
//from inside the view
undelegateEvent: function(event) {
this.undelegateEvents();
var events = _.clone(this.events);
delete events.event;
this.delegateEvents(events);
}
@alonecuzzo
alonecuzzo / gist:5172038
Created March 15, 2013 18:41
Here's how they create a hitArea/hitRadius in the /assets/SpaceRock.js file in the examples folder.
p.hitPoint = function (tX, tY) {
return this.hitRadius(tX, tY, 0);
}
p.hitRadius = function (tX, tY, tHit) {
//early returns speed it up
if (tX - tHit > this.x + this.hit) {
return;
}