Wednesday, February 11, 2015

Today I listened a really nice clean-code google talk about bad practice of using IFs, and how much polymorphism helps out there. It is amazing to see how nicer code becomes, and how easy it is for a programmers to go into routine of making if/switch statements for no reason. All methods mentioned there are not new at all, but having it here shown reminds you on what and how should you think when programming.

Tuesday, December 23, 2014

CodeAnywhere, (thumbsup)!

I started some mini javascript project of my own, so needed to create a relatively simplistic development environment.
However, this environment has some constrains:
- it should not require install (portable to many different devices),
- it should connect to my Dropbox account.

For that purpose, I came across CodeAnywhere website, where you can for free set up your account and connect your dropbox account and immediately start working. However, the internal browser that they have is running through their proxy, which causes a number of issues for my javascript development, so I am not using it.

Friday, December 19, 2014

What makes SAS Enterprise Guide not a mature application ...

Ok, before I start expressing my opinion about SAS Enterprise Guide and SAS Base Programming, I would like to make a quick introduction of my technical experience and expertise.

Throughout 7-8 years of my professional life, I have been using in great extent software tools like MATLAB, and have been programming enterprise applications in Java/Spring. In last 6 months I am introducing myself to SAS World.

Version I am working on is SAS Enterprise Guide 9.4. For a system that still uses programming model (SAS Base) of 80s, a graphical interface which visually shows how the process is being executed is a great refreshment. There are many options on dealing with data and doing analysis on it, making it very comfortable tool to easily build a large data manipulation process.


Basic Application use issues:



  • "Object reference not set to an instance of an object".
    • It relatively often happens (every 4 days of 8h daily use of SAS Enterprise Guide) that the file you think you saved ends up to be corrupted. You open the saved file, and during the load above quoted message comes up, which makes you not being able to see the project tree, rendering this project file completely useless. You might have some chance, if the project is not too big, to refresh the project tree, and that it actually brings you back the project tree, but bigger the project gets (more process flows you create), less chance you have of any recovery. This errors would be completely fine, if a error message would be shown if something during saving process gets wrong, but there is no such message, leaving you only to wonder if you really have saved your project properly or not.
  • the first created Query Builder node on a newly created process flow suddenly jumps into some other process flow.
    • This annoying issue is happening usually when you want to address a table you used in some other process flow. Even though you have the new process flow currently open, and that you when to Tasks->Data-> Query Builder, if you chose a table referenced in some other process flow, it will (automatically) jump into that process flow. If you have referenced multiple tables referenced also in different process flows, the destination of the "jump" is at random. The worst part of it all, it does not get selected and automatically shown once it jumps, so if you dont know about the "jumping" behavior, you will think something went wrong, and will start building a new one again. It happened to me couple of times, even if I knew this issue, to be distracted and build the same node again. Couple of hours later, you just realize you have some junk created in the process flow you haven't even worked on...
  • Deleting nodes sometimes ends up in deleting the whole process flow. 
    • It does happen very seldom, but often you want to delete one step in between of the flow you created, it deletes not just all nodes that are directly dependent on its result, but also every node on the process flow.
  • Waiting for Godot
    • when you run a number of tasks, queued one after another, it does happen that the Queue Controller does not receive the "finish" signal from previous task, and simply does not start the next task. However, the finished task is being even cleared from a Task Status list, so the first in queue task waits literary for no task...
  • Edit-> Undo feature is only for text... no graphical nodes...
    • it does happen when you work long or get distracted, to accidentally delete a wrong graphical node. YES, YOU CAN'T BRING IT BACK. IT IS GONE. unless you have similar tick like me and save project every couple of minutes, so the process of "closing without saving and opening again" successfully replaces undo option.

