Skip to content

Instantly share code, notes, and snippets.

//http://elm-lang.org/edit/examples/Reactive/Position.elm
//https://github.com/evancz/Elm/blob/master/elm/elm-runtime-0.7.2.js
try {
if (Elm.Main) throw new Error("Module name collision, 'Main' is already defined.");
Elm.Main = function () {
var $op = {};
for (Elm['i'] in Elm) {
eval('var ' + Elm['i'] + '=Elm[Elm.i];');
}
/*
http://groovy.codehaus.org/Using+the+Delegating+Meta+Class
Each groovy object has a metaClass that is used to manage the dynamic nature of the language.
This class intercepts calls to groovy objects to ensure that the appropriate grooviness can be added.
For example, when an object is constructed, the MetaClass's invokeConstructor()is called.
One feature of the invokeConstructor allows us to create groovy objects using a map argument
to set the properties of the object (new X([prop1: value1, prop2: value2])).
*/
@joseanpg
joseanpg / Vigenere.js
Created January 14, 2013 19:53
Vigenère cipher
//http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
//https://twitter.com/r0aTzdg73QLawWw/status/290907958118842368
//https://gist.github.com/1385585
var vigenere = (function() {
var map = Array.prototype.map;
var canon = function(str){ return map.call(str.toUpperCase(),function(c){return c.charCodeAt(0)-65})}
return function(source, key) {
source = canon(source);
key = canon(key);
@joseanpg
joseanpg / dojo-1.0.3.js
Last active December 10, 2015 10:29
Dojo Deferred.js & DeferredList.js
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// http://download.dojotoolkit.org/release-1.0.3/dojo-release-1.0.3/dojo/_base/Deferred.js
//
// 02-Nov-2007
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
dojo.provide("dojo._base.Deferred");
dojo.require("dojo._base.lang");
.text
.globl Main_init
.globl Int_init
.globl String_init
.globl Bool_init
.globl Main.main
Object_init:
addiu $sp $sp -12
sw $fp 12($sp)
sw $s0 8($sp)
-- example of static and dynamic type differing for a dispatch
Class Book inherits IO {
title : String;
author : String;
initBook(title_p : String, author_p : String) : Book {
{
title <- title_p;
author <- author_p;
@joseanpg
joseanpg / Basic.recite.mips
Created December 13, 2012 20:10
Understanding coolc : init-order-super.cl Calling self.recite( value:Int) where self :Basic
# FrameBot del caller en fp
# self del caller en s0
# ReturAddress en ra
# Argumento en sp + 1
# Mediante prima nos referiremos a los valores del callee
Base.recite:
#Preparamos el Frame
@joseanpg
joseanpg / 00-init-order-super.java
Created December 13, 2012 16:25
init-order-super.cl compiled by coolc
-- init-order-super.cl
-- Superclass attribute initializers must be evaluated before subclass
-- attribute initializers.
class Base inherits IO
{
recite( value : Int ) : Object
{
{
@joseanpg
joseanpg / 00-SymbolTable.java
Created November 18, 2012 08:26
Symbols and Tables :: Cool Support Code
class SymbolTable {
private Stack tbl;
public SymbolTable() { tbl = new Stack();}
public void enterScope() { tbl.push(new Hashtable());}
public void exitScope() {
if (tbl.empty()) { Utilities.fatalError("existScope: can't remove scope from an empty symbol table.");}
tbl.pop();
@joseanpg
joseanpg / 00-cool-ast.hs
Created November 17, 2012 12:33
Understanding cool-tree.java
{- This is mine -}
data Symbol = Symbol { id :: Int
, str :: String
}
data Program = Program { classes :: Classes}
data Class_ = Class_ { name :: Symbol
, parent :: Symbol