Friday

Gradle - Installation

1. Download gradle zip file from  https://gradle.org/releases/








2. Extract files from zip to a location.
3. Go to enviroment variables >> system variables >> new































4. Go to enviroment variables >> system variables >> Edit 'path' >> add '%GRADLE_HOME%/bin'




















5. cmd >> gradle -v

Thursday

How to install and configure Git(2.19.0) and GitHub on Windows

Install git on your desktop:
1. Go  https://git-scm.com/  >> click Downloads >> click for windows.
2. Run the downloaded file.
3. Click next, select below components, then click next.
























































































































































































Create repository on GitHub:
1. Create an account for GitHub. https://github.com/
2. Sign in to GitHub with your user.
3. Click to new repository:































































You can select language from >> 'add .gitignore' section


























































































Then click 'Create repository.'








































































You can find the link for your repository as follow:



















































Configure  git and github:
1. Create a folder named as 'git'. C:\git
2. Then open git bash.
3. Lets pass to out folder directory.
 'cd /C'







































































































'cd git/'



































git config --global user.name "Your github name"
































git config --global user.email "your email adress"
































git clone (your repository adress - i show you up how to copy it)































TestGit folder has been copied to our folder:

























How to upload files to GitHub:




1.Create  a file:































2. Write something to file then save.



























































3.
git add (file names)
























































4.
git commit - m "(committed message)" filename


































5.
git push -u origin master
>> at first time it will ask github user-password.












































6. Go to github then refresh page.
































































Change file and upload again:
1. Change text in the file and save it.














2.
git status










































3.
git commit - m "(committed message)" filename






























4.
git push -u origin master












































5. Go to your github page.

Wednesday

Postgres >> manually alter sequence next value

SELECT setval('my_seq', 100, FALSE);
--my_seq >> your sequence name
-- 100 >> value you want to set
-- false >> means the next value would be 100
--       >> if it would be true then next value will be 100+1 = 101

Monday

How to access JBoss over an another host

For accessing JBOSS or Wildfly from another host outside of localhost:

<!-- in standalone.xml  there is a definition as follows-->
<interface name="public">
    <inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>

<!--you can do any of the following -->

<!-- 1. choice: 
     binding for all the IP Addresses 
-->
<interface name="public">
     <inet-address value="${jboss.bind.address:0.0.0.0}"/>
</interface>

<!-- 2. choice: 
     binding for only one IP adress 
-->
<interface name="public">
     <inet-address value="${jboss.bind.address:192.168.x.x}"/>
</interface>

<!-- 3. choice:
     double click on server 
     then click 'Open launch configuration'
     then add -b 0.0.0.0 to the  'Arguments' 'Program arguments' 
-->

Friday

How to check for the existence of undeclared variable in js

You can check for the existence of undeclared variable in javascript without getting ReferenceError:
if (x !== undefined){} // gets error if x undeclared
if (x !== 'undefined'){} // gets error if x undeclared
if (typeof x !== undefined){} // gets error because typeof x returns "undefined"

if (typeof x !== 'undefined'){} //right one

Tuesday

How to learn which vendor / version is using in jsf webapp? (MyFaces or Mojarra)

You can run the following code fragment in your application:
import javax.faces.context.FacesContext;

System.out.println("imp title: " + FacesContext.class.getPackage().getImplementationTitle());
System.out.println("impl vendor " + FacesContext.class.getPackage().getImplementationVendor());
System.out.println("imp version: " + FacesContext.class.getPackage().getImplementationVersion());
Sample output:

imp title: Apache MyFaces JSF-2.2 Core API
impl vendor The Apache Software Foundation
imp version: 2.2.11

Dynamically calling a class - method in java by using reflection

Dynamically call a method on a dynamically given class by using reflection:
import java.lang.reflect.Method;

try {
       String myClassName = "tr.com.xx.xx.xx.Example";
       String myMethodName = "exampleMethod";

       Class<?> myClassRef = Class.forName(myClassName);
       Object instanceOfMyClass = myClassRef.newInstance();
       
       //my object input types in order: param1(int), param2(String), param3(MyDTO), param4(List<MyDTO>)
       Method method = myClassRef.getDeclaredMethod(myMethodName, int.class, String.class, MyDTO.class, List.class);
       MyResult respoonse = (MyResult) method.invoke(instanceOfMyClass, param1, param2, param3, param4);
       System.out.println("response" + response.getX());

} catch(Exception e) {
       //logging
       System.out.println(e.getMessage());

Hint: shaking problems in Safari

Container has been shaking chidren on safari. However in chrome, ie, firefox it works well.

Advice:
Dynamically height calculation shakes children on safari.
Check for any dynamically calculation for height. Then try to give "position: fixed" or try to avoid giving height dynamically.

JSTL format number

Add following taglib to your class:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:formatNumber value="${your double value}" maxFractionDigits="0"  groupingUsed="false" />
<!-- your value example :1500.0 then it will show 1500 ! -->
<!-- You can use it instead of <c:out /> which doesn’t have so much control for formatting -->

Why is SimpleDateFormat changing given date?

//The upper case Y is "week year". It has 364 or 371 days 
//The lower case y has usual 365 or 366.
//So they give different outputs:
//Locale.forLanguageTag("tr_TR") >> comes with Java 7

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;


public class Test {

    public static void main(String[] args) {
       try {
           String dateString = new java.util.Date().toString();
           System.out.println(dateString);

           SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.forLanguageTag("tr_TR"));
           Date date = format.parse(dateString);
           System.out.println(date.toString());

           SimpleDateFormat format2 = new SimpleDateFormat("EEE MMM dd HH:mm:ss z YYYY", Locale.forLanguageTag("tr_TR"));
           Date date2 = format2.parse(dateString);
           System.out.println(date2.toString());

       } catch (ParseException e) {
           //log
       }
    }
    
}
Output:

Mon May 14 10:31:14 EEST 2018
Mon May 14 10:31:14 EEST 2018
Mon Jan 01 09:31:14 EET 2018