rokoder

csv to sqlite conversion [csv2sqlite sqliteloader]

by on Jul.01, 2015, under Programming

During one of my personal projects, I had to use ‘.import’ command of the sqlite3 shell. The .import command is very limited in functionality. It also always binds column data as text. This has performance hit as well as disk usage hit. I also need some very basic conversion support like store numbers as numbers in db files as well as some way to parse date related data.

All these needs leads for the development of sqliteloader which csv files to sqlite easy.

Leave a Comment :, , , , more...

10 Open Source Rights

by on Dec.26, 2012, under Programming

Right No. 1: Free Redistribution
Right No. 2: Source Code Available
Right No. 3: Derived Works Permitted
Right No. 4: Integrity of the Author’s Source Code
Right No. 5: No Discrimination Against Persons or Groups
Right No. 6: No Discrimination Against Fields of Endeavor
Right No. 7: Distribution of License
Right No. 8: License Must Not be Specific to a Product
Right No. 9: License Must Not Contaminate Other Software
Right No. 10: License Must Be Technology-Neutral

Source: http://opensource.org/osd-annotated

Leave a Comment : more...

C++ Templates, not so generic

by on Mar.19, 2012, under Programming

Lets start with basic ideology of .h and .cpp files. When building libraries, the idea is to share only your header files and not your implementation (mean .cpp files). This is also the basics OOP’s encapsulation, abstraction etc, to hide the implementation details.

Now templates in C++ violates this encapsulation principle, bcoz C++ is a compiled language. And compiler generates all the needed (generic) code during compilation (it is different from Java as in Java this code can be generated in Java Run Time during execution and not at compilation. As Java compiled .class files contains enough info to generate a specific implementation later). Now to adhere to OOP we end up with fragile templates which are not 100% generic in nature.

Now there are two ways to implement templates.
(continue reading…)

Leave a Comment :, , , , more...

Finding version of Ubuntu via command line

by on Feb.26, 2012, under System

> lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 11.10
Release:	11.10
Codename:	oneiric
Leave a Comment :, , , , more...

Git with vimdiff

by on Feb.18, 2012, under System

Some people are really a big fan of ‘vim’ and so they also use ‘vimdiff’ over the default ‘diff’ utility. ‘vimdiff’ shows you a side by side diff which is very easy to read (shown in the image below).

vimdiff in action

vimdiff in action

Now if you are using ‘git’ and you run ‘git diff’ you will get a diff which is not very human readable. Thats where ‘vimdiff’ comes.

> git diff
diff --git a/todo-java-app/pom.xml b/todo-java-app/pom.xml
index 96aebba..6b9af3f 100644
--- a/todo-java-app/pom.xml
+++ b/todo-java-app/pom.xml
@@ -1,5 +1,6 @@

+testing
     4.0.0
     com.rokoder
     todo-java-app
@@ -48,4 +49,4 @@
             5.1.18

-
\ No newline at end of file
+
>
>

‘git’ supports ‘vimdiff’ as a diff tool. Run the below command to change the diff tool to ‘vimdiff’.
(continue reading…)

Leave a Comment :, , , , , , more...

Get N matches using grep

by on Feb.11, 2012, under Programming

Here is the test data that we gonna use:

>grep create *.log
1.log:create1
1.log:create2
10.log:create1
10.log:create2
2.log:create1
2.log:create2
3.log:create1
3.log:create2
4.log:create1
4.log:create2
5.log:create1
5.log:create2
6.log:create1
6.log:create2
7.log:create1
7.log:create2
8.log:create1
8.log:create2
9.log:create1
9.log:create2
>

Finding the First N matches
(continue reading…)

Leave a Comment :, , more...

Android missing MENU button

by on Jan.13, 2012, under Programming

Well since ICS, h/w MENU button is having a life of uncertainty on a phone. It may or may not be present. I learnt that the hard way, so thought of sharing this with everyone who is in the same boat. And some times (which sometimes becomes often) Android sdk docs are not very thorough (but yeah they are on the right track and doing better now). Here we ll consider two scenarios:

Scenario 1: App does not use standard title bar but have menu options
(continue reading…)

Leave a Comment :, more...

Hello World! to Path on Windows

by on Jan.02, 2012, under System

Well working with open source projects on Windows can be painful sometimes. I had faced this issue when I was working Tomcat, JBoss etc. on Windows.

The issue we are talking about is `space` in file names. Lest take one example, JBoss like apps won’t work fine if your Java is installed in `Program Files`. Which generally is the case as the setup you get from Oracle installs it there. People use quick hack to copy the Java folder from there to root dirs, so that there is no `space` in the file path.

Well there is another way to get the short name for a path in Windows. This is neat owes its roots to old 8 char long file names on old machines. Sometimes old legacy saves you in the new world….:)

dir /X

D:\>dir /X
 Volume in drive D is PROG_FILES
 Volume Serial Number is XXXX-XXXX

 Directory of D:\

03/11/2010  09:23 PM    <DIR>                       audio
09/29/2011  10:15 PM    <DIR>          GAMEFI~1     Game Files
03/11/2010  09:30 PM    <DIR>          INTELG~1     intelgraphics
12/17/2011  03:18 PM    <DIR>          PROGRA~1     Program Files
05/20/2011  07:08 PM    <DIR>                       tmp
               0 File(s)              0 bytes
               5 Dir(s)  29,142,163,456 bytes free

D:\>

You can see that `Program Files` have a short name displayed next to it. Now we can use the short name in our environment variables/settings and have our Java installed in `Program Files`. This gives us a benefit as we are going to upgrade Java we don’t have to move it again to the root folder as we would have done if used the traditional approach to get rid of `space`.

Leave a Comment :, , , , more...

Faster way to extract file name

by on Dec.29, 2011, under Programming

Working with unix shell and no way you wont end up extracting file names from paths. Well there is a usual way to do it.

>basename /my/big/long/path/to/a/little/bitty/file
file

Here is another way:

(continue reading…)

1 Comment :, , , , , , more...

Java to C++

by on Dec.29, 2011, under Programming

Many times people from Java endup writing C++ code and vice versa (for vice versa check notes below). This is the beauty of working in such a dynamic/vast programming eco-system. This blog is to help them create an analogy between the two.

Below we have a sample Java code which we like to convert to C++.

interface MyInterface {
  void func1();
  int func2(int x, int y);
}

interface MyAnotherInterface {
  void func3();
  int func4(int x, int y);
}

abstract class MyAbstract implements MyInterface {
  void func1() {
    System.out.print("In func1");
  }
}

class MyConcreteClass extends MyAbstract
  implements MyAnotherInterface {
  int func2(int x, int y) {
    System.out.print("func2 x=" + x + ",y=" + y);
  }

  void func3() {
    System.out.print("in func3");
  }

  int func4(int x, int y) {
    System.out.print("func4  x=" + x + ",y=" + y);
  }
}

(continue reading…)

Leave a Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...

Archives

All entries, chronologically...