Skip to content

Instantly share code, notes, and snippets.

View grig's full-sized avatar

Alex Grigorovich grig

  • Novosibirsk, Russia
View GitHub Profile

Tests encoding of UTF-16 data with ruby-smpp

Usage example:

$ javac -cp .:smpp.jar SmppDecodeTest.java
$ ruby ./smpp-test.rb | java -Dfile.encoding=utf-8 -cp .:smpp.jar:log4j-1.2.8.jar SmppDecodeTest
Привет
$
require 'active_support' # Array#sum
def avg(a)
a.sum.to_f/a.size
end
def groups(a, k)
result = []
while (a.size >= k)
result << a[0..k-1]