Skip to content

Instantly share code, notes, and snippets.

{
init: function(elevators, floors) {
var waiting = [];
elevators.forEach(function (elevator) {
elevator.on("idle", function() {
var i = waiting.length;
while (i-- > 0) {
@eridal
eridal / Compiler.java
Last active August 9, 2023 13:26
Java to PHP Compilation
package j2p;
import japa.parser.JavaParser;
import japa.parser.ParseException;
import japa.parser.ast.CompilationUnit;
import japa.parser.ast.ImportDeclaration;
import japa.parser.ast.PackageDeclaration;
import japa.parser.ast.body.BodyDeclaration;
import japa.parser.ast.body.ClassOrInterfaceDeclaration;
import japa.parser.ast.body.FieldDeclaration;
@eridal
eridal / Java.java
Last active August 29, 2015 14:06
PHP to Java persistent process comunication
import java.util.Scanner;
class Java {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while (s.hasNextInt()) { // <-- blocking read
int i = s.nextInt();
@eridal
eridal / code-zens.md
Created August 20, 2014 18:00
Code Zen
  • In the world of open-source development where most of the code is shared, code clarity and readability is important.
  • Object-oriented code architecture allows for much higher clarity and readability than procedural one, especially in complex code.
  • Clean and eloquent code is easier to review and independently reviewed code is more reliable and secure.
  • Code clarity largely influences the code's reusability for other purposes and by other people.
  • Consistency in a coding standard allows for cleaner and more comprehensible documentation.
  • Although it requires some tedious work, the usage of semantic checks on a massive scale pays off with more reliable code.
  • Adapting some of the familiar conventions that are used for method naming, parameter ordering, and method behavior from othe languages is better than making up new ones.
  • Unvarying return types with a fixed type for every method is better than varying return types when a value of one type can be mistaken for a value of another type.
  • Underscores