Wednesday 15 November 2017

git Repo

A year before had chat with my Guru/ Friend / Senior/ TL Bala.
He said lot about GIT. would like to do experiments on it.
Now got a chance on it.

went for an interview, they asked to do crud operations and upload it in GitHub.
cannot able to do that on the same day, however, next day, started that process.

so this what i did, 

1. generate ssh key from eclipse.
2. add that ssh key in Github.
3. commit and publish the code.

seems easy right. Yah, it is easy in eclipse. Eclipse made the process simple. I will explain what is happening behind in the part 2.

and that repo https://github.com/hunkr11/intellect i shared with Balaji, my senior in saksoft.
Asked him to fork it.
to my knowledge, forking is like importing my repository in github to his repository, and can make changes in that repository. It won't affect mine.

then ask him to raise a pull request.
well, pull request is after forking and made some changes, then the forked person would like to add their changes to the main copy.
in this scenario, balaji made some changes, he raised a pull request, then i received that intimation. i reviewed balaji's code then merged it.



so, that experiment is successful.


Next, day i want to try the same for angular code using Visual studio Code.

likewise created the repo.
tried to commit the code, show the error unknown user.
after googling, found need to set the user name and email for github to commit

$ git config --global user.name hunkr11

$ git config --global user.name hunkr11@gmail.com
 then is error resolved.

then tried commiting again, the RSA error comes.
after googling understood the flow,

1. need to generated a ssh key(public key) for my github email id.

 ssh-keygen -t rsa -C "hunkr11@gmail.com

2. Add the generated ssh key to git

 ssh-add  (path)/(keyname)

3. add this key to Git as new SSH key

4. configure the user globally

 git config --global credential.helper wincred

that's it. now we can push our code to git using Visual Studio Code.

git remote add origin https://github.com/hunkr11/GIT.git
git push -u origin master

my angular repo: 
https://github.com/hunkr11/angular-shopping-cart

Tuesday 24 October 2017

tHanKs Mohan !!!

always got struck with a querys.. 
Mohan, SQL Geek always helps me in fixing it..

this page is dedicated to him..

Tuesday, 24 Oct 2017


1. didn't thought of adding multiple parameter as comma separated in query. he did it in seconds.
 SELECT WORKER_ID,WORKER_NM FROM SHIFT_DET WHERE (SHIFT_ID , ROLE_CD ) IN  (
SELECT SHIFT_ID , ROLE_CD FROM SHIFT_DET WHERE SHIFT_DET_ID = 7451 )  

Wednesday, 25 Oct 2017

2. Query Optimization
Asked sql geek to look into the same query little bit modified by me.

SELECT WORKER_ID,
       WORKER_NM,
       STEV_SHIFT_DET_ID,
       SHIFT_SRC_DET_ID,
       stev_shift_id
  FROM (SELECT WORKER_ID,
               WORKER_NM,
               STEV_SHIFT_DET_ID,
               SHIFT_SRC_DET_ID,
               stev_shift_id
          FROM JPSNS.SNS_STEV_SHIFT_DET
         WHERE     (STEV_SHIFT_ID, ROLE_CD) IN
                      (SELECT STEV_SHIFT_ID, ROLE_CD
                         FROM JPSNS.SNS_STEV_SHIFT_DET
                        WHERE STEV_SHIFT_DET_ID = 7203)
               AND STEV_SHIFT_DET_ID <> 7203) A
 WHERE STEV_SHIFT_DET_ID NOT IN (SELECT NVL (SHIFT_SRC_DET_ID, 0)
                                   FROM JPSNS.SNS_STEV_SHIFT_DET

                                  WHERE stev_shift_id = A.stev_shift_id)

he altered the query like this,

SELECT WORKER_ID,
               WORKER_NM,
               STEV_SHIFT_DET_ID,
               SHIFT_SRC_DET_ID,
               stev_shift_id
          FROM JPSNS.SNS_STEV_SHIFT_DET d
         WHERE     (STEV_SHIFT_ID, ROLE_CD) IN
                      (SELECT STEV_SHIFT_ID, ROLE_CD
                         FROM JPSNS.SNS_STEV_SHIFT_DET
                        WHERE STEV_SHIFT_DET_ID = 7203)
               AND STEV_SHIFT_DET_ID <> 7203
 and not exists (SELECT 'X' FROM JPSNS.SNS_STEV_SHIFT_DET d1
                                  WHERE stev_shift_id = d.stev_shift_id and
                                  d.STEV_SHIFT_DET_ID = d1.SHIFT_SRC_DET_ID

                                  );