General issues (or simply, why it is not there?)


  • A proper versioning system? Apache Subversion has been created in year 2000. 14 years exists a well functioning versioning system. Why SAS Enterprise Guide does not have that feature? By versioning system means working in parallel on a same project, with a possibility without any conflicts to work on different process flows. 
    • I read about SCM in SAS post, but this approach enforces you to use ONLY SAS Base code in your SAS Enterprise Project, because all the graphical implementation (main feature of SAS EG) is saved in .egp file. Now this is the funny part... the whole project is written in one XML file and in bunch of folders which contain log files, and all that zipped and renamed as egp file... option to do a versioning of that XML file would already be a big step further! Why it isn't done then?
  • SAS Base Code <-> SAS Enterprise Code? 
    • One is able to extract the code of SAS Enterprise Code, but there is no chance that the same exported code gets imported into a fully structured SAS project
  • Testing in SAS? 
    • Is there any testing method supported by SAS? Unit testing?
  • Design Patterns? 
    • I have read a paper (this one) which describes multiple design patterns using a sas macro language. As a initial C developer, my experience with macros is that having a dumb text-placing/no-thinking is extremely dangerous style of coding.
    • One can say
  • Is a "TRICK the SAS Base Language" a main solution to every upcoming problem?
    • Throughout development, often I had to google for some info how to do what in SAS, and it often turn to be the "trick" the final solution, which is actually some awful side-effect of existing SAS feature that then makes you do the job you need. For Example, creating a folder through SAS (let's say you want your reports to be placed in a folder tree defined by the business specification. Through a solution on this site it means, you have to make a meaningless librefs with specific option to create such a folder structure?). Now it makes me wonder... does it mean becoming a senior SAS developer means how many hacks you know???

Monday, December 15, 2014

Small C code to convert german text to old ASCII-DE encoding


I had a task to convert a UTF-8 or ISO-8859-2 encoding german text (names, addresses,...) into a 7bit ISO-646-DE (ASCII-DE) encoding. Since this encoding almost is non-existent, it was a bit difficult to find on Google search any example of such a conversion. I decided to be that sucker to write it :) I know this is not really the best code ever, but does its job. To see it in action, you can check it here (in case you see in a code pane [object Object], just refresh the page, and it will show the code) :)
#include 
#include 
#include 
#define NUM_OF_CONV_TABLE 8

/*
compile it with: 
gcc -o convert convert.c
run it with:
convert input.txt output.txt && hexdump -ve '1/1 "%.2X"' output.txt

*/

int main ( int argc, char *argv[] )
{

 static unsigned char utfconv[NUM_OF_CONV_TABLE] = 
     {0x84, 0x96, 0x9C, 0xA4, 0xB6, 0xBC, 0x9F}; 
 static unsigned char conv[NUM_OF_CONV_TABLE] = 
     {0xC4, 0xD6, 0xDC, 0xE4, 0xF6, 0xFC, 0xDF}; 
     //Ä, Ö, Ü, ä, ö , ü, ß
 static unsigned char values[NUM_OF_CONV_TABLE] = 
     { 0x5B, 0x5C, 0x5D, 0x7B, 0x7C, 0x7D, 0x7E }; 


    if ( argc != 3 ) /* argc should be 2 for correct execution */
    {
        /* We print argv[0] assuming it is the program name */
        printf( "Text Encoding Convertor: From UTF-8/ISO-8859-2, to ISO-646-DE (ASCII-DE)");
        printf( "usage: , ");
    }
    else 
    {
        // We assume argv[1] is a filename to open
        FILE *fileIn = fopen( argv[1], "r" );
        FILE *fileOut = fopen( argv[2], "w");

        /* fopen returns 0, the NULL pointer, on failure */
        if ( fileIn == 0 || fileOut == 0)
        {
            printf( "Could not open file\n" );
        }
        else 
        {
            unsigned char x;
/*            unsigned char size;
            if (strcmp(covertToUpper(argv[3]),"UTF-8") != 0) {
                size=2;
            } else {
                size=1;
            }*/
            /* read one character at a time from file, stopping at EOF, which
               indicates the end of the file.  Note that the idiom of "assign
               to a variable, check the value" used below works because
               the assignment statement evaluates to the value assigned. */
            unsigned char isUTF=0;
            unsigned char wasC3=0;
            while  ( fread(&x,1,1,fileIn)==1 )
            {
                int i=0;
                int o=x;
             while (i Reached EOF
      If nrd <  0 --> Some kind of error */






        }
    }
}

Tuesday, December 9, 2014

Getting list of files from a folder in a text file

I keep always forgetting the exact parameters to use, and need to write this down somewhere :) It might also be helpful for others:
 In Windows:
WindowsUnix/Linux/OS X
dir /b >folderlist.txt
ls > folderlist.txt

and if you also want to see the subfolders with their full paths:
WindowsUnix/Linux/OS X
dir /b /s >folderlist.txt
ls -R > folderlist.txt

Tuesday, March 4, 2014

How to convert Integer into String with leading zeros in Java

This is pretty easy task, but I keep on forgetting it:
String.format("%05d", num);

Tuesday, February 18, 2014

Batch Resize Images in Mac OS

To resize all the images to maximum height of 640px
sips -Z 640 *.jpg
To resize all the images to maximum width of 400px
sips --resampleWidth 400 *.jpg

To resize SVG files in Mac OS, you can use the rsvg library install it with:
brew install -v librsvg
and then run it with the following shell line:
for i in *; do rsvg-convert $i -w 100 -h 100 -f svg -o `echo new/$i`; done
This takes all the svg files in the folder, resizes it and copies the result into new/ folder