CTCI: A simple feed analysis

If you were integrating a feed of end of day stock price information (open, high, low, and closing price) for 5,000 companies, how would you do it? You are responsible for the development, rollout and ongoing monitoring and maintenance of the feed De- scribe the di erent methods you considered and why you would recommend… Continue reading CTCI: A simple feed analysis

Advertisements

CTCI: Implement a jigsaw puzzle Design the data structures and explain an algorithm to solve the puzzle

First you need a "Piece" class to represent one piece of a puzzle. Each piece has four sides, each one with a unique outline which will only connect to one other piece. Edge sides have an "edge" outline. Each side also has a piece id attribute called "adjacent" to store the value of the piece… Continue reading CTCI: Implement a jigsaw puzzle Design the data structures and explain an algorithm to solve the puzzle

CTCI: Design the data structures for an online book reader system

The main entities will be - User Book Library Each user can have multiple book and each book can be subscribed to multiple user. Library maintains a list of all books. User - Each User will have few functions - addMemberShip(), renewMemberShip(), cancelMemberShip(), accessSubscribedBook(), readBook() Book - This can actually be split into two parts… Continue reading CTCI: Design the data structures for an online book reader system

Laravel: Lazy Load and Lazy Eager Loading

Laravel Lazy Load If you do not need to add additional constraints to an Eloquent relationship query, you may simply access the relationship as if it were a property. For example, continuing to use our User and Postexample models, we may access all of a user's posts like so: $user = App\User::find(1); foreach ($user->posts as $post) { //… Continue reading Laravel: Lazy Load and Lazy Eager Loading

Monitoring Processes with Supervisord

Supervisord is a simple and popular choice for process monitoring. Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems. Supervisord is a script monitoring tool. Below is the conf file which. [program:nodehook] command=/usr/bin/node /srv/http.js directory=/srv autostart=true autorestart=true startretries=3 stderr_logfile=/var/log/webhook/nodehook.err.log stdout_logfile=/var/log/webhook/nodehook.out.log user=www-data environment=SECRET_PASSPHRASE='this is secret',SECRET_TWO='another secret'… Continue reading Monitoring Processes with Supervisord

Speed Up PHP

APC-Cache Zend engine needs 4 steps to run a PHP script 1. Read PHP code from file into memory 2. Lexing : convert to lexicons that can form syntax 3. Parsing and compiling : parsing lexicons into opcodes and validate language syntax 4. Executing: execute opcodes APC mainly hijacks step 3. Instead of having Zend… Continue reading Speed Up PHP