Skip to content

Instantly share code, notes, and snippets.

View oscarryz's full-sized avatar

Oscar Reyes oscarryz

View GitHub Profile
var Inputs = Class.extend({
validate: function() {
blablabal
if ( someCondition ) {
f = this.validate
}
}
)
var f = function(){}
....
//A) This
countries = ImmutableList.copyOf( Collections2.filter(
Sets.newLinkedHashSet(Iterables.concat(someCountries, someOthers)),
availableCountries));
//B) vs. That
countries = ImmutableList.copyOf(
Collections2.filter(
Sets.newLinkedHashSet(Iterables.concat(someCountries, someOthers)),
availableCountries
@oscarryz
oscarryz / gist:6381954
Last active December 21, 2015 23:28
Pass the errors to the handling redirect controller using flassAttributes
@RequestMapping(value = "/hola", method = RequestMethod.GET)
public String hola(Model model,
@ModelAttribute("command") Object command,
BindingResult results,
RedirectAttributes redirectAttributes ) {
model.addAttribute("command", command);
ValidationUtils.invokeValidator(validator, command, results);
if (results.hasErrors()) {
redirectAttributes.addFlashAttribute("errors", results.getAllErrors());
import java.util.Date;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import java.util.Comparator;
import java.text.SimpleDateFormat;
import java.text.ParseException;
class Employee {
String name;
import static java.lang.System.out;
import java.util.Scanner;
class Equipo {
private String nombre;
private int juegosJugados;
private int juegosGanados;
private int juegosEmpatados;
private int juegosPerdidos;
private int golesFavor;
@oscarryz
oscarryz / wordwrap.go
Last active December 17, 2015 08:29
wordwrap Kata (not working)
package main
import (
"fmt"
//"unicode"
)
func main() {
fmt.Println("0000")
fmt.Println(WordWrap("999999999", 2))
/*
Copyright (c) 2013, Oscar Reyes
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the folLowing disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
@oscarryz
oscarryz / DummyServer.java
Last active December 14, 2015 03:59
Creates a server that receives an input of 100 bytes and outputs a string of 102 bytes with.. well... see it run
package dummy;
import java.util.Random;
import java.net.Socket;
import java.net.ServerSocket;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class DummyServer {
http://play.golang.org/p/3z5PNHzQtR
@oscarryz
oscarryz / stringcalculator.go
Last active December 12, 2015 08:58
stringcalculator in go
package calculator
import (
"errors"
"fmt"
"strconv"
"strings"
)
func Add(numbers string) (int, error) {