Phishing for the gullible
Bad English and tall stories are all part of a plan to filter out those who will not go all the way:

синє коло
Троє людей прийшли до мудреця, щоб дізнатись, хто з них найрозумніший. Мудрець запропонував задачу: "Я зав'яжу вам очі, намалюю на чолі синє або зелене коло, а потім зніму пов'язки. Якщо бачите синє коло, піднімайте руку. Перший з вас, хто скаже колір кола на їхньому чолі і є найрозумнішим із вас"

Мудрець зав'язав їм очі, і намалював кожному з них синє коло. Коли пов'язку зняв, всі вони, звичайно ж, підняли руки, бо побачили синє коло на чиємусь чолі. Поміркувавши деякий час один з них і каже: "У мене на чолі синє коло".

Як він дізнався?

ruby pearls
2.2.0 :004 > ':xyz'.split(/:/)[0]
 => "" 
2.2.0 :005 > ''.split(/:/)[0]
 => nil
2.2.0 :006 > 'xyz'.split(/:/)[0]
 => "xyz"

2.2.0 :001 > weak_key = lambda {|c| c.split(/:/, 2)[0]}
2.2.0 :002 > weak_key('xyz:1986')
NoMethodError: undefined method `weak_key' for main:Object

2.2.0 :003 > def weak_key(x)
2.2.0 :004?>   puts "blah"
2.2.0 :005?>   end
 => :weak_key 
2.2.0 :006 > def xyz(x)
2.2.0 :007?>   def weak_key(y)
2.2.0 :008?>     puts x+y
2.2.0 :009?>     end
2.2.0 :010?>   puts "yo"
2.2.0 :011?>   end
 => :xyz 
2.2.0 :012 > weak_key('b')
 => nil 
2.2.0 :013 > xyz('b')
 => nil 
2.2.0 :014 > weak_key('c')
NameError: undefined local variable or method `x' for main:Object
	from (irb):8:in `weak_key'
	from (irb):14
	from /Users/alex/.rvm/rubies/ruby-2.2.0/bin/irb:11:in `<main>'


carriage return for the blind

After endianness, character encodings is probably the next pet project of any decent standard committee.

CPS, π, actors, event loop
I have joined my current company to get better exposure to CPS, actors, event-driven programming. What I have found is that strict reasoning about the program's correctness requires a lot more effort: things that would be guaranteed by program order, are no longer guaranteed; more over, new things can happen apparently concurrently, in what otherwise would have been a "single-threaded" program.

Who can share their experiences on this? I heard a few people praising actors as a model that simplifies concurrency.

Suppose, there is an event-driven SMTP server:
smtp.on('mail', …);
smtp.on('rcpt', …);
smtp.on('data’, …);
smtp.on('message-start', (stream) -> stream.on('end', X));
smtp.on('message-end', Y);
smtp.socket.on('error', Z);

All of these things are technically concurrent. They are ordered only as far as the event-loop exposes the events in the same order in which they arrive, and as far as the underlying SMTP library orders events after seeing an ACK to the previous event. But errors are completely concurrent (hello, Yoneda and assertions about isomorphism between A and (A→⊥)→⊥?). And message body stream 'end' event and 'message-end' event of SMTP library occur in some unknown order. So X, Y, Z appear in arbitrary order, now you need barriers and execution time goal.

The same SMTP server without CPS would look like this:
  … = smtp.expectCommand('mail');
  while((C = smtp.expectCommand(Either 'rcpt' 'data')) == Left 'rcpt'){
  stream = smtp.expectCommand('message-start');
  … = smtp.expectCommand('message-end');
} catch(IOException ioe) {

I am not saying it is simpler, but, for example, there certainly is no question about X continuing execution, if Z occurs, so you don't need to cater for this eventuality.

How do you deal with the complexity introduced by event-driven style?

угадай мову по wtf
2.2.0 :001 > x = "\xE3\x81\x82"
 => "あ" 
2.2.0 :002 > y = x.encode("iso-2022-jp")
 => "\e\x24\x42\x24\x22\e\x28\x42" 
2.2.0 :003 > y[0]
 => "\e"
2.2.0 :004 > x[0]
 => "あ"

говоріть українською!

масштаби всесвіту
Якби галактика Андромеди була достатньо яскрава, вона б виглядала у порівнянні з місяцем ось так:

недружня підтримка свободи

2) отказа Соединенных Штатов Америки от недружественной
в отношении Российской Федерации, который должен

а) в отмене закона Соединенных Штатов Америки 2012 года (закон
Сергея Магнитского) и направленных против России положений закона
Соединенных Штатов Америки 2014 года о поддержке свободы Украины;
Помимо действий, направленных на изменение военно-
стратегического баланса, США предпринимают меры по
расшатыванию экономики Российской Федерации и нарушению прав
российских граждан

G.Gonzales, Comonad Challenge Exercise
Challenge Exercise: Prove that our original implementation of up' does not play nice with extend. In other words, find a counter-example that proves the following equation false:
extend (\t' -> p (up' t')) t = extend p (up' t)

What does he mean?

1. There is no need to look for counter-example, since it is false for any t, if we were to compare literally.

2. His previous statements about up' vs extend up were based on behavioural equality of the two, so motivating these challenges to find out which one was "correct". The behaviour of both sides is identical for all t. No? I tried even some cleverly placed undefined.


Log in