juan_gandhi: (VP)
2015-10-28 03:46 pm
Entry tags:

surprise

This morning I found a null in my code output. An error message was null. No shit. Spent some time tracing. Turned out an NPE is thrown somewhere inside a java library; ok, I intercept it. But the message of that NPE is null.

So what I did, I fixed all cases where t.getMessage is called. No way.

So, just FYI.
juan_gandhi: (VP)
2015-10-14 11:11 am
Entry tags:

unlimited idiocy

    /** {@inheritDoc} */
    public final boolean equals(Object obj) {
        if(obj == this){
            return true;
        }
        
        return super.equals(obj);
    }


and what do we see there in super:
public class Object {
...
    public boolean equals(Object obj) {
        return (this == obj);
    }


What's even funnier, they do not lock hashCode, so anybody can have, theoretically, two distinct instances that are equal but have different hashcodes.

Good that it's opensource; will grab the crap to my folder and fix it.
juan_gandhi: (VP)
2015-10-13 10:56 am
Entry tags:

an example of java monad transformer

    public List getOrderedChildren() {
        ArrayList children = new ArrayList();
        
        if (encryptedData != null) {
            children.add(encryptedData);
        }
        
        children.addAll(encryptedKeys);
        
        if (children.size() == 0) {
            return null;
        }
        
        return Collections.unmodifiableList(children);
    }
juan_gandhi: (VP)
2015-10-10 12:55 pm
Entry tags:

temporary code from Sun

    // temporary, used by RSACipher and RSAPadding. Move this somewhere else
    public static byte[] convert(byte[] b, int ofs, int len) {
        if ((ofs == 0) && (len == b.length)) {
            return b;
        } else {
            byte[] t = new byte[len];
            System.arraycopy(b, ofs, t, 0, len);
            return t;
        }
    }
juan_gandhi: (VP)
2015-06-23 11:10 pm
Entry tags:

why injective functions are important

Say, we have Set<T> objects;



vs



(Yes, it's Java)

What happens here. If you declare a function as injective, it can map a set to a set; otherwise, "elements can be repeated"; and map won't be "efficient enough", so an abstract collection is returned. It does not happen if you map a list.
juan_gandhi: (VP)
2014-12-19 02:19 pm
Entry tags:

необычный фрукт

selenium, джавный код, класс Куки.

В этих куках toString() возвращает весь текст (дату, домен и т.п.); а equals() сличает только имя и значение.

Так что пляшите, Варвара Лискова, две равных вещи производят разные результаты только так.

Ну или этих... не знаю, кто писал, дареному коню в зубы... джавщики, хуле, что с них взять.

P.S. Это я тут парсер-комбинатор для кук нарисовал, ну и это.
juan_gandhi: (VP)
2014-09-14 07:48 am
Entry tags:

wired funny

http://www.wired.com/2013/09/the-second-coming-of-java/all/

What I read here:
- Java's back
- Twitter uses Java
- Java is the fastest
- Bob Lee sees no choice
- Medvedev visited Twitter office 4 years ago

Any ideas what it was about?
juan_gandhi: (VP)
2014-08-25 11:13 am
Entry tags:

stupid Monday question

Hey crypto-haskellers! I mean those who know Haskell well and can write anything in it, but have to use C++ or Java, because the world around is pretty dumb and not ready for the truth.

How do you feel, did Haskell help you write more reasonable code?

Actually, there are two questions here:
a) you write in C++
b) you write in Java

I'd love to see examples.
juan_gandhi: (VP)
2014-06-16 01:05 pm
Entry tags:

истина про джаву

Ковырял в чаду угара Java семена,
и гадал, кому пришла IDEA
брать классов имена
в IKEA.

(src: [livejournal.com profile] sergeif)
juan_gandhi: (VP)
2014-06-02 04:22 pm
Entry tags:

apple swift

So, with the new "Apple language", object-oriented Java people are going to do what?
There must be some deep philosophy, explaining why they are so retarded.
I think.

I mean, I kind of heard an explanation from Josh; in my translation it sounds like this: "Java programmers are not very smart anyway, let's not overload them with closures and all that stuff."

The correlation I was writing about lately kind of shows itself again.
Weird.

Well, it's not Scala, of course; but it's a nice step in the right direction, I think.
juan_gandhi: (VP)
2014-05-21 07:35 pm

репортаж из жопы

Сижу на джавном митапе. Человек рассказывает, как они там на линух поставили wildfly8, каковая является просто новым именем джейбосса. Ощущение как будто на встречу энтузиастов форта или дельфи зашел. Мужик несет какую-то хуйню про эксемельную конфизурацию, показывает дикую картинку интероперабилити с другими аббревиатурами. "Common Annotations", например. Или еще - Concurrency. У них что там, конкарренси раньше не было? В одну нитку джейбосс работал?

Ну и т.д. Народ сидит какой-то кондовый; подобного рода толпу я последний раз видел, когда за каким-то хреном зашел на местный кампус Майкрософта. Бухгалтеры какие-то. Ну и в самом деле, кого сейчас интересует джава в наши дни?

Я-то зашел, на самом деле, чтобы объявление сделать, что нанимаем. Но уже жалею.

Вот одна строчка с экрана:


private static final Object PRESENT = new Object()


Кстати, мероприятие происходит на гугловском кампусе, но этот факт в данном случае нерелевантен. Единственно что водят по кампусу под конвоем.
juan_gandhi: (VP)
2014-05-12 02:00 pm
Entry tags:

talking to recruiters

RE: Rockstar Engineering Team at Multiscale

Hi Bara,

Ok, I see. I don't believe the word "rock star" may be applied these days to a Java/Python shop.

Best regards,
-Vlad

On 05/12/14 12:53 PM, Bara Boom wrote:
--------------------
Hi Vlad,
We are a Java/Python shop, yes but no immediate plans to use Scala.

Thanks for your note.

Cheers,
Bara
juan_gandhi: (VP)
2014-01-06 11:34 am
Entry tags:

more little java pearls (but not perls)


List<string> stringSet = parseProvider(provider);
juan_gandhi: (VP)
2013-12-07 05:35 pm
Entry tags:

more method naming fun

    /**
     * The filter will be used in case the URL of the request contains the DEFAULT_FILTER_URL.
     *
     * @param request request used to determine whether to enable this filter
     * @return true if this filter should be used
     */
    protected boolean processFilter(HttpServletRequest request) {
        return SAMLUtil.processFilter(filterProcessesUrl, request);
    }
juan_gandhi: (VP)
2013-10-20 09:07 am
Entry tags:

more Java masterpieces

public class Streams {

  /**
   * Drains the contents of a stream without blocking on further input from that stream.
   *
   * @param stream the stream to drain
   * @return the contents of the drained stream
   */
  public static String drainStream(OutputStream stream) {
    if (stream == null) {
      return null;
    }
    
    if (stream instanceof CircularOutputStream) {
      return stream.toString();
    }
    
    return null;
  }
}
juan_gandhi: (VP)
2013-10-19 06:38 pm
Entry tags:

just wrote some crap in Java

public static curry<X,Y,Z>(final Function2<X,Y,Z> f) {
  return new Function<X,Function<Y,Z>>() {
    public Function<Y,Z> apply(final X x) { 
      return new Function<Y,Z>() {
        public Z apply(Y y) { 
          return f(x,y) 
        }
      }
    }
  }
}


Just to scare my students a little bit. Hope they won't be scared, but will just laugh.