Skip to content

Instantly share code, notes, and snippets.

@aprofromindia
aprofromindia / autocomplete.xml
Created December 11, 2015 10:52
Android autocomplete layout with X button
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/search_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search_address_hint"
@aprofromindia
aprofromindia / Collection.swift
Last active January 29, 2017 11:58
Collection extension for Binary search
extension Collection where Self.Iterator.Element: Comparable {
func binarySearch(element: Iterator.Element) -> Index {
var low = startIndex, high = index(startIndex, offsetBy: count - 1)
while low <= high {
let i = index(low, offsetBy: distance(from: low, to: high)/2)
if self[i] == element {
return i
@aprofromindia
aprofromindia / Backend challenge 1.md
Last active May 19, 2017 14:09
Web Backend Developer Test 1

Backend Developer Challenge

Build a system that will accept a multipart form upload while displaying a percentage progress

Specification

When a user picks a file from their computer, the upload automatically begins. While uploading the % complete is visible on the page. It should atleast update the status every 2 seconds. Please ensure the progress bar works in a range of browsers including IE8.

Please try to avoid too many libraries for the task, unless required

Backend Developer Challenge

The challenge proposed here is to build a system which acts as a socket server, reading events from an event source and forwarding them when appropriate to user clients.

Clients will connect through TCP and use the simple protocol decribed in the section below. There will be 2 types of clients connecting to your server: -

1 event source: - It will send you a stream of events which may or may not require clients to be notified.
Many user clients: - Each one representing a specific user, these wait for notification for events which would be relevant to the user they represent.

Please try to avoid any unrequired code libraries for the task, unless specifically required

@aprofromindia
aprofromindia / wild.md
Created May 19, 2017 14:11
Wild Card Mobile Architecture proposal

Please find my solution below:

  1. I propose to use an MVVM based application architecture.
  2. for iOS I would recommend data binding (View to ViewModel) using RxSwift for a sample implementation by myself click here.
  3. for Android I would propose Data Binding with my own helper library. Rest of the document would only focus on an iOS solution.
  4. As for code organisation, we can use an use-case based folder grouping.
  5. We should also separate our classes into Entities, Domain Services, Application Services, Repositories and Network layer.
  6. the RESTClient should be a singleton, sample [implementation here](https://github.com/aprofromindia/Yahoo-Weather/blob/master/Yahoo%20Weather/RE
@aprofromindia
aprofromindia / StringUtils.java
Created July 20, 2017 17:36
Generic String Utils collection
package com.github.aprofromindia.utils;
import javax.validation.constraints.NotNull;
public class StringUtils {
public static String capitalize(@NotNull String string) {
StringBuilder builder = new StringBuilder();
if (string.length() > 0) {
builder.append(string.substring(0, 1).toUpperCase());
}
@aprofromindia
aprofromindia / Image Search Mobile Coding Task.md
Last active January 18, 2018 14:27
Google Image Search Mobile Coding Task

iOS/Android Mobile Developer Coding Task

Many thanks for investing the time in interviewing with us. For the next step we would like you to create a Google Image Search mobile client (iOS/Android app) to display an infini-scroll Image list based on a user's search input.

Please follow the following guidelines while developing : -

  • Please use the Google Image Search API for searching and fetching relevant images.
  • Please refrain from using any additional 3rd party APIs (e.g. Alamofire, Retrofit, RxJava etc...) except for the iOS or Google Android SDK, as required.
  • Please focus on proper code structure and applying OOP and/or SOLID coding principles as and when applicable.
  • Please don't spend too much time on producing a snazzy UI; we are more interested in your coding competency.
  • Ideally you shouldn't spend more than 4 hours to finish this task.
  • Please ensure you submit the task within 7 working days fro
@aprofromindia
aprofromindia / Sample.java
Last active July 5, 2018 12:51
Flatten a multi level array
List<Integer> flatten(final List<?> arrays) {
final List<Integer> result = new ArrayList<>();
flattenRecursive(arrays, 0, result);
return result;
}
private void flattenRecursive(List<?> arrays, int index, List<Integer> result) {
if (arrays.get(index) instanceof List<?>) {
flattenRecursive((List<?>) arrays.get(index), index, result);
} else if (arrays.get(index) instanceof Integer) {
@aprofromindia
aprofromindia / Mobile Coding Task.md
Last active August 29, 2018 21:29
iOS/Android Coding Task

iOS/Android/React Native Mobile Developer Coding Task

Many thanks for investing the time in interviewing with us. For the next step we would like you to create a Twitter mobile client (iOS/Android/React Native app) to display the 50 most trending topics around a users' current location.

Please submit the code for the specific platform your were asked to in the interview.

Please follow the following guidelines while developing : -

  • Please use the Twitter Trends API to fetch the relevant trends data.
  • Please refrain from using any additional 3rd party APIs (e.g. Alamofire, Retrofit, RxJava etc...) except for the iOS or Google Android SDK, as required.
  • Please focus on proper code structure and applying OOP and/or SOLID coding principles as and when applicable.
  • Please don't spend too much time on producing a snazzy UI; we are more interested in your coding competency.
@aprofromindia
aprofromindia / JacksonConfig.java
Created October 7, 2018 22:07
Spring Jackson Java 8 Date Time Config
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
class JacksonConfig {
@Bean
Module dateTimeModule() {
return new JavaTimeModule();