Tuesday, December 22, 2015

GIT - swap origin from master to develop branch

Easy steps to swap local branches from master to develop, do it from working directory:

git fetch && git checkout develop
git remote set-head origin develop

Friday, December 11, 2015

GRADLE - delete whole directory with all subdirectories

Override clean task:

clean {
    delete += 'dist'
}

If you do like this it will remove all files but leaves empty sub-directories:(!!!!!!)
clean {
    delete += fileTree('someDir')
}
or
clean {
    delete += fileTree('someDir').include('**/*')
}

Saturday, December 5, 2015

Friday, December 4, 2015

CSS - best place to choose right color palette for your web app

Here you will find variety of web sites samples of different color palette
http://www.colourlovers.com/

Thursday, November 26, 2015

IDIOM - ready to take on the world

ready to take on the world - is an idiom

It means:

"to try to do a lot/too much"
"to try to fight with everyone"
In this particular case it probably means "trying to do too much".

GRADLE - gradle tutorial (link)

https://docs.gradle.org/current/userguide/tutorial_using_tasks.html

Wednesday, November 25, 2015

IDIOM - lean and mean

'lean and mean' is idiom.
It mins: capable and ready for hard, efficient work

More here.

BOWER - difference between tilde(~) and caret(^) before version number

In the simplest terms, the tilde matches the most recent minor version (the middle number). ~1.2.3 will match all 1.2.x versions but will miss 1.3.0.
The caret, on the other hand, is more relaxed. It will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0.

More is here.

Tuesday, November 24, 2015

GULP - how to configure Gulp to use Sass instead of Less

In order to use Sass instead of Less with Gulp follow this instruction:
https://www.npmjs.com/package/gulp-ruby-sass

and here:
https://github.com/sindresorhus/gulp-ruby-sass

Here is the gulp task for Sass (instead of Less) in HotTowel generator for Angular project:

var sass = require('gulp-ruby-sass');

/** * Compile less to css * @return {Stream} */gulp.task('styles', ['clean-styles'], function() {
    /*log('Compiling Less --> CSS');
    return gulp        .src(config.less)        .pipe($.plumber()) // exit gracefully if something fails after this        .pipe($.less())//        .on('error', errorLogger) // more verbose and dupe output. requires emit.        .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))        .pipe(gulp.dest(config.temp));*/
    log('Compiling Sass --> CSS');
    return sass(config.sass)
        .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
        .pipe(gulp.dest(config.temp));
});
gulp.task('sass:watch', function () {
    gulp.watch(config.sass, ['sass']);
});

ANGULAR - Angular style guide from John Papa

