May 11, 2014

Translate Angular-UI DatePicker - text and popup buttons too

You might want to Angular-UI date picker in your own language instead of default english.
Fortunately, guys at Angular-UI team did the job well and used i18n angular system.

All you have to do is to include the correct language pack :

...
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script>
<script src="https://code.angularjs.org/1.0.2/i18n/angular-locale_fr-fr.js"></script>
...


There's still the popup action buttons that are not translated.
As stated in the doc, you can configure the text displayed in those buttons by altering the datepickerPopupConfig global object default values :


// INJECT GLOBAL DATE PICKER POPUP CONFIG
var DatepickerDemoCtrl = function ($scope, datepickerPopupConfig) {
...
// TRANSLATION HERE
datepickerPopupConfig.currentText = 'Aujourd\'hui';
datepickerPopupConfig.clearText = 'Effacer';
datepickerPopupConfig.closeText = 'Fermer';
...
}
Here's a Plunkr for demoing purpose.

Hope this help !

March 18, 2014

Angular JS : Angular-UI modals won't show up with Bootstrap 3

While migrating from Bootstrap 2 to 3 in an angular jS app, realized there was a bug in modals implementation : Angular-UI directive doesn't add a "display block" CSS prop to the built modal, so it will never show up.

To fix it, simply add the following CSS :

/*
FIX ui-bootstrap modals + bootstrap 3
*/ .modal.ui-bootstrap-modal {   display: block; }
And open the modals this way :
$scope.openTheModal = function () {
$modal.open({
templateUrl: 'myModalTemplate.html',
scope: $scope,
windowClass: 'ui-bootstrap-modal'
});
};
Here we add a different class from the regular 'modal' class. Reason is : in my app I had both plain Bootstrap3 modals and angular-UI modals. Simply adding display: block property on 'modal' class was breaking regular Bootstrap 3 modals.

Hope this help.

December 30, 2013

Grunt uglify task breaks angular app

Here is the error in the browser console :

  1. Error: [$injector:unpr] Unknown provider: aProvider <- a http://errors.angularjs.org/1.2.7-build.2026+sha.7d6e5a2/$injector/unpr?p0=aProvider%20%3C-%20a at http://localhost:9000/vendor/bower_components/angular/angular.js:78:12 at http://localhost:9000/vendor/bower_components/angular/angular.js:3538:19 at Object.getService [as get] (http://localhost:9000/vendor/bower_components/angular/angular.js:3665:39) at http://localhost:9000/vendor/bower_components/angular/angular.js:3543:45 at getService (http://localhost:9000/vendor/bower_components/angular/angular.js:3665:39) at invoke (http://localhost:9000/vendor/bower_components/angular/angular.js:3687:13) at Object.instantiate (http://localhost:9000/vendor/bower_components/angular/angular.js:3708:23) at http://localhost:9000/vendor/bower_components/angular/angular.js:6758:28 at link (http://localhost:9000/vendor/bower_components/angular-route/angular-route.js:897:26) at nodeLinkFn (http://localhost:9000/vendor/bower_components/angular/angular.js:6212:13) <div ng-view="" class="ng-scope"> angular.js:9384


What happened is that Grunt uglify task included angular files (angular-route.js in this case).
Minification included in uglify task broke the file by minufying some string that mustn't be minified.

Three solutions :
  • Make the grunt task do not include unwanted files, and include those files already minified in your app.
  • If problem still occurs after first solution, your angular modules are not "uglify friendly". There's a special way to declare your dependencies so that minifying goes smooth, as described on this page ("a note on minification" paragraph) for example. Please note that instead of doing this declaration "by hand", you can use the "ng-min" task that automatize the process and keep your code clean.
  • Well, in my case I still had issue, so I ended turning off the "mangle" option in uglify (that very option that make long strings into smaller to compress response size). You can turn off the option like this :
 uglify: {

            options: {
                mangle: false
            },

Hope this help.

August 28, 2013

Getting MysQL utilities to work in MySQL Workbench 6.0 on Ubuntu 12.04 LTS


I installed MySQl Workbench 6.0 (downloaded from thier website) on my Ubuntu 12.04 LTS.
Installation ran smoothly.

However when I tried to start the shell for MySQL Utilities, I had an error saying that MySQL utilities weren't installed, and that I had to download and install them.

So I did. But when trying to install the .deb package for my arch, boom :

The MySQL Connector/Python module was not found

I found this module that looked like the right one (disclaimer : I'm a total noob regarding linux)

sudo apt-get install python-mysql.connector

Installation OK, but still MySQL can't find the connector.

What worked in the end : download and compile sources :

cd /usr/share

sudo wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.12.zip

sudo unzip mysql-connector-python-1.0.12.zip

cd mysql-connector-python-1.0.12/

sudo python setup.py install


Then I was able to launch the shell utilities.

Hope this help.

August 14, 2013

Eclipse shortcuts

There's already tons of posts dealing with this, but I don't care and I'll share my favourite eclipse shortcuts anyway :

Ctrls ^^
Ctrl + Space => completion
Ctrl + T => show implementations for an interface method
Ctrl + Shift + O (the letter)=>organise imports
Ctrl + Alt + H => lookup call hierarchy for this method or attribute
Alt + Shift + X, then J => Run a java class containing a main method
Alt + Shift + X, then T => Run junit tests in current class
Alt + up or down arrow => move a line up or down
Alt + left or right arrow => go to last edited location
Ctrl + Alt + up or down arrow => duplicate current line and copy it above or below
Ctrl + page up or page down => move from one tab to another. Really useful, except when you hit the bloody xml editor in your tabs...
Ctrl + L => goto line number ....
Ctrl + Shift + L => pops up the shortcut list
Alt + Enter => Access file properties. Useful to check file encoding, or check version control file URL
Ctrl + Shift + R => Open File
Ctrl + Shift + T => Open Type. Useful to find a class in a jar for example
Ctrl + W => Close file
F12 => Go to editor view
Ctrl + M => maximize/minimize current editor
Ctrl + 1 => show quickfix. has the same effect as hovering over an error with the mouse
Ctrl + E => display list of opened editors
Ctrl + Shift + F => Format code
Ctrl + I => Indent code
F3 => open d├ęclaration
F4 => open hierarchy
Alt + Shift + R => rename field
Alt + Shift + T => show refactor menu

I usually also create a binding for the "generate getters and setters" action.

Please feel free to propose new ones if you feel like I've forgotten important ones.

July 18, 2013

PowerMock and SSL Context : NoSuchAlgorithmException

I was  trying to unit test a method that's sending an HTTP message to a potentially secured URI. Therefore, somewhere in the process the javax SSL Context interface is used.

I obvisouly want to mock that call, because I'm testing the method and not the call itself. When ryunning the test, I get the exception below :

com....TechnicalException: java.security.NoSuchAlgorithmException: class configured for SSLContext: com.sun.net.ssl.internal.ssl.SSLContextImpl not a SSLContext

...

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:69)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:312)

at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:89)

at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:296)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl$PowerMockJUnit49MethodRunner.executeTestInSuper(PowerMockJUnit49RunnerDelegateImpl.java:117)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl$PowerMockJUnit49MethodRunner.executeTest(PowerMockJUnit49RunnerDelegateImpl.java:77)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:285)

at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:91)

at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:210)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:148)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:123)

at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)

at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)

at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:125)

at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:102)

at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)

at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:684)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:391)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: java.security.NoSuchAlgorithmException: class configured for SSLContext: com.sun.net.ssl.internal.ssl.SSLContextImpl not a SSLContext

at sun.security.jca.GetInstance.checkSuperClass(GetInstance.java:242)

at sun.security.jca.GetInstance.getInstance(GetInstance.java:221)

at sun.security.jca.GetInstance.getInstance(GetInstance.java:147)

... 31 more




This is related to the SSLCOntext loading stuff from the upstream classloader - which is Power Mock's one when running the test.

Solution : use @PowerMockIgnore annotation on the top of your test class :

@PowerMockIgnore("javax.net.ssl.*")

public class MessageProcessorTest { ... }


Found the solution thanks to this thread and that issue.

HTH

Mathieu.

June 02, 2013

ATI Radeon 2600 drivers on Ubuntu 12.04.02 with 3.5.0-32 kernel

I just spent a few hour trying to install proprietary drivers on my (old) laptop for my (old) graphic card.
If the following configuration talks to you, then I might help you :-)

- Ubuntu 12.04.02
- Kernel version 3.5.0-32-generic
- ATI Radeon 2600 graphic card

Since the last kernel update, unable to install Catalyst 13.1 drivers. dpkg creation is successful, but when trying to install those dpkg I am getting a bad exception when fglrx is installing.

Error! Bad return status for module build on kernel: 3.5.

DKMS part of installation failed. Please refer to /usr/share/ati/fglrx-install.log for details

Same result with the graphic installer of course.

After a while I found some 13.4 Catalyst drivers. Installation goes smoothier, but in the end...

aticonfig: No supported adapters detected 

Arrrgh ! They dropped support for 2600 series in this version !

Only solution that worked for me :
https://launchpad.net/~makson96/+archive/fglrx

Hope this help !