also he looked into cost of both the queries using CTRL + E in toad.


and gave me pretty good suggestions, like 
TABLE ACCESS SHOULD NOT COME FULL for that need to set index for the shift id.
also said, using of NOT IN is elementary practice, better to use NOT EXIST.

Thursday 30 March 2017

Filter request url based on func code - 1111 Spring security

hope, from the title itself, you would have guess, yes URL restriction based on JAS  response. 


i'm not sure you guys can follow the above link easily, however, in my case, i can. i say you why, i have implemented a functionality of disabling a button in JSP page.


so, it looks like the continuation of that, thought will complete in some time. but it says, not so easy buddy. 😄

Case i)
earlier, i had the object in the session and i can get object as ${OBJECT} and give permission. 


<sec:accesscontrollist hasPermission="101001"   domainObject="${USER_FUNCTIONS}"> 
Now it is opposite, need to do the same implementation in JAVA used @PreAuthorize("hasPermission(OBJECT,'TEST123')"),  thought it would work. But it didn't.

got blocked in here..

current scenario, 
* having the object in the session, nee to get that object and make the @PreAuthorize to work. but, how i ll set the session object in the annotation.

i tried getting the session object gloabally using, 

HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.currentRequestAttributes()).getRequest();
HttpSession session = request.getSession();
List<String> functionList = (List<String>)session.getAttribute("OBJECT");

since in spring, the controller will compile in the run time itself, i got error. 

case ii)

since the case i) didn't worked, another !dea spared.
doing the restriction in the configuration itself, using

<intercept-url pattern="/test/edit/**" access="hasPermission(OBJECT,'TEST123')"/>

this also didn't worked.

Finding a way to fix it.

Finally, after a long waiting fixed it

https://stackoverflow.com/a/45354372/2573744

Friday 17 February 2017

i18N report xls

i18N report.. obviously the name say the meaning.. but the task is simple, the header in the report will be in english, but that should come from database.

* Initially thought of hitting db and taking a query and have 3 classes, 1 with list<reportvalue>, reportHeaderObject putting this object into another object say ReportObj. This !dea suggested by my Tech Lead, thanks. very good suggestion. while implementing another !dea hit in mind.

* Instead of creating new classes, set the value directly into the model, when we creating a variable. Think, you didn't got my point. let me clarify..

we have a cron/scheduler which will run every 15/30 mins, hit the database and update the properties file, that file we are using for i18N translation. My !dea is, instead of hitting to the db again, take the value directly from this properties file. googled..




ResourceBundle rb = ResourceBundle.getBundle("test.bundletest.mybundle");
String value = rb.getString(key);
with this, half of my task was over.. 

the second half is, how to set this object in the UI ?

saw the code, implemented by my colleague(obviously, on leave, enjoying weekend). Njoy Ramesh :D

PURE JAVASCRIPT (O _ O), however understandble.. 

changed in some places, get my object, set that as column header, BiNgOoo



Wednesday 8 February 2017

thanks BaLaJ!

Today, Unknowingly deleted a column values, by noon, a colleague send mail to all, not to delete any values, without his knowledge like that




issue, got serious.. 

luckily found a query in http://stackoverflow.com/questions/19853150/rollback-a-committed-transaction
and thinking of how to implement it..
Explained the scenario to Balaji, with in minutes he put the query. Thats why, we call him Geekbot :D

ill say what i understand..

i took this oracle query..

select * from table as of timestamp timestamp '2017-02-08 17:30:00' order by id

1. Balaji, looked at it..
2. He copied, all the data,
3. pasted it in excel
4. kept only necessary columns
5. in excel he wrote query
 =CONCATENATE("UPDATE table SET TYPE='",C1,"' WHERE ID=",A1,";")
6. he press enter, update query came for all the entries..

Done. Big issue resolved in minutes, Thanks Geekbot. :D



Monday 9 January 2017

Code Hints

// USING THIS LOGIC IN KEY UP TRIGGING A FUNCTION

ref : http://stackoverflow.com/questions/20281546/how-to-prevent-calling-of-en-event-handler-twice-on-fast-clicks

// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.

function debounce(func, wait, immediate) {
    var timeout;
    return function() {
        var context = this, args = arguments;
        var later = function() {
            timeout = null;
            if (!immediate) func.apply(context, args);
        };
        var callNow = immediate && !timeout;
        clearTimeout(timeout);
        timeout = setTimeout(later, wait);
        if (callNow) func.apply(context, args);
    };
};