Skip to main content

Posts

Java remove redundant values in a list of String and sort it

            List<String>idees=new ArrayList<String>();             idees.add("0009232329329323923");             idees.add("9009232329329323923");             idees.add("5009232329329323923");             idees.add("1009232329329323923");             idees.add("4009232329329323923");             idees.add("3009232329329323923");             idees.add("6009232329329323923");             idees.add("2009232329329323923");             idees.add("7009232329329323923");             idees.add("0009232329329323924");             idees.add("0000000000000000000");             idees.add("00...

enable/disable element in html

<!DOCTYPE html> <html> <head> <script> function disable_enable(){ if (document.all || document.getElementById){ if (document.test1.test2.disabled==true) document.test1.test2.disabled=false else document.test1.test2.disabled=true } } </script> </head> <body>  <form name="test1">       <p><input type="test" value="A Button" name="test2" disabled> <a       href="javascript:disable_enable()">Click here</a></p>     </form> </body> </html>

SQL group by comon mistakes

problem:   we have millions of patient visits and we want to get all last patients visits in the hospital solution: 1-we have to separate them by patient id wise  to avoid engine crushing               2- we will use group by in our query BUT we should group by only patient id ***trick***  to bring more details in your query and avoid redundancy  , then you may add more columns but in the form of calculations  then you don't have to put them after group by the below example brings max visit of each patient ..and i have added VISIT_DATE as well in my details without adding it after group by ....just by using max (v.VISIT_DATE) select  max(v.VISIT_NO) , v.PATIENT_ID ,max(v.VISIT_DATE) as last_visit from OPS_PATIENT_VISITS v   where  v.PATIENT_ID  between 1 and 10 group by v.PATIENT_ID

Android : adding library project into your project

Let say you have a list view activity in a separate project and is defined as library and it's main activity is "com.ls.list.MyActivity" t he proper way is to add the activity in the main project manifest file <activity android:name="com.ls.list.MyActivity" /> then create intent as usual Intent intent =new Intent(this, MyActivity.class);     startActivity(intent); another way which does not need the manifest changes  inside the main project's activity just write this simple code     Intent intent = new Intent(android.content.Intent.ACTION_VIEW);     intent.setComponent(new ComponentName("com.ls.list","com.ls.list.MyActivity"));      startActivity(intent);

Android :download android sdk manually

1- make sure that eclipse and sdk are closed 2- download the platform from this link http://qdevarena.blogspot.com/2010/05/download-android-sdk-standalone-for.html  and extract it under sdk\platforms 3-download system image for example  this for android 4.2  jelly-bean API level 17 http://software.intel.com/en-us/articles/intel-eula-x86-android-4-2-jelly-bean-bin extract it under  sdk\system-images\android-17 4- start eclipse and start sdk 

Runing multiple mysql instances on one machine

Suppose you have two mysql instances  c:\mysq1 and c:\mysql2 1- create file c:\mysql1\my.cnf add the following lines [mysqld] datadir = C:/mysql1/data port = 3308     2- create file c:\mysql2\my.cnf add the following lines   [mysqld] datadir = C:/mysql2/data port = 3309    3-now run the first instance    cd c:\mysql1\bin mysqld --defaults-file=c:\mysql1\my.cnf     4-open another command and run the second instance     cd c:\mysql2\bin mysqld --defaults-file=c:\mysql2\my.cnf finsihed ;)