Angular style guide from John Papa (https://twitter.com/john_papa)
https://github.com/johnpapa/angular-styleguide

Angular course from John Papa:
https://www.pluralsight.com/courses/angularjs-patterns-clean-code

ANGULAR - generator-hottowel. Nice angular generator for Gulp (link)

https://github.com/johnpapa/generator-hottowel

Friday, November 20, 2015

GIT - proxy settings

Edit with e.g. Far .gitconfig (usually it is located under C:\Users\youraccount\)


Add these locs:

[http]
sslVerify = false
proxy = http://username:passwd@domain:port

Where “username” is your domain username.

The same you can do it with editing in CLI e.g. cmd :
git config --global --edit
or
git config --global http.sslVerify false

git config --global http://username:passwd@domain:port

REST - good tutorial for REST API (link)

http://restapitutorial.com/

Tuesday, November 17, 2015

ANGULARJS + SPRAY + AKKA example (link)

http://www.cakesolutions.net/teamblogs/2014/05/08/spray-akka-and-angularjs

CHROME - blur issues in Windows 8

Only Chrome:
By default Chrome has a strange blur in Windows 8.
How to fix it: in Chrome properties check "Disable display scaling".
That's all. Here is more: https://productforums.google.com/forum/#!topic/chrome/9DnjIpD3xoE

Across all Windows 8:
In order to remove blur over all Windows applications go to Display settings and set scaling to 100% (default is 120%). See here: http://www.thewindowsclub.com/fonts-appear-blurred-windows-8

Monday, November 2, 2015

Friday, October 23, 2015

SPRING - stereotypes example

import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Service;
import java.util.*;
@Service("myConfigServiceFacade")public class MyConfigServiceFacadeImpl implements MyConfigServiceFacade {

    @Value("${com.foo.isWebSSOEnabled}")
    private String webSSOEnabled;
    @Value("${com.foo.webSSOlogoutURL}")
    private String webSSOInternetLogoutURL;
    @Value("${com.foo.webSSOlogoutURL}")
    private String webSSOIntranetLogoutURL;
    @Value("${com.foo.brandbarURL}" )
    private String brandbarURL;
    @Value("${com.foo.4eye.active}")
    private boolean is4eyeActive;
    @Autowired
    private MyPrincipalService principalService;

====================================================

import com.google.gwt.user.client.rpc.RemoteService;import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;import java.util.Map;import java.util.Set;
@RemoteServiceRelativePath("services/myConfigServiceFacade.rpc")
public interface MyConfigServiceFacade extends RemoteService {
    ApplicationInfo getApplicationInfo();
    SessionInfo config() throws Exception;
    Map<Long, Set<String>> configAllowedAccounts(Long var1, Long var2) throws Exception;}

Wednesday, October 21, 2015

ANDROID - align linearlayout each one behind other programmatically

http://stackoverflow.com/questions/12108370/how-to-setcontentview-in-a-fragment

The method setContent(relativeLayout) on Activity in case of Fragments need to be replaced with return this relatiVeLayout from onCreateView or do from onViewCreated this:

RelativeLayout rootContainer = (RelativeLayout)mainActivity.findViewById(R.id.rootContainer);
rootContainer.addView(rl);

Saturday, October 17, 2015

TOOLS - Colorzilla, nice color picker tool for browser

Colorzilla http://www.colorzilla.com/
Very nice plugin for browsers Chrome and Firefox. It allows to pick colors and see its numeric value in very handily way.

FONTS - safe web fonts for CSS

http://www.cssfontstack.com/Candara

Friday, October 16, 2015

ANGULAR - add logo image in navbar

http://bootply.com/77512

ANGULAR - 15 Best AngularJS Tutorials for Developers

https://codegeekz.com/best-angularjs-tutorials/

Popular one;
https://www.codeschool.com/courses/shaping-up-with-angular-js

ANGULAR - left menu, multiple controllers

https://www.codecademy.com/courses/javascript-advanced-en-2hJ3J/1/1#

index.html
<!doctype html>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
        <script src="app.js"></script>
        <script src="user.js"></script>
        <script src="menu.js"></script>
        <script src="content.js"></script>
        <link rel="stylesheet" href="style.css">
    </head>
    <body ng-app="exampleApp">
        <header ng-controller="userCtrl">Welcome {{user}}!</header>
        <nav ng-controller="menuCtrl">
            <h2>Menu</h2>
            <ul>
                <li ng-repeat="link in links">{{link}}</li>
            </ul>
        </nav>
        <article ng-controller="contentCtrl">
            <h1>{{title}}</h1>
            <hr />
            <p>{{paragraph}}</p>
            <small >by {{author}}</small>
        </article>
    </body>
</html>

app.js
// Defining a module
angular.module('exampleApp', []);

user.js
angular.module('exampleApp')
    .controller('userCtrl', function ($scope) {
        $scope.user = "Jan Kowalski";
    });

menu.js
angular.module('exampleApp')
    .controller('menuCtrl', function ($scope) {
        $scope.links = ['Link 1', 'Link 2'];
    });

content.js
angular.module('exampleApp')
    .controller('contentCtrl', function ($scope) {
        $scope.title = "Lorem Ipsum";
        $scope.paragraph = "Completely myocardinate process-centric "
        + "total linkage whereas installed base e-tailers. "
        + "Proactively extend collaborative intellectual capital "
        + "vis-a-vis unique expertise. Dynamically.";
        $scope.author = "Anna Nowak";
    });

style.css
body {
    width: 500px;
}

nav {
    float: left;
    width: 30%;
}

article {
    margin-left: 30%;
    width: 70%;
}

Thursday, October 15, 2015

ANGULAR - links on different components implementaiotion

Angular Dropdown menu:
https://www.codementor.io/angularjs/tutorial/create-dropdown-control
https://angular-ui.github.io/bootstrap/
https://github.com/jseppi/angular-dropdowns (https://jsfiddle.net/jseppi/cTzun/142/embedded/result/)


Angular Left menu:
http://stackoverflow.com/questions/18599753/vertical-navbar-using-bootstrap-and-angular (http://plnkr.co/edit/UBBq7V8mdyqllBHdwegY?p=preview)

Angular Subheader
http://codepen.io/svswaminathan/pen/MYBrgM

Saturday, October 3, 2015

ANDROID - how to enable your mobile phone for Android Studio on Windows

Case:
You want to run/debug Android app on your phone (e.g. Samsung Galaxy  S2) instead of emulator (which sucks), but Android Studio (Windows version of it) can not see it among available devices.

Solution:
FIRST OF ALL The last thing you will think it is important, but it is indeed: install on Windows USB drivers for you phone model!!! 
For instance:
Samsung Galaxy S2http://www.samsung.com/us/support/owners/product/SGH-I777ZKAATT
LG L9http://www.lg.com/us/support-mobile/lg-LGP769BK
Then enable some phone settings:
Developer options / USB debugging
Security / Unknown sources (Allow installation of apps from sources other than Play Store)

Thursday, October 1, 2015

JVM - stack, heap etc good explained (link)

http://blog.jamesdbloom.com/JVMInternals.html

JAVA - when WeakReference and SoftReference are equaly garbage collected

WeakReference - is ALWAYS eagerly garbage collected.
SoftReference - is LESS eagerly garbage collected on Server JVM.

The Sun JRE does treat SoftReferences differently from WeakReferences. We attempt to hold on to object referenced by a SoftReference if there isn't pressure on the available memory. One detail: the policy for the "-client" and "-server" JRE's are different: the -client JRE tries to keep your footprint small by preferring to clear SoftReferences rather than expand the heap, whereas the -server JRE tries to keep your performance high by preferring to expand the heap (if possible) rather than clear SoftReferences. One size does not fit all.

More here...

JAVA - collections, the main difference between Map and SortedMap contracts

The main difference between Map and SortedMap contracts is its approach to comparing of keys.

Map contract is to compare keys with equals method.
SortedMap contract is to compare keys with provided or class natural compator.

From javadoc of Comparable<T> interface: This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method.

Objects that implement this interface can be used as keys in a sorted map or as elements in a sorted set, without the need to specify a comparator.

Why NULL can not be set as value in Set?
The natural ordering for a class C is said to be consistent with equals if and only if e1.compareTo(e2) == 0 has the same boolean value as e1.equals(e2) for every e1 and e2 of class C. Note that null is not an instance of any class, and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.

Wednesday, September 30, 2015

GIT - 'git reset' my explanation

When and how to use git reset.

Case 1:
You have commited changes, but not yet pushed it. (never reset shared (pushed) commits, read this)
AND
You want to undo this commit and continue to work on these changes in it.
git reset --soft HEAD~1

Case 2:
You have commited changes, but not yet pushed it. (never reset shared (pushed) commits, read this)
AND
You want to undo this commit and DO NOT WANT to continue to work on these changes in it.
git reset --hard HEAD~1
In this case all changes of this commit will be lost and you will not see it in your Local Changes list (e.g. in InteleJIdea IDE)

HEAD~1 means 'one commit from HEAD'

Tuesday, September 22, 2015

THREAD - how to stop running thread

private volatile Thread blinker;

    public void stop() {
        blinker = null;
    }

    public void run() {
        Thread thisThread = Thread.currentThread();
        while (blinker == thisThread) {
            try {
                Thread.sleep(interval);
            } catch (InterruptedException e){
            }
            repaint();
        }
    }

http://docs.oracle.com/javase/7/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html

JAVA COLLECTIONS framework structure


Friday, September 11, 2015

Friday, August 28, 2015

DATA STRUCTURE - Persistent Data structure

In computing, a persistent data structure is a data structure that always preserves the previous version of itself when it is modified.

https://en.wikipedia.org/wiki/Persistent_data_structure

DATA STURCTURE - Singly and Dobly linked list

Basic explanation Singly and Dobly Linked list https://en.wikipedia.org/wiki/Linked_list

Dobly Linked list  https://en.wikipedia.org/wiki/Doubly_linked_list

JavaScript - collection method explaned

http://www.thatjsdude.com/interview/linkedList.html

Monday, August 24, 2015

JAVA - Out of Memory Errors by Incorrect Implementation of Equal and Hashcode, link

The relationship between the hashcode and equals methods and memory problems is not obvious at first. But we only need to think about hashmaps to make it more clear. An object's hashcode is used to insert and find objects in hashmaps. However, the hashcode is not unique, which is a why it only selects a bucket that can potentially contain multiple objects. Because of this, the equals method is used to make sure that we find the correct object. If the hashcode method is wrong (which can lead to a different result for otherwise-equal objects), we will never find an object in a hashmap. The consequence is often that the application inserts an object again and again.
Although the growing collection can easily be identified by most tools, the root cause is not obvious in a heap dump. I have seen this case over and over through the years, and one extreme case led the customer to run his JVMs with 40 GB of memory. The JVM still needed to be restarted once a day to avoid out-of-memory errors. We fixed the problem and now the application runs quite stable at 800 MB!
A heap dump — even if complete information on the objects is available — rarely helps in this case. One simply would have to analyze too many objects to identify the problem. The best approach is to be proactive and automatically unit-test comparative operators. A few free frameworks (such as EqualsVerifier) ensure that the equals and hashcode methods conform to the contract.
Use EqualsVerifier for Java UnitTests

Friday, July 31, 2015

Tuesday, July 21, 2015

GWT Scheduler.scheduleDeferred implementation

Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
    @Override    public void execute() {
        render();    }
});

