Skip to content

Instantly share code, notes, and snippets.

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

Enrique Zamudio chochos

💩
(╯°□°)╯︵ ┻━┻
View GitHub Profile
@chochos
chochos / MagicalLand.java
Created February 21, 2013 16:36
Monopattable Unicorns
public class MagicalLand {
public static void main(String[] args) {
for (int i = 0; i < (Math.random() * 500) + 2; i++) {
if (Unicorn.pat()) {
System.out.println("UNICORN #1: PAT THIS UNICORN ONCE");
}
}
for (int i = 0; i < (Math.random() * 500) + 2; i++) {
if (Unicorn.pat()) {
@chochos
chochos / lcd.ceylon
Created March 22, 2012 06:54
LCD in Ceylon
class Digito(String partes) {
shared String parte(Integer idx) {
if (exists p=partes[idx]) {
if (p==`_`) {
return " _ ";
} else if (p==` `) {
return " ";
} else {
return "| ";
}
@chochos
chochos / NSFW.scala
Created January 12, 2012 18:25
NSFW Scala graffiti
object D extends App {
implicit def =====(x:Int)={
print(x)
print("=====D")
D
}
def apply(f1: => Unit)(f2: => Unit)={
f1
f2
println()
@chochos
chochos / build.gradle
Created October 14, 2011 23:53
Gradle script for Finagle projects
apply plugin:'scala'
repositories {
mavenLocal()
mavenCentral()
//This repo is for the Finagle jars
mavenRepo urls:'http://maven.twttr.com'
}
dependencies {
@chochos
chochos / gist:1109589
Created July 27, 2011 15:15
Canal jAlarms para Growl
<bean class="com.solab.alarms.channels.CommandLineChannel">
<property name="commandWithArgs"><list>
<value>/usr/local/bin/growlnotify</value>
<value>-m</value>
<value>${alarm}</value>
<value>Alarma del motor</value>
</list></property>
<property name="minResendInterval" value="5000" />
</bean>
@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");
@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 / 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 / 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 / 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) ];