Thursday 26 April 2018

Shopify Interview Questions

1.     What are some ways to decrypt a password if I have an encrypted one?

Passwords aren't typically encrypted, they're hashed with a one-way function. “One-way” meaning they can't be “decrypted” or reversed. To authenticate with a website, the user supplies the password again, it’s hashed again, and the result is compared to the stored hash. If they match, you're allowed in. This means the only way to figure out what the password is is to guess a password, hash it, and compare the result.
To complicate matters (for an attacker such as yourself), a smart programmer uses “dcrypt”, a library that performs the hashing thousands of times in an effort to slow you down enough that trying all possible passwords would take longer than your lifespan.
Or you could get a naive implementation that used a bare hashing algorithm like SHA or MD5; that would have been a huge mistake, making it much easier for you to try many passwords quickly.

2. What are the best and worst things about public transit in Winnipeg, MB? How could it be improved?

Context: I've lived in Winnipeg and Toronto.
Best thing about Winnipeg transit? It covers large portions of the city and can get you anywhere you need to be.
Worst things? Buses are infrequent. They take winding serpentine routes that make trips take forever. These two things combine to make transit mostly useless and anyone who can afford otherwise typically does not take transit.
How could it be improved? more frequent buses, direct routes, and high-speed elevated trains between major city points, like downtown, University of Manitoba, Polo Park, etc. As it is today, I use transit primarily in Toronto but wouldn't even consider it in Winnipeg.

3. How can I setup an automatic read receipt for my personal gmail so that I am notified whenever someone reads my email?

There is probably a service that will do this for you in some form or another.

If you wanted to build it yourself, this is how I'd do it (short summary version):
- Set up a server that serves a 1x1 pixel image to any url  requested. Record urls requested to a database.
- create a unique Identifier for each email you send, point it to the image server you launched. Write some software to include this in the email body in html so you don't have to do this by hand.
-  when the user opens the email, the image will be loaded. This behavior is not 100% consistent across Mail readers. Some ask you to approve loading of images first.
- when the image is requested, send a notification with the unique ID from the image name. This could be another email, or some other form of notification.

This will not achieve 100% notification, but it should do alright. You can probably find some stats on other similar methods with corresponding "open" rates online.

4. I'm trying to create a Mad Libs type game in Ruby where anyone can create a story and add exactly 5*s where they want the player to add the random words. How do I create a list for the *s to be replaced by those random words?

The simplest way to do this is with with ruby's format specifier (String (Ruby 2.1.0)):

  1. "%s are %s, %s are %s, %s is %s, and so is %s" % ['roses', 'red', 'violets', 'blue', 'sugar', 'sweet', 'gasoline']
  2. => "roses are red, violets are blue, sugar is sweet, and so is gasoline"
As of Ruby 1.9 you can even used named format tokens:
  1. "%{name} likes to %{verb}" % {name: "John", verb: "jump rope"}
  2. => "John likes to jump rope"
In this version hash key names are used instead of the order of the terms in the first example.

5. How does content-based filtering recommendation algorithm work?

In a content-based recommender system, keywords or attributes are used to describe items. A user profile is built with these attributes (perhaps as a user upvotes or "likes" something). Items are ranked by how closely they match the user attribute profile, and the best matches are recommended. (wikipedia has more under: Recommender system)
It's worth checking out this paper on how Pandora does content-based music recommendations: 
Pandora’s Music Recommender
A more general description of Pandora's song attribute curation is available on wikipedia: Music Genome Project

To Answer your other questions (rephrased for clarity):

6. Do we define a similarity function for use between users?