Friday, June 19, 2015

GWT - ListBox with Enum vs ValueListBox implementation example


public class EnumListBoxEditor<T extends Enum<T>> implements IsWidget, LeafValueEditor<T> {

    private ListBox listBox;    private Class<T> enumType;
    public EnumListBoxEditor(Class<T> tClass) {
        listBox = new ListBox();        this.enumType = tClass;        for(T e : enumType.getEnumConstants()) {
            listBox.addItem(e.name());        }
    }

    @Override    public Widget asWidget() {
        return listBox;    }

    @Override    public void setValue(T language) {
        listBox.setSelectedIndex(language.ordinal());    }

    @Override    public T getValue() {
        int index = listBox.getSelectedIndex();        T result = null;        for (T e : enumType.getEnumConstants()) {
            String itemName = listBox.getValue(index);            if (e.name().equals(itemName)) {
               result = e;            }
        }
        return result;    }

    public void setEnabled(boolean isEnabled){
        listBox.setEnabled(isEnabled);    }

}

Thus this approach is acceptable the best way to use ListBox with any Enum or bean that implement HasLabel interface is ValueListBox component e.g.:

@UiField(provided = true)
ValueListBox<TeamDTO> team;
 
this.team = new ValueListBox<TeamDTO>(new HasLabelRenderer<TeamDTO>(), new IdentityProvidesKey<TeamDTO>());
 
