Posts

html select multiple, how to preselect with anugularjs while using jstl

Image
There is a problem when you mix angularjs with JSTL. JSTL provides you complete HTML from the server side once whereas angularjs is good with ajax model and getting data in JSON format. There are ways to pre-set the ng-model with ng-init as shown below < label > Username </ label > < input id = "username" name = "username" type = "text" disabled = "disabled" ng-model = "user.username" ng-init = "user.username='Vaibhav'" required > The above code will create following visual. We can the same thing with HTML select tag (no multiple) like following with JSTL < label > Role* </ label > < select id = "role" ng-multiple = "false" name = "role" ng-init = "user.role='ADMIN...

Account HEAD failed: http://controller:8080/v1/AUTH_f5d59946d78a4085ac5c02003c3dcf03 401 Unauthorized

I was trying to deploy openstack swift, all went well but verification failed and suck a lot of time after trying many things. Here are some tips in case one faces similar problem.  Problem : Swift proxy is not authenticating user "demo"with keystone. Reason 1: Account, container, object rings run on separate ports on controller. Many a time during doing redundant job of copyin and pasting stuff, one may forget to change the ports. Reason 2: You need to restart the Apache server on which swift proxy runs. This apache server is same which exposes keystone authentication api's. Somehow new user is not identified by and you need to restart it on controller node. # service apache2 restart DEBUG:keystoneclient.auth.identity.v3.base:Making authentication request to http://controller:5000/v3/auth/tokens INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): controller DEBUG:requests.packages.urllib3.connectionpool:"POST /v3/auth/toke...

ORA-00979: not a GROUP BY expression when using join on subquery

This problem grappled me for hours where individual queries were just running good but when using them as table representation in a join I was getting notorious "ORA-00979: not a GROUP BY expression" After sometime I found that i need to use aggregate function in simple select too. Following are individual pieces of query. Query as Table 1: SELECT calcdate, count ( * ) as nodecount FROM ( SELECT TRUNC(lastoccurrence) AS calcdate FROM reporter_status WHERE lastoccurrence < trunc(sysdate) and lastoccurrence > trunc(sysdate) - 2 GROUP BY TRUNC(lastoccurrence),node ) GROUP BY calcdate Query as Table 2: SELECT calcdate, RTRIM (XMLAGG (XMLELEMENT (e, node || ',' )).EXTRACT ( '//text()' ), ',' ) nodes FROM ( SELECT calcdate1 as calcdate,node,RANK FROM ( SELECT TRUNC(lastoccurrence) AS calcdate1,node || ':' || COUNT ( * ) AS node, COUNT ( * ) as counts, RANK() OVER ( PARTITION BY TRUNC(lastoccurrence) OR...

group by weak of month in mssql

Let the data be in format CREATE TABLE contacts ( id INT, status VARCHAR( 100 ), created DATETIME DEFAULT NULL ); INSERT INTO contacts (id,status,created) VALUES ( 3 , '3' , '2015-05-12' ); INSERT INTO contacts (id,status,created) VALUES ( 4 , '4' , '2015-02-09' ); INSERT INTO contacts (id,status,created) VALUES ( 5 , '5' , '2011-07-12' ); INSERT INTO contacts (id,status,created) VALUES ( 6 , '5' , '2015-05-01' ); INSERT INTO contacts (id,status,created) VALUES ( 7 , '3' , '2011-06-12' ); INSERT INTO contacts (id,status,created) VALUES ( 8 , '2' , '2011-07-12' ); INSERT INTO contacts (id,status,created) VALUES ( 9 , '1' , '2011-05-12' ); INSERT INTO contacts (id,status,created) VALUES ( 10 , '1' , '2011-06-12' ); INSERT INTO contacts (id,status,created) VALUES ( 11 , '1' , '2011-05-12' ); INSERT...

A simple query to find missing data for date ranges in sql

Image
Sometimes we have seemingly simple problems like, "we store our daily data in a table, how can I figure out, what dates the data is missing for.". This problem statement looks rather simple, and obvious solution that one may think can be to loop through the records and find out the missing dates in a defined interval. But writing this logic in plain SQL is hard and one may try to find solace in some scripting language. Can there be some other elegant solution? Luckily there is an elegant trick, which is fast and only a few inches when you write: Consider following sequence of integers as dates. (Easy to visualize the solution with small digits than dates) 1 2 3 5 6 8 9 We can see that if this is a series, we have missed digits "4" and "7". Problem is how to determine this using a computer and not human brains. Lets increment, every digit by one as in the following series. 1 + 1 = 2 ...

oracle how to combine IN and LIKE clause together

There is no direct way to combine IN and LIKE clause in SQL. IN matches keywords and not pattern. One can programmatically combine IN and LIKE by using loops in any programming language. But sometimes simple SQL is better then PL-SQL block or some other program. In the example below, I am using oracle CASE statement to converge IN and LIKE in simple SQL. Suppose there are three tables: TABLE_ONE, TABLE_TWO, and TABLE_THREE with the following structure TABLE_ONE { ID, COL1, COL2, COL3 } TABLE_TWO { COL1, COL2 } TABLE_THREE { COL3 } Now we want to find records from TABLE_ONE where  TABLE_ONE.COL1 has entries LIKE TABLE_TWO.COL1and TABLE_ONE.COL2 has entries LIKE ABLE_TWO.COL2. Let's throw some more complexity by adding a requirement that TABLE_ONE.COL3 must have a matching pattern from TABLE_THREE.COL3 Below SQL is using the first requirement in the sub query of CASE statement and generating '1' in the case of match and '0' in the case of ...

Production IT Systems - Monitoring and Alerting

Image
Introduction Monitoring gives insight into an application, that how it is working, is there any problem and where is the problem. When people working with an application know to answers of these questions, they will be able to successfully operate the application, help their customers and keep up the business. Application monitoring is a paradigm of design that initiates with the start of design/ architecture phase. A well designed application is well equipped with self-monitoring capabilities and placeholders for other monitors to plugin into it. The goal of application monitoring is to reduce MMTK (mean time to know) and thus MTTR (mean time to recover). Depending on cases monitoring can also extend to capabilities of predictive fault assessment and therefor enabling provisions for preventive measurements. So the big three questions monitoring answers are:     How the application is working?     Is there any problem in any component of ...