Skip to content

Instantly share code, notes, and snippets.

@programaths
programaths / filter.egl
Last active August 29, 2015 14:28
Remove items from a list on specific criterion
// The bad
isFound boolean = true;
while(isFound)
isFound = false;
for(j int from 1 to array.getSize())
if (array[j].attribute == "lookupValue")
array.removeElement(j);
isFound = true;
end
end
@programaths
programaths / JavaFXBuilder.kt
Created August 13, 2015 14:35
Mimmic FXML in Kotlin using only one extention method
fun main(args:Array<String>){
Application.launch(javaClass<Foo>())
}
fun <T:Any> T.builder(f:T.()->Unit):T{
this.f()
return this
}
class Foo : Application(){
import java.text.DateFormat
import java.time.LocalDate
import java.util
import java.util.*
/*
Given a list of people with their birth and end years (all between 1900 and 2000),
find the year with the most number of people alive.
See http://qr.ae/RAG2zH
*/
@programaths
programaths / generators-vs-iterator.php
Last active September 21, 2015 12:22
PHP generators
<?php
// Data on which we operate
$tree=[
'+'=>[
'*'=>[1,2],
'-'=>[
'+' => [3,4]
, 5