public class HasLabelRenderer<T extends HasLabel> extends AbstractRenderer<T>{

    @Override    public String render(HasLabel object) {
        return object == null ? "" : object.getLabel();    }

}
 
public class IdentityProvidesKey<T extends Identity> implements ProvidesKey<T> {
    @Override    public Object getKey(T item) {
        return item == null ? null: item.getId();    }
}

Thursday, June 18, 2015

JAVA - example of use in overrided method generic type of class that extends interface

public class HasLabelRenderer<T extends HasLabel> extends AbstractRenderer<T>{

    @Override    public String render(HasLabel object) {
        return object == null ? "" : object.getLabel();    }

}

This approach is possible due to the fact that in generics e.g. Bounded Type Parameter the type can be of the upper type it is extended. For instance, in example above the type T in HasLabelRenderer<T extends HasLabel>  can be of type HasLabel interface.

Sunday, June 7, 2015

INTERVIEW - The Art Of Hiring Great Javascript Developers

http://www.zsoltnagy.eu/the-art-of-hiring-great-javascript-developers/?utm_content=bufferb411d&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer

JavaScript - iterate or loop over JavaScript object or JSON

It is taken from here: http://stackoverflow.com/questions/684672/loop-through-javascript-object

In JavaScript, every object has a bunch of built-in key-value pairs that have meta-information. When you loop through all the key-value pairs for an object you're looping through them too. hasOwnPropery() filters these out:

