1. I've been thinking about this problem for a while - seeing more and more people preparing for interviews by learning only from Cracking the Coding interview and similar books or attending coding interview preparation meetups. Noting wrong with that, except - it won't teach you how to code and understanding algorithms and data structures.

    The good
    You are a CS major applying for an internship or a full time, already familiar with algorithms, data structures and have already written a decent amount of code but never done a technical interview before - this is the perfect source for you.

    You have been in industry for a while, writing code on a daily basis but feeling rusty on coding interviews - again, prefect book for you!

    The bad
    You have just entered in tech and need something fast to prepare you for interviews - you passed this book once or twice, remembered most of the questions and solutions.

    You are CS major, already listened important courses and understand the theory but haven't done much coding and trying to use the book by solving the problems on the paper or whiteboard without even running them and making sure they actually do what you think they do.

    The ugly 
    Then you come to an interview, get similar problem (or you think you got the similar problem - I'm sure some things sound pretty similar but are not) and try to solve the problem with one of the learned tricks but that doesn't quiet work. Then you get confused about complexities and you are sure interviewer gave you this problem because they want to trick you so you try to remember the optimal solution (even if there is none) and things get ugly.

    It's not really that bad
    No it's not. But if you are using those books to prepare for interviews - make sure you understand the problem, and understand the code you wrote. If you don't understand - ask questions - there are plenty of places where you can ask people. And the most important *run and debug the code you wrote*, understand why it didn't work in the first place. Don't be this guy:

    0

    Add a comment


  2. Yesterday evening I was at a house warming party and there was a discussion about the Sheryl's Lean in. By living in Bay Area and working in tech those conversations happen quiet often. Some people (especially women) said that they had a feeling that the book is mostly for women who plan to have kids, get married, be a boss... My experience was a bit different.
    While reading the book I didn't feel any pressure that I should have kids or that having kids would mean that I'm leaning in or being successful woman.
    For me the book was about whatever choice you make in your life it should be because of the right reasons.And that It's easier to make and accomplish them if you are surrounded by people who encourage you.
    Leaning in is not only about your own choices and decisions but also about supporting others in their own life choices and not judging them. There is no wrong way to lean in.
    0

    Add a comment


  3. Few days ago I met with a friend for a coffee and a little bit of coding. This time it was interesting because I found something I didn't know how to deal with - relative imports in Python - I never needed them before. Here is how I learn to deal with them the hard way.

    Disclaimer: I’m not saying that this is a good/bad way to organize source code in Python. The intention of this post is to show how to deal with relative imports in Python and not how to organize the code.

    I’m starting with the wrong code and I’m correcting imports in order to get working code. If you know better way to solve this problem (not by organizing code structure differently) please let me know.

    The project structure is:
     project/  
       __init__.py  
      example1.py  
      test/  
         __init__.py  
         test_example1.py  
    

    in test_example1.py I first had:
     from example1 import *  
    
    So I try to run this and got an error:
     ~/project/test$ python test_example1.py  
     Traceback (most recent call last):  
      File "test_example1.py", line 1, in <module>  
       from example1 import *   
     ImportError: No module named example1  
    
    This error makes sense because in the package tree in /project/test there is no module example1 as it is outside the test. OK so we need to use relative imports. I read Guido Decision for relative imports in PEP 328.
    If Guido says this it must be true so I changed my code and did:
     from ..example1 import *  
    And got an error:
     ~/project/test$ python test_example1.py  
     Traceback (most recent call last):  
      File "test_example1.py", line 1, in <module>  
       from ..example1 import *   
     ValueError: Attempted relative import in non-package  
    

    It didn’t work. Hm... I started to question that things Guido says are wrong. But I was missing one crucial thing - my understanding was that it treats . and .. like directory listing and not searching through the package tree at execution time.

    The solution how to make this work is to call python with option -m outside the root of the package:
     ~$ python -m project.test.test_example1  
    
    YAY! It worked but it’s a bit frustrating to get it work. It’s probably the first time I said that I like something in Java more than in Python. sigh

    The other solution is to have python script outside the package which will import the package and then call it:
     main.py:  
     from project.test import test_example1  
    
    Here is how I learned some things the hard way :)
    2

    View comments

  4. This was my first pyCon and I have to say it was a great experience:

    * I met so many great people who are working on interesting projects
    * was on PyLadies booth and was surprised how many people were coming to talks to us, offer help, ask for advice how to help their female friend, wife, daughter...
    * attended interesting talks
    * saw Guido
    * got Raspberry Pi B - I'm supper excited about this

    Here are few pics:

    fortune cookie I got - sums up pretty much everything at PyCon

    PyLadies booth 

    Elevation of Privilege game - really nice geeky game at AdaInitiative

    Lightning talks

    Guido Van Rossum on PEP 3156 - the most technical talk :) 

    Posters session - FB global load balancing 

    Each of us got Raspberry Pi to take home and hack, teach 
    someone coding in Python,...




    0

    Add a comment

  5. There are hundreds of articles full of advices how to prepare for technical interview (believe me - I read most of them while I was preparing for my interviews). As my interviews went pretty good I decided to make a post what topics I covered especially because I was preparing and interviewing for several different positions - SWE, Software Engineer in Test, Production engineer, Backend-Infrastructure …

    It depends how much time you have but here is what I did.


    Algorithms and data structures
    * finished Algorithms: Design and Analysis part 1 course on Coursera
    * read Introduction to algorithms - CSLR  and implement several algorithms from the book
    * read TopCoder advices on algorithms and data structures
    * went through Cracking the Coding interviews book and solved almost all problems
    * solved some problems from Algorithms for interviews
    * solved problems on HackerRank and those from Careercup

    I solved many problems and put the code on github - my approach was that no matter what topic I’m going through that day I need to solve one coding problem. At first it took me some time to solve each problem but after a while it was just a task I did and went to something else. Don't get discouraged it if takes some time at the beginning.

    Testing

    * wrote unit tests for some algorithmic implementations
    * read How Google tests software and some topic from Beautiful testing
    * read articles about testing (just Google it ;) )

    Even if you are not going for a testing role it is not that bad to cover some testing topic just to get the feeling about edge cases you need to think of in your solution and writing SW that could be easily tested later.

    Networking 
    * read TCP/IP illustrated volume 1 - second edition
    * used wikipedia for other topic I wanted to read (e.g. BitTorrent protocol)
    * played with network tools - tcpdump, ping, host, dig, netstat, ifconfig...

    This is the topic I really enjoyed and spend some time going trough.

    Linux / Operating Systems
    * read Operating systems concepts - one of my favorite books on the topic (read it few times since my college days)
    * went through several other books and tutorials:
    * Advanced Programming in the Unix Environment
    * Optimizing Linux Performance
    * The Unix Programming Environment
    * bash tutorial 

    * The Linux System Administration Guide

    I also tried to find as many questions on Linux/Unix topic and solved them

    Scalbility
    * read High Scalability blog
    * checked wikipedia on topics CDN, Load Balancer
    * read Facebook Engineering topics related to scalability

    General programming
    This list will depend on your prefered language but make sure that you can code in at least one very good on a board. 

    * python tutorial
    * read Expert python programming
    * Deep C presentation - awesome presentation about C/C++

    Other topics you should check:
    * git

    * databases - sharding
    * caching - memcache - basic operations

    It took me some time to go trough everything and I definitely haven't learned everything from those book and my list of things I want to learn is much larger but don't be discouraged by this list :)


    2

    View comments

  6. Python has several nice ways to help you solve k-way merge problem.

    1. heapq.merge(*iterables) - returns iterator
    from heapq import merge
    
    def n_way_merge(*args):
        return list(merge(*args))


     2. itertools.chain(*iterables) with sorted()
    from itertools import chain
    
    def n_way_merge(*args):
        return sorted(chain(*args))

    3. Using priority queue:
    from heapq import heappush
    from heapq import heappop
    from collections import deque


    def n_way_merge(*args):
        pq = []
        result = []
        for array in args:
            array = deque(array)
            # take first element of array, and the rest of an array
            heappush(pq, (array.popleft(), array))
        
        while len(pq) > 0:
            key, array = heappop(pq)
            result.append(key)
            if len(array) > 0:
                heappush(pq, (array.popleft(), array))

        return result


    0

    Add a comment

  7. I recently finished reading Optimizing Linux performance book and made a cheat sheet with Linux troubleshooting tools to make my life easier. You can find it on github. I hope you will find it useful. Please let me know if you find any mistake.

    Happy hacking!
    0

    Add a comment

  8. I had never heard about EtherApe until yesterday (..sigh..) and I think it’s pretty cool tool so here is something about it. 

    Etherape is graphic network traffic monitoring tool for Unix. Each node represents specific host and links represent connections to hosts. Nodes and links are colored to represent different protocols forming various types of traffic on the network. Individual nodes and their connecting links grow and shrink in size with increases and decreases in network traffic. If you need more information regarding protocol and traffic click on specific node.

    To run etherApe root access is required.

    Here are some screenshots:

    normal traffic

    refreshing Facebook 

    more details about a node

    0

    Add a comment

  9. Today I wanted to export list of movies I rated on Flixter. I was so naive to suppose that there is an API for that. Official API exists but only for browsing movies in general (not user specific). There is also Python version of that library.

    First I played a bit with Firebug Lite Chrome extension to find a link that I need.

    The data fetched is in JSON format - it is pretty easy to work with it in python with json lib. I wrote python code for getting data, saving to file and extracting it to nicer format - list of movie entries. I plan to add search and nicer output in the future (maybe importing data to sqlite3 for easier working with data)

    You can find the code on gitHub.

    The usage is pretty simple:
    Fetching data:
     >>> import ratings 
     >>> r = ratings.Rating('USER_ID','NUM_RATINGS')  
     >>> r.read('FILENAME')  


    Getting data (parsing):

     >>> import parse  
     >>> p = parse.Result()   
     >>> f = p.get_raw_data(FILENAME)  
     >>> f[0]['movie']['title'] # returns first movie   
     u'Super Size Me'  


    Movie entry:

     >>> f[0]  
     # formated to be easier to find keywords  
    {  
        u'movie': {  
                 u'mpaa': u'PG-13',   
                 u'cast': [  
                     {u'id': 162659559, u'name': u'Morgan Spurlock'},   
                     {u'id': 162659562, u'name': u'Dr. Daryl Isaacs'},   
                     {u'id': 770690679, u'name': u'Alexandra Jamieson'}],   
                 u'title': u'Super Size Me',   
                 u'url': u'http://www.flixster.com/movie/super-size-me/',   
                 u'poster': {u'mobile': u'http://content6.flixster.com/movie/25/38/253828_mob.jpg',   
                 u'profile': u'http://content6.flixster.com/movie/25/38/253828_pro.jpg',   
                 u'thumbnail': u'http://content6.flixster.com/movie/25/38/253828_tmb.jpg'},   
                 u'tomatometer': 93,   
                 u'audienceScore': 69,   
                 u'dvdReleaseDate': u'Sep 28, 2004',   
                 u'consensus': u'Entertaining doc about the adverse effects of eating fast food.',   
                 u'runningTime': u'1 hr. 36 min.',   
                 u'synopsis': u'First-time director Morgan Spurlock takes a look at the subject of obesity in the United States, specifically zeroing in on the...',   
                 u'year': 2003,   
                 u'id': 10060,   
                 u'vanity': u'super-size-me'},   
         u'review': u'',   
         u'scoreCss': u'50',   
         u'lastUpdated': u'3 days ago',   
         u'score': u'5.0',   
         u'ratingSource': u'Flixster',   
         u'user': {u'id': USERID, u'firstName': u'NAME'},   
         u'id': u'UID_10060'}  




    12

    View comments

  10. Yesterday I saw a web project where you can make an ASCII art from selected picture - http://dchang.mit.edu/artwork/. It's pretty cool - UI is simple (it would be cool to be able to choose size or color too).
    I tried Linux and python alternatives and here are the results. I tried Linux app jp2a and python lib aalib. I'm pretty happy with results.

    The original picture is:


    The result with web alternative is:

    jp2a

    After experimenting with different options - the best result I got with:
     mmihaljevic@gizmo:~$ jp2a --colors --fill --width=80 --html walle.jpg > walle.html   
    


    The result:

    aalib

    Simple example of using python library aalib is:

    import aalib
    import Image
    
    screen = aalib.AsciiScreen(width=80, height=40)
    image = Image.open('walle.jpg').convert('L').resize(screen.virtual_size)
    screen.put_image((0, 0), image)
    print screen.render()
    


    The result:

    mplayer

    You can also watch a video in ASCII using mplayer:


    mmihaljevic@gizmo:~$ mplayer -vo aa test.mp4



    There are several more alternatives but I haven't tried them. What is your experience with ASCII art ?
    1

    View comments

About Me
Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.