Skip to content

Instantly share code, notes, and snippets.

View chochos's full-sized avatar
💩
(╯°□°)╯︵ ┻━┻

Enrique Zamudio chochos

💩
(╯°□°)╯︵ ┻━┻
View GitHub Profile
@chochos
chochos / constructors.ceylon
Last active August 29, 2015 14:10
Simple constructors test
abstract class Padre() {
shared formal String nombre;
print("Creando Padre");
}
class A extends Padre {
shared actual String nombre;
print("Creando un A");
shared new A() extends Padre() {
nombre="Default";
}
value t1=[1, "2", 3.0];
value [a,b,c]=t1;
print(a==1);
print(b=="2");
print(c==3.0);
value d->e = "K"->1;
print(d=="K");
print(e==1);
value [f,g,[h,i,j]]=[9,10,t1];
print(f==9);
@chochos
chochos / keybase.md
Created January 13, 2015 18:40
keybase.md

Keybase proof

I hereby claim:

  • I am chochos on github.
  • I am chochos (https://keybase.io/chochos) on keybase.
  • I have a public key whose fingerprint is 064F FB7F 04CB 9FD1 EF11 7004 44AE 821F 3C43 F763

To claim this, I am signing this object:

@chochos
chochos / duh.java
Created April 16, 2015 23:44
Encode/Decode 16-bit unsigned integer
byte[] encode(int x) {
byte[] b = new byte[2];
b[0] = (byte)(x>>8 & 0xff);
b[1] = (byte)(x & 0xff);
return b;
}
int decode(byte[] b) {
return ((b[0] & 0xff) << 8) | (b[1] & 0xff);
}
@chochos
chochos / wtf.js
Created April 22, 2015 03:43
Go home, JavaScript, you're drunk...
function meta(f) {
console.log("en meta");
f();
}
var lista=[meta,meta,meta];
var fun=function() {
console.log("funcion");
}
for(var i=0;i<lista.length;i++) {
var item=lista[i];
@chochos
chochos / calendar.ceylon
Last active August 29, 2015 14:20
Calendar in Ceylon, similar to *nix `cal`
import ceylon.time {
today, date
}
import ceylon.time.base {
monthOf, Month, sunday, saturday
}
shared void run() {
value hoy = today();
value quarters = [ for (m in (1..12).partition(3)) m.collect(monthOf) ];
@chochos
chochos / build.gradle
Created August 1, 2015 18:46
Gradle run with watcher plugin
task watchConcurrently {
new Thread({
tasks.watch.execute()
} as Runnable).start()
}
run.dependsOn watchConcurrently
@chochos
chochos / Permutator.ceylon
Created September 2, 2015 03:23
Permutator in Ceylon
shared class Permutator<out Element>({Element*} source) satisfies Iterable<{Element*}> {
shared actual Iterator<{Element*}> iterator() {
value elems = source.sequence();
if (elems.size>1) {
value arr = Array(source);
value idxs = Array(0..arr.size);
void swap(Integer i, Integer j) {
if (exists ei=arr[i], exists ej=arr[j]) {
arr.set(i,ej);
@chochos
chochos / Zurg.ceylon
Created September 9, 2015 23:18
Zurg
class Toy(shared String name, shared Integer time) {
string="``name`` (takes ``time``m)";
}
Comparison sortFast(Toy a, Toy b)
=> a.time<=>b.time;
Toy[2] fastestPair([Toy*] gang) {
assert(nonempty g=gang.sort(sortFast),
nonempty r=g.rest);
@chochos
chochos / Skip.java
Created September 24, 2015 15:30
Skip `final` in Java
import java.lang.reflect.*;
public class Skip {
public final String s;
public Skip(String s) {
this.s=s;
}
public static void main(String... args) throws Exception {
Skip me = new Skip("Initial");