for (var key in p) {
  if (p.hasOwnProperty(key)) {
    alert(key + " -> " + p[key]);
  }
}
In ECMAScript 5 you have new approach in iteration fields of literal - Object.keys
More information you can see on MDN
My choice is below as a faster solution in current versions of browsers (Chrome30, IE10, FF25)

var keys = Object.keys(p),
    len = keys.length,
    i = 0,
    prop,
    value;
while (i < len) {
    prop = keys[i];
    value = p[prop];
    i += 1;
}

KARMA + JASMINE tutorial for testing

http://www.bradoncode.com/blog/2015/02/27/karma-tutorial/

Friday, June 5, 2015

GWTBootstrap - custom email validation for TextBox

=== JAVA CODE ===

TextBox emailLookup = new TextBox();
emailLookup.addValidator(new Validator() {
            @Override
            public int getPriority() {
                return 0;
            }

            @Override
            public List<EditorError> validate(Editor editor, Object value) {
                List<EditorError> result = new ArrayList<EditorError>();
                String valueStr = value == null ? "" : value.toString();
                if (!valueStr.matches(EMAIL_REGEXP)) {
                    result.add(new BasicEditorError(emailLookup, value, "Not a valid email address"));
                } else if (isEmailReapeated(valueStr)) {
                    result.add(new BasicEditorError(emailLookup, value, "Email address is repeated"));
                }
                return result;
            }
        });

=== UI BINDER ===

<b:Row addStyleNames="{style.padding}">
    <b:Column size="XS_12">
        <b:Row>
            <b:Column size="XS_2">
                <b:FormGroup>
                    <b:TextBox ui:field="emailLookup" placeholder="Enter email" allowBlank="false"/>
                    <b:InlineHelpBlock iconType="EXCLAMATION"/>
                </b:FormGroup>
            </b:Column>

            <b:Column size="XS_1">
                <b:Button ui:field="addContact" text="Add"/>
            </b:Column>

        </b:Row>
    </b:Column>
</b:Row>

D3 Karma Jasmine testing

http://busypeoples.github.io/post/testing-d3-with-jasmine/

JavaScript Karma Jasmine - JSON parsing tests

http://stackoverflow.com/questions/20938320/loading-external-file-from-karma-jasmine-test
http://stackoverflow.com/questions/25035688/json-parse-fails-in-jasmine

ANGULAR + KARMA + JASMINE: test controller with $http, $scope

https://docs.angularjs.org/api/ngMock/service/$httpBackend

Tuesday, June 2, 2015

JAVA GWT - entity persistence approach

== IDENTITY ==
import java.io.Serializable;

public interface Identity<T extends Serializable> extends Serializable{
    T getId();
    void setId(T id);
}

JAVA Annotation - GWT impl of email validation on bean field

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import javax.validation.constraints.Pattern;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Replacement for the Hibernate Email constraint that is not supported by GWT.
 * <p/>
 */
@Documented
@Constraint(validatedBy = {})
@Pattern(regexp = "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9!#$%&'*+/=?^_`{|}~-]+(\\" +
        ".[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])$", flags = Pattern
        .Flag.CASE_INSENSITIVE)
@ReportAsSingleViolation
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
public @interface Email {
    String message() default "{org.hibernate.validator.constraints.Email.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * Defines several {@code @Email} annotations on the same element.
     */
    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
    @Retention(RUNTIME)
    @Documented
    public @interface List {
        Email[] value();
    }
}

