23 Haziran 2015 Salı

My Eclipse Preferences & Shortcuts

CTRL + SHIFT + o => import packages
CTRL + SHIFT + r => find & open resource

CTRL + SHIFT + f => format text


Creating Non Formatting Areas

Window >> Preferences >> Java >> Code Style >> Formatter >> Edit Profile >>  Off/On Tags >> Enable Off/On Tags
Usage:
// @formatter:off
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/", "/public/**").permitAll()
}
// @formatter:on


Formatting of Inline Elements & Line Width
Window >> Preferences >> Web >> Html Files >> Editor >>
Manage your line width and inline elements and make new line for every attribute

20 Haziran 2015 Cumartesi

Spring Framework Web Application Tutorials 3 - Externalization Of Text Messages & i18n

We start by creating the MessageSource Bean.

 @Bean
 public MessageSource messageSource() {
  ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
  messageSource.setBasename("locale/messages");
  messageSource.setDefaultEncoding("UTF-8");
  return messageSource;
 }

Above, we've set the path to the property files as resources/locale/messages. Next we create the property files: one for each language and one for default:



messages.properties:
hello.header=Welcome!
hello.content=Click here to advance to the next page
greeting.header=Hello on a second page!
greeting.content=Click here to go back
messages_fr.properties
hello.header=Welcome!
hello.content=Click here to advance to the next page
greeting.header=Bonjour!
greeting.content=Click here to go back

Next we create the localeResolver Bean and set the default locale, the cookie file name and the cookie's maximum age:

 @Bean
 public LocaleResolver localeResolver() {
  CookieLocaleResolver resolver = new CookieLocaleResolver();
  resolver.setDefaultLocale(new Locale("fr"));
  resolver.setCookieName("myLocaleCookie");
  resolver.setCookieMaxAge(4800);
  return resolver;
 }

Lastly, we set up the way to update the locale through creating LocaleChangeInterceptor Bean and registering it as a interceptor through addInterceptors



 @Bean
 public LocaleChangeInterceptor localeChangeInterceptor() {
  LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
  localeChangeInterceptor.setParamName("mylocale");
  return localeChangeInterceptor;
 }

 @Override
 public void addInterceptors(InterceptorRegistry registry) {
  registry.addInterceptor(localeChangeInterceptor());
 }

In the test.html, we call the message through the Thymeleaf notation as below:
<h3>i18n</h3>
<p th:text="#{greeting.header}"></p>
The Result:



When we set the variable mylocale through the URL, the locale is updated and the messages_fr.properties file is used as a source:


19 Haziran 2015 Cuma

Spring Framework Web Application Tutorials 2 - Thymeleaf Integration

I start by including the thymeleaf maven dependency into pom.xml

<dependency>
 <groupId>org.thymeleaf</groupId>
 <artifactId>thymeleaf-spring4</artifactId>
 <version>2.1.4.RELEASE</version>
</dependency>

18 Haziran 2015 Perşembe

Spring Framework Web Application Tutorials 1 - The Initial Setup & Hello World

You should have JRE, Maven, Tomcat, Eclipse (and preferable Git) installed. 


In Eclipse, in Package Explorer

  1. right click
  2. new
  3. other
  4. Maven
  5. Maven Project
  6. maven-archetype-webapp

In pom.xml include the dependency below


<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>


Let's include Spring Framework and Spring MVC dependencies (into pom.xml)

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>


Let's create the DispatcherServlet (which inherits from HttpServlet base class) and map the requests that we want our DispatcherServlet to handle. There are two ways to do this:

  1. web.xml
  2. A new class that implements WebApplicationInitializer (I choose this way)
While we create DispatcherServlet, we also create WebApplicationContext and tie to the servlet. While we are creating WebApplicationContext, we will tell it the Class (in my case: WebConfig.class) to look for the Bean definitions.

WebApplicationInitializer is an interface provided by Spring MVC that ensures your code-based configuration is detected and automatically used to initialize any Servlet 3 container. 

In the Web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. These inherited beans can be overridden in the servlet-specific scope, and you can define new scope-specific beans local to a given Servlet instance.

Upon initialization of a DispatcherServlet, Spring MVC looks for a file named [servlet-name]-servlet.xml in the WEB-INF directory of your web application and creates the beans defined there, overriding the definitions of any beans defined with the same name in the global scope.

The WebApplicationContext is an extension of the plain ApplicationContext (which is a Bean Factory with additional features) that has some extra features necessary for web applications. It differs from a normal ApplicationContext in that it is capable of resolving themes, and that it knows which Servlet it is associated with (by having a link to the ServletContext). The WebApplicationContext is bound in the ServletContext, and by using static methods on the RequestContextUtils class you can always look up the WebApplicationContext if you need access to it.

MyWebApplicationInitializer.java
package com.quizcv.web.config;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
public class MyWebApplicationInitializer implements WebApplicationInitializer {
public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(WebConfig.class);
ctx.setServletContext(servletContext);
Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1); }
}

WebConfig.java
package com.quizcv.web.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@Configuration
@EnableWebMvc
@ComponentScan(basePackages="com.quizcv")
public class WebConfig extends WebMvcConfigurerAdapter {
}

HelloWorldController.java

package com.quizcv.web.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloWorldController {
    @ResponseBody
    @RequestMapping("/helloWorld")
    public String helloWorld(Model model) {
        model.addAttribute("message", "Hello World!");
        return "helloWorld";
    }
}

The final project structure:




The Result:




A Fresh Windows Install : Windows 10 Pro Insider Preview 10074 & Softwares and Add-ons I use

A complete fresh install of Windows 10 Pro Insider Preview with the softwares and add-ons I use:

  • System
    • NVIDIA driver update (GForce 9400 GT)
    • Realtek High Definition Audio (software for my sound card
  • Utility
    • Chrome
      • Add-on: Google Alexa
      • Add-on: XMarks
      • AdBlock
    • Firefox
      • Add-on: GoogAlexa
      • Add-on: XMarks
    • 7-zip
    • Google Drive
    • VLC
    • MusicBee
    • Microsoft Office Professional Plus 2013 (Excel, World and PowerPoint only)
    • Picasa
    • Photoscape
    • Fotor
    • Adobe Acrobat Reader
    • Popcorn Time
    • Evernote
    • Notepad++

  • Software Development
    • Java SE Development Kit
      • Set JAVA_HOME environmental variable to F:\dev\java\JDK\jdk1.8.0_45
      • Check: run "SET" command in cmd and see your variable settings.
    • Git (msysgit)
    • Tomcat
    • Maven
      • Add the Maven bin dir (F:\dev\tool\apache-maven-3.3.3\bin) into Path environmentral variable
    • Eclipse
      • Add-on: M2Eclipse
    • S3 Browser
    • MongoDB
    • Robo

The current status
C:\Users\mustafa>git --version
git version 1.9.5.msysgit.1
 C:\Users\mustafa>java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
C:\Users\mustafa>mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T14:57:37+03:00)
Maven home: F:\dev\tool\apache-maven-3.3.3\bin\..
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: F:\dev\java\JDK\jdk1.8.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"
C:\Users\mustafa>ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32] 

17 Haziran 2015 Çarşamba

I Wish I Knews - Before Deciding On The Startup Idea

This post is a reply to a list of questions I've been asked by a friend of mine, due to his research.


I Wish I Knew Before I Decided To Launch Vanilya Club

Since it is now very clear that the main business value proposition behind Vanilya Club is not so strong, my reply to this question is: I wish I were much more experienced on valuating, assessing and detecting the weaknesses and strengths of a business idea. 



The Idea Comes First - Not The Team

In entrepreneurial talks, it is generally said that the more important element between the idea and the team, is the team because even if the idea is bad, a good team can change the idea and move on. In my experience, this is not always or even mostly true. I've seen many average teams that work on shiny ideas that became very successful, very fast; meanwhile, I've seen many brilliant teams that work on troublesome ideas that could not survive. So what you are trying to do is much more important that how you are trying to do it. If what you are trying to achieve or implement makes sense in terms of business, you will somehow learn the correct ways of doing it.

So do not trust in yourself or the wonderful team you have build, focus on the idea first.

Pivoting is very hard. Much harder than it sounds if you have an ongoing business (your startup, your customers, your suppliers...) You have to be damn lucky to make a good pivot. (Unless you have enough capital to terminate everything by burning your seed investment)


The Greatest Components of A Successful Business - and why beauty box subscription model is not a good business idea in Turkey

Scale - Scale Fast

The greatest problem behind Vanilya Club is that the business is very hard to scale and even more importantly scale fast. For the business to grow, we needed both the supply and demand to scale; and even more scale in accordance/together. A good business idea should not have anything in front of it that stops it growing / growing fast.

Cost Of Scaling

Another scaling problem is the incremental cost of it. While the business grows, are the problems also growing or lessening? Think of an online marketplace: the greatest problem of a marketplace is that when it is small, people are not interested so much because they will most probably not find what they are looking for. However if the marketplace is bigger, the matching of supply and demand is easier and hence it works better. And the incremental cost of growing is negligible. Vanilya Club's cost of scaling was very frightening due to the reasons below:

  • need of incremental capital (keep inventory)
  • operation is getting harder (many different beauty profiles, in terms of skin type, hair type etc..)
  • brand relations are getting harder to maintain (so much more brands that conflict with each other)

In short, nothing scales well and moreover scale comes with its incremental cost.

The Market Size and Market Fragmentation

Among the biggest mistakes I've made was the fact that I did not think / consider so much about the market size. Even worse, I did not have any idea about the market's formation: is it dominated my a few companies or is it very fragmented? Even even worse: I did not have any idea which is better.

  • High-end beauty market in Turkey is relatively very small compared to US and European countries. 
  • Annual spending per user is very low. 
  • Moreover internet penetration of beauty consumer products' market is lower that other consumer products' market. 
  • If a market is small, the focus of companies is by far on sales. Marketing department / responsible may even not exist in most of the companies. 
  • The beauty market in Turkey is not fragmented. A few big companies holds 80-90% of the market. Not well fragmented markets are not suitable at all for new ideas and startups. Startups need small companies that are looking for great new ways of doing business. Big companies are not interested in early stage ideas & businesses. So in an not sufficiently fragmented market, a startup will find harder a place to co-operate and develop its product.

Vanilya Club was an online marketing solution for high-end beauty brands in Turkey. What a mismatch !


16 Haziran 2015 Salı

Short History of Vanilya Club - The Beauty Box Subscription Startup in Turkey

I've spend my 40 months on www.VanilyaClub.com that I've started up in September 2011. My Vanilya Club story ended in December 2014, by an exit of an amount that did not worth all the hard-work and sacrifices; however the amount I've received was enough to let me spend my time without working for 1-2 years and start a new business in a modest way.


What is Vanilya Club & How Does It Work ?
Vanilya Club started as an online beauty box subscription service (like Birchbox or Glossybox) (in Turkey, October 2011) where consumers are buying memberships (monthly, recurring or fixed length subscription like 3 to 12 months) and in return they get a surprise box of 4-5 travel/sample size beauty products each month.

The Assumptions Behind The Business Model
The main assumption behind the idea is that people are looking for new beauty brands and products and they are willing to buy those products if they like; but that there is no efficient way for them to try & discover these products. Since people who are looking for new products are potential customers, brands would be willing to give away their products' samples for free.

Why I've Choosed This Busines Model ?
I did start this business model (even though I did not know anything about beauty and cosmetics) because it seemed like it requires no big capital: The sample size products would be supplied from the brands for free and people talking about the surprise box each month would offer free marketing. It sounds perfect for an entrepreneur without capital.

The Launch
The launch was good enough thanks to the viral video and all the bloggers buzz around the new offering. The only page that was about to collect e-mail addresses got more than 20K distinct email addresses in 15 days.

My Partner Comes In
Before the launch my ex partner came into the board. He was satisfied with the results and wanted to jump into the business. He is a perfect partner for anybody so we could easily get into agreement.

The Reality Appears
The real launch was in October 1st of 2011. In 20 days, there were more than 500 paying members. Everything was looking good in terms of demand.

However the real problem showed very early: the brands were not willing to give away free samples. Actually before the launch, I had visited more than 20 brands to introduce Vanilya Club and all the extraordinary(!) benefits it will offer to their brands. However the returns were blurred and I did not notice that, that actually mean "stop".

First Pivot
When I've realized that supplying free samples will be more than difficult each month, in the end of 1st month I've decided to change the business model. I've increased the membership fee to 35TL/month from 15TL/month; and I've announced to the brand managers that I will pay for some part of the costs of the samples and travel sizes. The business suddenly become more balanced in terms of both supply and demand however it was now clear that neither demand nor the supply can scale rapidly. In the end of 1st year, I've decided that it will not work out.

Second Pivot
I've always thought about selling full-size products in Vanilya Club but I was aware of the fact that keeping inventory is very risky and increases the need of capital very aggressively. My partner was believing that we could find some creative ways through cooperating with brands (mainly through consignee, drop shipping ..) however I have not been convinced for a long time.

So we started to look for other subscription models. The real reason behind it was that we were ready to launch any subscription business in terms of IT, payment and delivery infrastructure. After a big list of subscription businesses that I've deeply analysed, I've come up with the Babbabox  or similarly Kiwicrate model. We were incredibly fast and we launched in 3 months our new service: PandaKutu (www.PandaKutu.com)

We have terminated PandaKutu in its 7.months due to the feeling that it has serious problems in terms of demand. I will not get into the details about Panda Kutu in this post but certainly I can in another post.

Third Pivot
Meanwhile, Vanilya Club was going on smoothly, we were breaking even thanks to our economical style of living & working. After Panda Kutu, we started to look for expansion opportunities again. At the end of long discussions, even though I never was convinced, we decided to give e-commerce a try. The mathematics of e-commerce was very cruel for companies without capital so I've build a financial model to find out what I would expect from a supplier in terms of profitability and payment term.

Somehow many of the suppliers did not disagree with my aggressive working conditions due to the very good and friendly relationships I've built: %40 top-down profitability on discounted consumer prices and 120-150 days for the settlement date. These conditions were much better compared to our competitors' .We started to buy products, keep small inventory and sell full size products. The business more than tripled in less than 6 months however the need of capital has never been negligible.

Funding Options
We had some talks with venture capitals however none of them was excited to invest in beauty category of e-commerce, due to the fact that there were some companies that had investment and did not go well.

How Did Not We Go Bankrupt ?
We have implemented a lots of marketing offering into the site for cross selling, bundling and promotion. We have increased our profitability for more than 20% on the overall portfolio, due to all the marketing tricks we have discovered. We offered 3 free samples and 1 gift within each transaction which affected our sales and word of mouth marketing very positively.

My Partner Quits
At the end of the summer 2014 my partner decided to quit because he draw the conclusion that e-commerce is the hardest and riskiest way to earn money. I was also agreeing with his conclusion however I was not ready to give up because I was feeling that all the things we do differently, all the marketing tricks we've discovered were making us much more profitable than our competitors and all I need to do was to show this mathematics to an investor, raise capital, and dominate the market.

Investors That Do Not Like Math
Unfortunately I did not meet any angel or venture capital that can think really analytically or mathematically. I've never talk to someone who can discuss the mathematics of the business. The overly complex excel analysis and plans were to frightening for them to get into.

My Exit
One day (end of 2014), I was chatting with the partners of a company I was buying products from. They showed their intention to buy Vanilya Club. Within a week we get into agreement.