juan_gandhi: (Default)
2020-02-14 03:26 pm

fb prophet

Predicts things in time.
Any opinions? 
juan_gandhi: (Default)
2018-04-04 04:53 pm
Entry tags:

Scala Future[T] notes

Say, we have tf: Future[T] =..., and two functions, f: T => U and g: U => V

We can produce vf: Future[V] = tf map f map g - same as vf: Future[V] = tf map (f andThen g)

Now, having fp: PartialFunction[T, U] and gp: PartialFunction[U, V],
we can run tf1: Future[T] = tf andThen fp andThen gp - these partial functions will be called on the value that tf produces, with no outside effect - only side effects happen. "composition" waits for fp before calling gp.

yet another future operation, onComplete, works like this: having f: Try[T] => U, the call tf onComplete f will call f even if the future ended with an error; the result of tf onComplete f is of type Unit.

Also, if your function f produces a Future, you will need to use flatMap.
juan_gandhi: (VP)
2016-08-25 06:38 pm
Entry tags:

scala futures critique

Decided to reread this:

http://docs.scala-lang.org/overviews/core/futures.html

"The most general form of registering a callback is by using the onComplete method, which takes a callback function of type Try[T] => U"


Guys, do you seriously think accepting a monad is a good solution? What is the type of your function? Well, it's a comonad, but I wonder if they know that.


"The callback is applied to the value of type Success[T] if the future completes successfully, or to a value of type Failure[T] otherwise."


Ever heard of XHR? They just have two functions, onsuccess and onerror. If you have a union, it's better to define a function on components.

Actually, they have it all. onSuccess, onFailure.

"The onComplete, onSuccess, and onFailure methods have result type Unit, which means invocations of these methods cannot be chained."

Oh. It's all so... not exactly wrong, but so misrepresented...

"This can be mind-boggling, but fortunately the flatMap operation is seldom used outside for-comprehensions, which are easier to use and understand."

Interesting. Which century was it?

"The recover combinator creates a new future which holds the same result as the original future if it completed successfully."

"The recoverWith combinator creates a new future which holds the same result as the original future if it completed successfully."

"The recoverWith combinator creates a new future which holds the same result as the original future if it completed successfully."

What a life!

"The andThen combinator is used purely for side-effecting purposes. It returns a new future with exactly the same result as the current future, regardless of whether the current future failed or not."

"we create a promise and use its future method to obtain the Future that it completes"

I remember reading it with almost an awe.
Now it all looks funny, like Ulysses - but Ulysses is actually funny, while this one is basically just a little bit sick. Is it not?
juan_gandhi: (VP)
2015-04-07 09:47 pm
Entry tags:

predictive policing

predpol.com

cops go there to see what is going to happen
juan_gandhi: (VP)
2014-05-24 02:58 pm
Entry tags:

usbank alerts

a break in will happen on Tuesday.

"Action: Your Online Banking ID and Password have been disabled due to multiple, incorrect attempts to login to Online Banking at usbank.com.
Date: 05/27/2014"

More, I actually even know what they mean. They snap current date/time to the nearest business day in the future. Developers, developers, developers!

They should have said "will have been disabled".

Except that it probably won't; and it is not disabled now. The shit happened yesterday; and it was about 4pm PDT, which means it was 7PM in Ohio, so they rounded it up. And now the time has come for the batch mail to send me this notification.