JAVA Annotation for phone number validation of bean field

==== USE OF ANNOTATION ON BEAN FIELD ====
   @Phone
    public String getPhone() {
        return phone;
    }

==== PHONE NUMBER VALIDATION CLASS ===
import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import javax.validation.constraints.Pattern;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Created by baraole on 27/05/2015.
 */
@Documented
@Constraint(validatedBy = {})
@Pattern(regexp = "\\+?[0-9()]+")
@ReportAsSingleViolation
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
public @interface Phone {
    String message() default "not a well-formed phone number";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * Defines several {@code @Phone} annotations on the same element.
     */
    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
    @Retention(RUNTIME)
    @Documented
    public @interface List {
        Phone[] value();
    }
}

JS frameworks comparision

http://habrahabr.ru/post/259311/

MongoDB - шпаргалка

http://habrahabr.ru/post/259219/

AngularJS - Combating AngularJS executing controller twice

AngularJS docs - ngController
Note that you can also attach controllers to the DOM by declaring it in a route definition via the $route service. A common mistake is to declare the controller again using ng-controller in the template itself. This will cause the controller to be attached and executed twice.

http://stackoverflow.com/questions/15535336/combating-angularjs-executing-controller-twice

Monday, May 25, 2015

Font Awesome resources

http://www.bootstrapcdn.com/

JavaScript - JSON.parse(), JSON.stringify()


https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

Sunday, May 24, 2015

Spring Boot gradle webapp with Java persistence on server side and AngularJS+Bootstrap on client (link)

http://www.rnowak.info/2014/06/spring-boot-and-angularjs-quick-start.html

WebStorm JetBrains - install and run sample AngularJS app

1. Install WebStorm
2. Install NodeJS
3. Check it is installed:
   C:\Users\Andre>npm -version
   2.10.1
4. Run from the AngularJS root project directory npm install:
e.g. listed below.
5. In order to debbug JavaScript check that your Chrome has jetbrains-ide-support extension. If it is not installed look for it here: https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji

JavaScript - testing tools: Jasmine (BDD), JsUnit, Karma (test runner)

1. Jasmine http://jasmine.github.io/ is the priority for testing, due to its BDD approach. 
2. JsUnit is an option (w/o BDD):http://www.jsunit.net/
3. Karma http://karma-runner.github.io/0.12/index.html - it is JavaScript test runner.

AngularJS + Bootstrap best practice

