Skip to content

Instantly share code, notes, and snippets.

@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 / 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
-- 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;
.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)
@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");
@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);
/*
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])).
*/
//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];');
}
@joseanpg
joseanpg / cps.scm
Created April 20, 2013 09:05
LISP in small pieces: CPS Transformation (5.9)
;; http://books.google.es/books?id=81mFK8pqh5EC&pg=PA177#v=onepage&q&f=false
;; http://pagesperso-systeme.lip6.fr/Christian.Queinnec/WWW/LiSP.html
;; src/chap5f.scm
(define (cps e)
(if (pair? e)
(case (car e)
((quote) (cps-quote (cadr e)))
((if) (cps-if (cadr e) (caddr e) (cadddr e)))
((begin) (cps-begin (cdr e)))
@joseanpg
joseanpg / SimpleHttpRequest.js
Last active December 17, 2015 00:59
SimpleHttpRequest
(function(module){
var hop = Object.prototype.hasOwnProperty;
var urlEncode = function(flatObject) {
var result = [];
for (var p in flatObject) if (hop.call(flatObject,p)) {
result.push(encodeURIComponent(p)+'='+encodeURIComponent(flatObject[p]));
}
return result.join('&');