A: Once you have attributes for your users, and you have attributes for the thing you want to recommend (I assume it's not also users, but it could be), then yes, a similarity function (also called a distance function) is used to recommend similar items for that user. Note that this recommendation (unlike collaborative filtering) does not depend on actions other users have taken.
It's not uncommon to implement this similarity/distance function on top of a search engine (Building a real time, solr-powered recommendation engine), since modern search engines are well-suited to the task (Solr, ElasticSearch).

7. Is there a public paper on collaborative and content-based filtering available?

A: Try Collaborative and Content-based Filtering for Item
Recommendation on Social Bookmarking Websites http://ceur-ws.org/Vol-532/paper...

8. Can the dataset be used for both the collaborative-filtering algorithm and the content-based filtering algorithm at the same time? How?

A: Yes. This is referred to as Hybrid Filtering; The two algorithms complement each other nicely, so It works fine. Implement both individually and display separately, or multiply the ranking scores to merge them in to a single recommendation set.

9. If light travels in a straight line then why do shadows bend?

The specific phenomenon you are referring to is called Diffraction (as opposed to Refraction). Light is known to bend when passing objects, depending on the object's size and the wavelength of the light. Hopefully someone can add more to this answer. :)

10. Which computer language is this?


I actually doubt this is modern encryption; at least not anything like AES, DES, or any other block cipher I can think of.  Typically you'd see a more-even distribution of characters, but that's not at all what you see when you decode the (clearly, as other posts have said) base64 text.
the text decodes to:
\x1D\xDC\x96\x9A\x8A\xDB\x93Y\xCC\x98\x9DT\x9D\tL\xD1\x15\x94\x9A\f\x19\xD9\x16\x98\x9D\x14\x1DV\x12\x98\x9A\tL\xD1\x1CZ^\x16\x13\eR\x19]\tL\xD1\x12\x9B\x99U\x19\xDD\\[\x9D[XX\xD3\x19\x93\x99\x9D\xDB\x8C\x9B\x1A\e^[\xCA\xD4\x9D\xD4\xD2\xCCR\xDB\x9D\x11\xDA\xD8\xD6NN\x1A]\xDA\x9E\tL\xD1\x1D\x8C\x16IL\xD1\x12\xD3\xD2\x94\xCB\xD8\x9C[\xCA\xD4\xDD\xD8\xD9IL\xD1\x1D\tL\xD1\x13\x0EY\xDA\xCB\xD8\x98YS\x0E\fT\x9DIL\xD1\x18\xD9\xD9P\xCD\xD4\xD3\x1A^T\xD2\x9A\x9AY\xCC\xCDM"
(the \ format is \xAA, where AA refers to a hexidecimal range from 00 - FF, so \x0F is the 15th ascii character)

11. So what do we know about it?

We know it's not another character encoding.  By reading it as another encoding and/or trying to convert it to anther encoding, we can see that only ascii-8bit works without errors. (anyone want to confirm my work?)

so reading the characters as ascii-8bit and as the decimal character values, this gives you a character map like such:
[29, 220, 150, 154, 138, 219, 147, 89, 204, 152, 157, 84, 157, 9, 76, 209, 21, 148, 154, 12, 25, 217, 22, 152, 157, 20, 29, 86, 18, 152, 154, 9, 76, 209, 28, 90, 94, 22, 19, 27, 82, 25, 93, 9, 76, 209, 18, 155, 153, 85, 25, 221, 92, 91, 157, 91, 88, 88, 211, 25, 147, 153, 157, 219, 140, 155, 26, 27, 94, 91, 202, 212, 157, 212, 210, 204, 82, 219, 157, 17, 218, 216, 214, 78, 78, 26, 93, 218, 158, 9, 76, 209, 29, 140, 22, 73, 76, 209, 18, 211, 210, 148, 203, 216, 156, 91, 202, 212, 221, 216, 217, 73, 76, 209, 29, 9, 76, 209, 19, 14, 89, 218, 203, 216, 152, 89, 83, 14, 12, 84, 157, 73, 76, 209, 24, 217, 217, 80, 205, 212, 211, 26, 94, 84, 210, 154, 154, 89, 204, 205, 77]

there are 151 characters, but only 51 unique characters. This might hint at a sort of substitution cipher, but that's just a guess.  if the distribution was random, you'd expect to see ~ 100-120 unique characters, not 51. If anything, this hints that the data has some sort of structure or meaning.
Looking at the characters sorted can give you an idea of the grouping; sorted the data looks like:

[9, 9, 9, 9, 9, 12, 12, 14, 14, 17, 18, 18, 18, 19, 19, 20, 21, 22, 22, 22, 24, 25, 25, 25, 25, 26, 26, 26, 27, 27, 28, 29, 29, 29, 29, 73, 73, 73, 76, 76, 76, 76, 76, 76, 76, 76, 77, 78, 78, 80, 82, 82, 83, 84, 84, 84, 85, 86, 88, 88, 89, 89, 89, 89, 90, 91, 91, 91, 91, 92, 93, 93, 94, 94, 94, 138, 140, 140, 147, 147, 148, 148, 150, 152, 152, 152, 152, 153, 153, 154, 154, 154, 154, 154, 155, 155, 156, 157, 157, 157, 157, 157, 157, 157, 157, 158, 202, 202, 203, 203, 204, 204, 204, 205, 205, 209, 209, 209, 209, 209, 209, 209, 209, 210, 210, 210, 211, 211, 211, 212, 212, 212, 212, 214, 216, 216, 216, 216, 217, 217, 217, 217, 218, 218, 218, 219, 219, 219, 220, 221, 221]
Frequency analysis shows that "\x9D" occurs 8 times, as does "L" and "\xD1" (that's 157, 76, and 209), which stand out above the typical 1-3 occurrences of the rest of the characters.  I wouldn't be surprised if they correlated to spaces, or 'E's.

So while I don't know what it is, it does appear to be something. Fun. :)

12. How long does it take to get a song out of your head?

I HATE having songs stuck in my head. It's typically something annoying, short (like a chorus), and has a ending that leads in to the intro, so my brain never stops following the progression of the song.
As such, I've devised the quickest possible way to get a song out of my head: for me that is to put all of my concentration on the immediate sensory inputs around me, especially auditory; the ones that your brain normally, conveniently, mutes.  Listen to the wind you didn't notice a moment before, the floor creak, the TV from the other room. I find focusing on those things for a minute or two can help free my brain to do other things.

So, I suppose it depends on the individual.

13. Should you start programming at a young age or wait until college?

I'll answer this two ways:
1. Assuming you're asking this as a parent wanting to introduce your children to programming as a life skill or for potential future employment opportunities.
2. Whether or not a young child has the skills to learn programming.

Part 1:
As a software developer myself, I've tried to introduce my kids to programming and encourage them to pick it up, but for some reason it hasn't stuck.  I think the desire has to come from within themselves, as with picking up any skills.

Rather than trying to give my kids skills I think they need, I've tried to introduce them to as many things as possible and see what they're interested in.  When they show interest in a certain area, I make sure they have the tools and opportunity to grow that interest in to something valuable. The rest is really up to them.
That said, maybe you'll have more luck convincing your child to want to be a software developer.

Part 2:
I taught myself to write BASIC by copying programs from a book as early as 8.  What I knew was elementary, but I built skills quickly.  By 13 I could write fairly complex programs, and starting to teach myself Pascal by translating programs I had written in BASIC, line by line.

Having access to a computer to "play" with as much as I wanted was critical for developing these skills.  Mind you, at the time I didn't have the internet to distract me. :)
If your kid is motivated, anything's possible.

14. What is the interview process like at Shopify for software engineers?

Assuming you're trying to decide how to prepare for interviewing at Shopify, I'll give you some general interview advice that will help you in an interview at Shopify, and cover the general process.
Process

Nothing crazy, we just get a feeling for who you are and what you do. Here's loosely how the process goes:
We usually start with a test of your coding prowess on Codility.com.  While your test results wont necessarily make or break your chances, it will significantly influence them.  Make sure to do the example test to get a feel for how their system works ahead of time.  Keep in mind questions may be more complicated than they appear.

If you're not in a city in which we have an office yet (Ottawa, Toronto, Winnipeg, at the moment), we'll likely conduct a Skype or phone interview.
Next we'll bring you in for a face-to-face interview and ask you about your experience to see if you know your stuff.

If you're a Ruby developer, we may bring you in for a day of pair programming with one of our devs, or to write an app that integrates with the Shopify API. Bonus points if you've already done something cool with our API.
Assuming everything goes well to this point and we think your skill set fits, you'll probably meet management, discuss the job, and get an official offer.  Congratulations! :)

General Advice & Stuff
·         Ruby, Coffeescript  and Objective C are our most-used languages.  Wouldn't hurt to have experience in at least one of them, or be a fast-learner, or both.
·         Have a Github account with code you've written. If you don't have a project, contribute to open source. It's win-win-win for the community, your education, and your resume.
·         What are you better at than anyone else? Highlight that in your interview. Show off the public projects you've worked on.
·         Have fun! We do. :)

15. Young Entrepreneurs: What advice would you give to a 16 year old who has little programming ability, $1000 or so to spend but some decent ideas in his head?

Most of the advice here is solid, but I strongly disagree with Tristan.  I suspect you're A) unlikely to find a decent mentor because you B) have no idea what to look for in a mentor, and C) don't know the right people, even if you did something as ridiculous as calling all your friend's friend's friends (which you shouldn't do). Even if one of those people in that network is the right mentor, it's not likely you'd know that, or say the right thing to get their attention with so broad an approach.

Forget the mentor.  Instead of finding a mentor in "business", which is bullshit, become a better developer.  You don't need a mentor to do it, and it gives you skills that will last you a lifetime.  My god you are getting in to programming at a great time.
Ideas don't have value.  You can't be the "idea guy" in a venture.  He's the first guy to get cut and provides very little.  Ideas aren't worth anything by themselves.  Give yours away freely.  Chances are anyone who hears them wouldn't know what to do with them anyway.  The "x guy stole my idea and made millions" is a myth that never (or almost never) happens.  The people it happens to couldn't have executed the idea on their own in the first place.

Programming is not hard. There's a ton of resources out there to teach you what you don't know.  Many of them are free or insanely cheap.  For example: http://peepcode.com/ has screencast tutorials for $12 each. Google screencast and your language of choice and you'll find tons.  When you're stuck, try http://stackoverflow.com/ or Google.  Spend your money wisely. Resources should cost less than $60: books, screencasts, tutorials. Github and Heroku are free, so you can host your code and deploy apps at virtually no cost.  Any decent programming language is also free.
Read everything you can find, learn everything you can.  You can do it, it's not that hard, and there's much less "black magic" holding the internet together than it seems to you right now.

Become an expert.  I'd strongly suggest (and yes, i'm slightly biased here) considering Ruby for server-side web development (ie, Ruby on Rails), and Objective-C for mobile development.  Pick one and become an expert.  Learn the other later.  These two, in my opinion, are the hotest things out there right now.  Choosing either will leave you with a huge mass of job opportunities if doing your own business idea doesn't work out, and the odds are against you on that one.  At least this is a nice backup plan.
Start with a simple project idea and build up to more complex things.

Cut scope ruthlessly.  What's the smallest part of your idea that could work or have any value? Build just that. nothing else.  Release it.  If anyone has any interest in it, add a single feature.  Release that.  Repeat.  The single biggest factor that kills every project from a simple $100 project to a $10,000,000 project is Scope Creep: Making your project do too many things.
Your software projects are part of your portfolio, failed or not.  You learn more from your failures anyway.  Be proud of them.  Keep them handy.

More about Shopify:


No comments:

Post a Comment