lev neiman dot com

Meet Lev Neiman, Staff Software Engineer at Leanplum

Working at Leanplum is an incredible ride of balancing cost, functionality and future foundation at scale.

Check out what I have been up to in my interview:


Crushing race conditions!

New cats!

I finally got my own cats! Checkout Bagheera and Leon!

Bagheera and young LeonI love these two!Looking off into the distance!

Ukranians, WordPress and xmlrpc.php

On this sunny day of February 28, 2016, the year of our Lord, I woke up with a bunch of emails telling me MySQL db on this fine server has been going down a whole number of times.

SSH didn't work, until it did.  At which point I could not execute any command because OS could not fork anything due to the lack of free memory.

Once the top command managed to work I saw that everything was dominated by a big array of apache2 processes, which indicated some sort of DOS attack.

After a nice reboot (and a backup in between, of course!) I took a look at the logs and discovered a whole bunch of accesses like such: - - [28/Feb/2016:21:40:49 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:41:10 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:41:35 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:42:22 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:42:30 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:42:36 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:42:52 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:42:55 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-" - - [28/Feb/2016:21:44:01 +0000] "POST /xmlrpc.php HTTP/1.1" 500 607 "-" "-"

As first order of business, I moved xmlrpc.php somewhere out of sight (who needs it anyway? I can post shit just fine!) then minimized the number of processes apache can spawn and added some golden rules to iptables:

# block ukranians
iptables -I INPUT -m iprange --src-range -j DROP

And now you can read this!

Making PHP / WordPress send email using custom sendmail

Recently I have had the pleasure of migrating a WordPress website which resulted in a peculiar problem - sending email functionality on the new server no longer worked.  After some digging around I found out that PHP has this mail function which uses the sendmail program to actually send your email.

Well after messing around with real sendmail for a good while and still not really understanding how to configure it properly, I decided to write my own sendmail.py script that uses my gmail and its app password to send out an email to whoever PHP/Wordpress wants to send an email to on my behalf.

After script was done I had to tell php to use it via sendmail_path = path to sendmail.py line inside php.ini which was located /etc/php5/apache2/php.ini on my Debian server. Then I just restarted apache server and voila, sending email worked!

Here is sendmail.py in all of its hacky glory:


#this is replacement for sendmail that php can use to send its goddamn emails

import smtplib
import sys

def findToAddress(lines):
  for i, val in enumerate(lines):
  j = val.index("To: ")
  if j != -1:
    return val[j+4:]
  return ""

fromaddr = 'whatever@example.com'
lines = sys.stdin.readlines()
toaddrs = findToAddress(lines)
msg = ''.join(lines)

username = 'you@gmail.com'
password = 'your app password'

# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:25')
server.sendmail(fromaddr,toaddrs, msg)

Hello World, again

I have gotten fed up with my past provider - JTLNet, and have switched over to DigitalOcean.com

Not only is JTLNet slow as shit, but they kept restarting my instance for mysterious reasons, and always bullshitted me on the support tickets while never fixing the problem.

On the other hand, Digital Ocean is excellent so far, and for over 2x less the price of JTLNet. Highly recommended for anyone looking for a simple VPS.

Rijik & Stesha Pro

Finally got someone with professional camera to take pictures of Rijik & Stesha on NYE. Enjoy.

More Rijik and Stesha photos

Bringing life back into the "Rijik" series are more photos of my pussies. To recap: Rijik is the white male cat, and Stesha is the fatty colored female cat.

My super secure password scheme

For the longest time in my life I have only used a single password for all the online services until I realized how much of a bad idea that is.

However I still didn't want to start memorizing a huge set of different passwords for each service so I came up with a following scheme which allows me to remember a single master password while still providing different password for each service. The key is in using a scheme that combines a master password plus the username and name of an online service then running resulting combination through a hash function output of which is what actually ends up being used as a password.

Running Backtrack 5 on my CR48

Back when Google was doing it's beta test program for Chrome Netbook, I applied and luckily received my own free CR48 laptop.

I have used Chrome OS for a while and while it's pretty good if you just always want to use chrome browser I was feeling a bit lonely without root access and gnome desktop. So I manned (nerded) up and flashed CR48 BIOS to allow running unsigned code and installed Backtrack 5 on it. Now CR48 is infinitely more usable and entertaining. All hardware (except 3g modem, I haven't gotten around to using that yet) works fine, and I didn't have to install any drivers manually. Only thing I had to do is create a non root user for use for desktop type tasks because by default Backtrack only has root user.

Create your own personal IM “cloud”!

Recently I have gotten around to purchasing my own VPS - Virtual Private Server. I did it because I wanted to have a server with root access on a pretty fast and reliable connection that I could use remotely from everywhere. One of the more useful things I have found to do on it is to run a chat client that I can use remotely from either web interface or SSH. What follows below is a high level description and instructions on how to setup your own IM "cloud"!