{{ message }}

Instantly share code, notes, and snippets.

# Tautvidas Sipavičius flakas

Last active Mar 25, 2019
MailPoet coding test
View description.md

## 1. Code Review

A page within the newsletter system was needed to display an in-browser preview of a newsletter. The preview needs to display newsletter's subject, HTML body and a link to the preview itself for sharing with others. A fellow developer wrote this piece of code to do the job and is asking you to review it.

What do you think of it? Are there any issues you see? Please describe your evaluation of this code. Would you write it differently? If so, please rewrite it to meet your standards and explain the reasoning behind any changes.

Created Jul 7, 2013
Calculating Hamming distance of a byte array with number of bits set with Scala
View hammingDistance.scala
 object HammingDistance { def main(args: Array[String]) = { val b1 : Array[Byte] = Array(5, 7) // 0b00000101, 0b00000111 val b2 : Array[Byte] = Array(6, 8) // 0b00000110, 0b00001000 println(hammingDistance(b1, b2)) // Output: 6 } // Calculate a sum of set bits of XOR'ed bytes def hammingDistance(b1: Array[Byte], b2: Array[Byte]) = { (b1.zip(b2).map((x: (Byte, Byte)) => numberOfBitsSet((x._1 ^ x._2).toByte))).sum
Created Aug 8, 2012
Modified Arduino Ping))) example to work with 4-Pin HC-SR04 Ultrasonic Sensor Distance Measuring Module
View hc-sr04.ino
 /* HC-SR04 Sensor https://www.dealextreme.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696 This sketch reads a HC-SR04 ultrasonic rangefinder and returns the distance to the closest object in range. To do this, it sends a pulse to the sensor to initiate a reading, then listens for a pulse to return. The length of the returning pulse is proportional to the distance of the object from the sensor. The circuit: