Thursday, September 24, 2015

Cordova / Ionic - Multiple Dex Issue with "Facebook Connect" and "LocalNotification" plugins.

Had a problem with Cordova / Ionic today:

com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)

After some hours of reading and testing found solution that worked for me in following configuration:

com.phonegap.plugins.facebookconnect 0.11.0 "Facebook Connect"
de.appplant.cordova.plugin.local-notification 0.8.2-dev "LocalNotification"

Fix was quite simple (after a couple of hours :) :

plugins/com.phonegap.plugins.facebookconnect/plugin.xml:

-   <framework custom="true" src="platforms/android/FacebookLib">
+   <framework src="com.android.support:support-v4:+">
+   <framework src="com.facebook.android:facebook-android-sdk:3.23.0">

plugins/de.appplant.cordova.plugin.local-notification/plugin.xml:

-   <dependency id="cordova-plugin-android-support-v4">
+   <framework src="com.android.support:support-v4:+">


PS: de.appplant.cordova.plugin.local-notification will install cordova-plugin-android-support-v4 - you can remove it after this with ionic plugin remove cordova-plugin-android-support-v4

Friday, September 26, 2014

backbone.js + underscore.js + ??? = good localization

Starting a localization process for one of projects. Currently looking for localization of backbone and underscore parts. i18n plugin from require.js seems to do almost all that I need, but... there is a strange feeling that everything is too simple... Looking around on the web found some frameworks, projects but they don't offer anything that I can not get with a plain and simple require.js i18n... Strange... Someone passed through same feeling before? What was the result? :)

Thursday, September 25, 2014

npm + grunt + bower + grunt-bower-task

Maybe this will help someone... In any case - I'm keeping this KB mostly for myself :)

Since I prefer following structure for my node.js (and backbone / underscore) projects:

project/
  public/
   js/
     lib/ - here will go all libs/frameworks
     app/ - here will go all JS application files
   ...
   css/
   fonts/
   tpl/

1) Sample package.json:

{
  "name": "test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "3.*",
    "bower": "*"
  },
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-bower-task": "^0.4.0"
  }
}


2) Sample Gruntfile.js:

module.exports = function(grunt) {
  var path = require('path');

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    bower: {
      install: {
        options: {
          targetDir: './public',
          layout: function(type, component, source) {
            var renamedType = type;
            if (type == 'js') renamedType = 'js/lib';
            else if (type == 'js/map') renamedType = 'js/lib';
            else if (type == 'js/lang') renamedType = 'js/lib/lang';
            else if (type == 'css') renamedType = 'css';
            else if (type == 'css/img') renamedType = 'css';
            return path.join(renamedType);;
          },
          install: true,
          verbose: false,
          cleanTargetDir: false,
          cleanBowerDir: false,
          bowerOptions: {}
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-bower-task');

  // Default task(s).
  grunt.registerTask('default', ['bower']);
};

3) Sample bower.json

{
  "name": "test",
  "version": "0.0.0",
  "moduleType": [
    "amd"
  ],
  "authors": [
    "Viktor Yarmak "
  ],
  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "requirejs": "*",
    "jquery": "1.*",
    "backbone": "*",
    "underscore": "*",
    "bootstrap": "*",
    "font-awesome": "*",
    "backbone-validation": "*",
    "backbone.paginator": "*",
    "fuelux": "*",
    "moment": "*",
    "chosen": "https://github.com/harvesthq/chosen/releases/download/v1.1.0/chosen_v1.1.0.zip"
  },
  "exportsOverride": {
    "requirejs": {
      "js": "require.js"
    },
    "jquery": {
      "js": "dist/jquery*.js",
      "js/map": "dist/jquery*.map"
    },
    "jquery-1.*": {},
    "backbone": {
      "js": "backbone.js"
    },
    "underscore": {
      "js": "underscore*.js",
      "js/map": "underscore*.map"
    },
    "bootstrap": {
      "js": "dist/js/bootstrap*.js",
      "js/map": "dist/js/bootstrap*.map",
      "fonts": "dist/fonts/*",
      "css": "dist/css/*"
    },
    "font-awesome": {
      "css": "css/*",
      "fonts": "fonts/*"
    },
    "backbone-validation": {
      "js": "dist/*.js"
    },
    "backbone.paginator": {
      "js": "lib/*.js"
    },
    "fuelux": {
      "js": "dist/js/*.js",
      "fonts": "dist/fonts/*",
      "css": "dist/css/*"
    },
    "chosen": {
      "js": "chosen.jquery*.js",
      "css/img": "chose*.png",
      "css": "chosen*.css"
    },
    "moment": {
      "js": "moment.js",
      "js": "min/*.js",
      "js/lang": "lang/*.js"
    }
  }
}

After this you can run:

npm update
grunt

Wednesday, November 27, 2013

MySQL privileges update for creating procedures, functions, etc.

After creating a new user you need to update his privileges to grant creation of procedures, functions and so on. Here is a SQL for this.

UPDATE user SET 
Select_priv="Y", Insert_priv="Y", Update_priv="Y", Delete_priv="Y", Create_priv="Y", Drop_priv="Y", Reload_priv="Y", Process_priv="Y", File_priv="Y", References_priv="Y", Index_priv="Y", Alter_priv="Y", Super_priv="Y", Create_tmp_table_priv="Y", Lock_tables_priv="Y", Execute_priv="Y", Create_view_priv="Y", Show_view_priv="Y", Create_routine_priv="Y", Alter_routine_priv="Y", Event_priv="Y", Trigger_priv="Y"
WHERE user = "xxxxx";
FLUSH PRIVILEGES;


Monday, March 25, 2013

jQuery executes error function even on success (200) status

Just lost a couple of hours with this problems.

jQuery was executing an error function regardless the jqXHR status. A little bit about setup:
node.js + Express + Backbone + backbone.paginator + Underscore

After upgrading to Express 3.0 an application that was working without any problems stoped to work. Problem - jQuery was always executing an error function for all ajax requests. After checking the code, googling, reading, debugging, taking a lunch, debugging again and again I saw that I was using res.json() and not res.jsonp() (added in Express 3.x). Change of one line and everything is working back again.

So - if your node.js + express 3.x returns jsonp, please, use res.jsonp() instead of res.json()

Saturday, December 1, 2012

MySQL PASSWORD() function in JavaScript


If you need to implement a MySQL PASSWORD() function in JavaScript - use http://code.google.com/p/crypto-js/#SHA-1 with 2 encodings.

Here is an example:

var password = "TestPassword";
var result = ("*"+CryptoJS.SHA1(CryptoJS.SHA1(password))).toUpperCase();
console.log("result : " + result);

Result will be *0F437A73F4E4014091B7360F60CF81271FB73180. If you check it with MySQL password() it will be the same:

mysql> select password("TestPassword") as result;
+-------------------------------------------+
| result                                    |
+-------------------------------------------+
| *0F437A73F4E4014091B7360F60CF81271FB73180 |
+-------------------------------------------+

Monday, June 11, 2012

Show hidden files on Mac

To show hidden files and folders in Finder - open terminal window and paste the following line:

defaults write com.apple.Finder AppleShowAllFiles YES


Then relaunch Finder application (Option + right button click on dock icon, then select relaunch).
To disable showing of hidden files - do the same procedure with other string:

defaults write com.apple.Finder AppleShowAllFiles NO

Monday, December 19, 2011

Find directory with biggest number of files / directories

Today we had a problem related with a number of files in a directory. We needed to find directories with a biggest number of files / directories in it. Here is a small shell script that will list directories and a number of files/directories in each directory.

find . -type d|awk {'print "echo -n "$1".\"\t\"; ls "$1"|wc -l"'} > /tmp/do; . /tmp/do|sort -k 2 -n -r |more

Explaining it a little bit:

"find . -type d" - find all directories bellow current directory
"awk {'print "echo -n "$1".\"\t\"; ls "$1"|wc -l"'} > /tmp/do" - generate a script that will print a directory name (echo -n), make ls in this directory and count a number of lines from ls (wc -l)
". /tmp/do" - execute generated script
"sort -k 2 -n -r" - sort the result using second column (-k 2) as numerical (-n) and in reverse order (-r)

Monday, February 22, 2010

iPhone takes too long to sync

After changing a notebook I got a following problem. My iPhone was taking an eternity to sync with iTunes. I made a restore - no solution. I made a restore as new iPhone - same problem. After googling a little bit I found that this can be related with "Sync Photos" option. At the moment that I disabled "sync photos" - my iPhone was synced in a couple of minutes.

Problem: iPhone is taking too much time to sync on Windows 7.
Possible solution: Try to disable "Sync Photos" option.

Sunday, November 8, 2009

VMware crashes after updating (upgrading) of host OS (to CentOS 5.4)

If you have in your hostd.log something like this:

Nov 07 21:19:12.648: Worker#23| Caught signal 6 -- tid 31543

this can be related with update(upgrade) of host OS.

After upgrading of a host OS (CentOS 5.3->CentOS 5.4) I got an issue - a guest OS started to crash. Searching around for a possible cause I found bug post in CentOS bug tracker. Seems that issue is related to glibc update (last version is glibc-2.5-42) and a fix is to downgrade to previous version on host OS (glibc-2.5-34).

To be sure that your downgrade of glibc worked - check the size of libc-2.5.so. I got an issue on downgrade (even with --oldpackage rpm was not willing to replace a libc), and that's why I lost some hours trying to figure out what is going on. So, be sure to check the size of the files after downgrade. It can save you some hours :)

Tuesday, August 4, 2009

Twitter tip

RT @ryancarson: Top tip: You can put a "+" on the end of any http://bit.ly link and see, real time, the pace at which that link is getting shared and clicked

Tuesday, July 7, 2009

VMware troubles

Well, I'm not a hardware guru, but from my experience I figured out the following:


Dell Servers + QLogic HBA + IBM Storage = troubles
Dell Servers + Emulex HBA + IBM Storage = working ok
Dell Servers + QLogic HBA + EMC Storage = working ok

Other one issue is:

Any server + Any HBA + Any storage - Fiber Channel Switch = troubles (unclean filesystem on Linux guests with EXT3 filesystem)

Monday, May 25, 2009

"Network Connection Closed Unexpectedly" error while using svn+ssh

If you got a "Network Connection Closed Unexpectedly" error while using svn+ssh (here is a nice HOWTO) then you should comment (or remove) "mesg y" in /etc/bashrc or in $HOME/.bashrc


Worked for me as a charm :)

Monday, February 16, 2009

iPhone speaker too low

Well, I got a simple accident - "Mozart Chocolate Liqueur" were split over my iPhone 3G. I quickly clean it out, but... Next day I noticed that my iPhone speaker was too low. I was not able to hear it ringing. After looking around for solution I found a post telling that this can be caused by dust. Seems that this is my case (ok, not dust, but a creamy liqueur...). 

So, I put some music on my iPhone and start carefully cleaning the microphone hole with a needle. After just a few holes I made on the "dust" - I was able to hear that volume had increased. So I finished up cleaning by putting a needle just a little into every tiny hole of the speaker protection and everything worked like a charm. My speaker volume came back to the normal level (or even louder).

Just in case that you have a doubt on which one is speaker and which one is microphone on your iPhone - here is a picture:

Wednesday, December 3, 2008

How to sync Google Contacts and Calendar with iPhone

I've been looking for some simple solution to sync Google Contacts & Calendar with my iPhone on the air (without syncing with my notebook). Finally I found a solution that seems to be working like a charm.



Setup process is quite simple and straigh forward. 

Friday, August 22, 2008

cfmenu and cfgrid overlap

If you are using <cfmenu> and <cfgrid> and you have an overlapping of the menu items by cfgrid header (a part of menu is hidden behind cfgrid header) you must add to your CSS a following style:


#myMenuId .yuimenu {
z-index: 300003;
}

This problem is caused by some "yui" CSS style with z-index set to 1, while grid related styles have z-index bigger than 200000.

Friday, July 25, 2008

ESX host not connecting to Virtual Center

We got following problem some days ago:

One of our ESX (version 3.5) hosts, after crash, was not connecting to Virtual Center (version 2.5).

Solution:
  • Restart management service on ESX host
service mgmt-vmware stop
service mgmt-vmware start
  • Restart Virtual Center service on Virtual Center server (stop/start on service VMware Virtual Center in Services)

One more stuff - if you have a lot of memory on your hosts (16 GB or more) I would recommend you to increment amount of console memory on your host to 800 MB. You can do this in "Configuration" tab for host in your Virtual Center console.

Wednesday, June 25, 2008

Creating a copy of the disk (vmdk) in VMware

When you need to have the a copy of the disk from one VM on the other:

  • Power off  source VM, copy your .vmdk files to destination VM (probably you would like to change disk name and flat name - just rename your files and edit smaller .vmdk file to set correct name for flat file).
  • Set new UUID for your copy of your original .vmdk file
/usr/sbin/vmkfstools -J setuuid path_to_destination_VM/filename.vmdk
  • Add new disk to your destination VM (using "Use an existing virtual disk" option)
  • Start your VMs (source and destination)
  • Mount new drive on your destination machine
We used this solution to make a quick copy of data files disks from primary Oracle server to standby Oracle server.

Monday, June 16, 2008

Oracle analog of MySQL GROUP_CONCAT function

I was looking for Oracle analog of MySQL GROUP_CONCAT function. There is a solution on Ask Tom site. So here it is:


create or replace type string_agg_type as object (
  total varchar2(4000),

  static function ODCIAggregateInitialize(sctx IN OUT string_agg_type )
  return number,

  member function ODCIAggregateIterate(self IN OUT string_agg_type, value IN varchar2 )
  return number,

  member function ODCIAggregateTerminate(self IN string_agg_type, returnValue OUT varchar2, flags IN number)
  return number,

  member function ODCIAggregateMerge(self IN OUT string_agg_type, ctx2 IN string_agg_type)
  return number
);
/

create or replace type body string_agg_type is
  static function ODCIAggregateInitialize(sctx IN OUT string_agg_type)
  return number
  is
  begin
    sctx := string_agg_type( null );
    return ODCIConst.Success;
  end;

  member function ODCIAggregateIterate(self IN OUT string_agg_type, value IN varchar2 )
  return number
  is
  begin
    self.total := self.total || ',' || value;
    return ODCIConst.Success;
  end;

  member function ODCIAggregateTerminate(self IN string_agg_type, returnValue OUT varchar2, flags IN number)
  return number
  is
  begin
    returnValue := ltrim(self.total,',');
    return ODCIConst.Success;
  end;

  member function ODCIAggregateMerge(self IN OUT string_agg_type, ctx2 IN string_agg_type)
  return number
  is
  begin
    self.total := self.total || ctx2.total;
    return ODCIConst.Success;
  end;
end;
/

create or replace function stragg(input varchar2)
return varchar2
parallel_enable aggregate using string_agg_type;
/

After this you can use this function like this:
select t1.id, stragg(t2.name) as names from table1 t1, table2 t2 where t1.id=t2.id group by t1.id;

It will produce comma separated list of the names - something like this:
ID NAMES
-- ------------------------------------
10 CLARK,KING,MILLER
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD

Tuesday, May 13, 2008

List number of file handles (open files) for each process

Here is a simple script that will show you a number of file handles (open files) used by each process on your Linux system:


ps -e|grep -v TTY|awk {'print "echo -n \"Process: "$4"\tPID: "$1"\tNumber of FH: \"; lsof -p "$1"|wc -l"'} > out; . ./out