The main point: with AngularJS use pure CSS Bootstrap (don't use BootstrapJS)
https://scotch.io/tutorials/how-to-correctly-use-bootstrapjs-and-angularjs-together

angular.bootstrap - function in module ng:  https://docs.angularjs.org/api/ng/function/angular.bootstrap

Saturday, May 23, 2015

JavaScript - shuffle an array, mix up array elements randomly

Mix up (shuffle) array JavaScript function is taken from here:
Fisher–Yates Shuffle http://bost.ocks.org/mike/shuffle/
function shuffle(array) {
  var m = array.length, t, i;

  // While there remain elements to shuffle…
  while (m) {

    // Pick a remaining element…
    i = Math.floor(Math.random() * m--);

    // And swap it with the current element.
    t = array[m];
    array[m] = array[i];
    array[i] = t;
  }

  return array;
}

Friday, May 22, 2015

JavaScript D3 - random integer number

Decimal values are fine, but if you ever need whole numbers, you can use JavaScript’s Math.round() method. For example, you could wrap the random number generator from this line
    var newNumber = Math.random() * 30;
as follows:
    var newNumber = Math.round(Math.random() * 30);
Example:
d3.selectAll("p").style("color", function() { return "hsl(" + Math.round(Math.random() * 360) + ",100%,50%)"; });

JavaScript D3 - The power of data()

http://alignedleft.com/tutorials/d3/the-power-of-data

Wednesday, May 20, 2015

Create ls command for Windows cmd

In order to enable cmd on Windows run ls command just run from command line this:
echo dir %1 > %systemroot%\system32\ls.bat

Javascript D3 good basic explanation

http://synthesis.sbecker.net/articles/2012/07/08/learning-d3-part-1

JavaScript D3 - example how the function(d, i) works

http://jsfiddle.net/M8nK8/

==HTML==
<script src="http://d3js.org/d3.v3.min.js"></script>
<section></section>


===JS D3==

var data=[10,20,30,40];

var lis = d3.select("section")
          .append("ul")
            .selectAll("li")
            .data(data)

lis.enter()
 .append("li")
 .text(function(d,i){ return "item n° "+i+" has value: "+d})

JavaScript D3 - forEach() vs each() function

The main takeaway is that, using .each() you get access to 3 things you need: dthis and i. With .forEach(), on an array (like in the example from the beginning) you only get 2 things (d and i), and you'd have to do a bunch of work to also associate an HTML element with those 2 things. And that, among other things, is how d3 is useful.

http://stackoverflow.com/questions/13465796/d3-javascript-difference-between-foreach-and-each

Tuesday, May 19, 2015

GWT DataGrid with LeafValueEditor

====== UIBINDER =======

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:g='urn:import:com.google.gwt.user.client.ui'
             xmlns:b.grid='urn:import:org.gwtbootstrap3.client.ui.gwt'
             xmlns:b='urn:import:org.gwtbootstrap3.client.ui' >

Wednesday, May 13, 2015

Monday, May 11, 2015

Bootstrap free themes - link

Apache Tomcat - good explanation of install etc, "how to"

Could not reserve enough space for object heap

Here is the errors during the Maven build:

Error occurred during initialization of VM 
Could not reserve enough space for object heap 
Error: Could not create the Java Virtual Machine. 
Error: A fatal exception has occurred. Program will exit. 
Picked up _JAVA_OPTIONS: -Duser.home=C:\Users\Andre

In order to fix this, add an extra parameter to _JAVA_OPTIONS sys environment:
-Xmx512m

So it should look something like this:
_JAVA_OPTIONS: -Duser.home=C:\Users\Andre -Xmx512m

Issues with user.home during Maven build

If you have issue with incorrect property user.home during Maven build set this sys environment:

_JAVA_OPTIONS=C:\Users\username

More of it here:
http://stackoverflow.com/questions/1501235/change-user-home-system-property

Friday, May 8, 2015

GWT - how dynamically change a static css of theme in GWT Dev Mode

We know that all static resources e.g. images, css should be kept in project structure in static way e.g. through resource or public packages. This principle supposes that these kind of resources rarely will be changed. But if in your RIA GWT project you have to override some theme's css by some custom-style.css and see the result lets say "right now" in Dev Mode there would be the problem because if both css stored statically you can not dynamically see the result of the change just by refreshing the browser page e.g. F5.

If you want to see your css changes dynamically in GWT Dev Mode you have to inject your e.g. custom-style.css through ClientBundle somewhere in the beginning e.g. onModuleLoad().

===== Create this class inside resource package in you java src ====
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.CssResource.NotStrict;

/**
 * Created by panoand on 08/05/2015.
 */
public interface AppResources extends ClientBundle {

    AppResources INSTANCE = GWT.create(AppResources.class);

    @Source("css/custom-style.css")
    @NotStrict
    CssResource foo();
}

===== In your EntryPoint class put it inside onLoadModule() methode =====
AppResources.INSTANCE.foo().ensureInjected();







Thursday, May 7, 2015

GWT project settings

=========== app-client =================

<?xml version="1.0" encoding="UTF-8"?>
<project
        xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

GWT - LeafValueEditor implementation for RadioButton widget with Enum type

package com.paniov.bitwitwebapp.client.widgets.editors;

import com.google.gwt.editor.client.LeafValueEditor;
import com.google.gwt.uibinder.client.UiConstructor;
import org.gwtbootstrap3.client.ui.RadioButton;
import org.gwtbootstrap3.client.ui.html.Div;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Paniov on 06.05.15.
 */
public class EnumRadiobuttonEditor extends Div implements LeafValueEditor<ButtonsType> {