Thursday, 31 January 2019

Tuesday, 29 January 2019

how to return isert ids from batch insert :MySQL

PreparedStatement ps = null;
ps = connection.prepareStatement(sql,ps.RETURN_GENERATED_KEYS);

results = ps.executeBatch();
            ResultSet rs= ps.getGeneratedKeys();
            while(rs.next()){
                playerIds.add(rs.getInt(1));
            }

date formatting in java

https://stackoverflow.com/questions/18480633/java-util-date-format-conversion-yyyy-mm-dd-to-mm-dd-yyyy

Monday, 28 January 2019

prepared statment date exception in java

https://stackoverflow.com/questions/30280494/why-do-i-get-a-com-mysql-jdbc-mysqldatatruncation-data-truncation-incorrect-d


PreparedStatement prep = con
         .prepareStatement("REPLACE INTO bus(mac, route, latitude, longitude, created_at)"
                 + "VALUES( ?, ?, ? , ?, now())");

convert array into list

https://stackoverflow.com/questions/1073919/how-to-convert-int-into-listinteger-in-java


int[] ints = {1,2,3};
List<Integer> list = Arrays.stream(ints).boxed().collect(Collectors.toList());
int[] ints = {1, 2, 3};
List<Integer> intList = new ArrayList<Integer>();
for (int i : ints)
{
    intList.add(i);
}
https://www.techiedelight.com/convert-int-array-list-integer/

Tuesday, 22 January 2019

JAVA wildcard tutorial

https://www.geeksforgeeks.org/wildcards-in-java/



//Java program to demonstrate Upper Bounded Wildcards
import java.util.Arrays;
import java.util.*;
 
class Main
{
    public static void main(String[] args)
    {
         
        //Upper Bounded Integer List
        List<Integer> list1= Arrays.asList(4,5,6,7);
         
        //printing the sum of elements in list
        System.out.println("Total sum is:"+sum(list1));
 
       // Double list
        List<Double> list2=Arrays.asList(4.1,5.1,6.1);
         
        //printing the sum of elements in list
       System.out.print("Total sum is:"+sum(list2));
    }
 
    private static double sum(List<? extends Number> list) 
    {
        double sum=0.0;
        for (Number i: list)
        {
            sum+=i.doubleValue();
        }
 
        return sum;
    }
}

Monday, 21 January 2019

javascript tricky question

https://www.thatjsdude.com/interview/js2.html

jedis libarary for java

https://www.baeldung.com/jedis-java-redis-client-library

http://www.javadoc.io/doc/redis.clients/jedis/3.0.1

Wednesday, 16 January 2019

Java arraylist implaemention and contains example

import java.util.ArrayList;
class Main {
  public static void main(String[] args) {
      ArrayList<Integer> al1 = new ArrayList<Integer>();
      al1.add(56);
      al1.add(88);
      ArrayList<Integer> al2 = new ArrayList<Integer>();
      al2.add(1);
      al2.add(99);
      al2.add(56);
      al2.add(13);
      al2.add(44);
      al2.add(6);
      for(Integer number : al2) {
       if( al1.contains(number)){
         System.out.println("player exist");
         return ;
       }
        System.out.println(number);
  }
      // System.out.println("'55' is present in arraylist: "+al2.contains(55));
      // System.out.println("'44' is there in arraylist: "+al2.contains(44));
      // System.out.println("'7' is there in arraylist: "+al2.contains(7));
  }
}

Thursday, 10 January 2019

SSO who works

https://stackoverflow.com/questions/35663357/how-does-sso-single-sign-on-work

Well, there are certainly many ways to achieve it, and it can be tricky. I can give you one solution as an example:
Consider two apps on different subdomains:
The Fine Corinthian Turkey Shop (turkey.example.com)
Rent a Baboon (monkey.example.com)
These two web apps want to share signon, and arrange for a third hosted website for their single sign-on:
sso.example.com
Then the flow is:
  1. Frank visits http://turkey.example.com/orders/12
  2. Turkey redirects to https://sso.example.com/login
  3. SSO presents user with login form, validates and issues token
  4. The token is saved in a cookie on SSO.
  5. User is now validated on SSO, but needs to get the token back to turkey.
  6. SSO stores a combination of (Guid, Token, Expiry) on the server, where Guid is a random guid and Expiry is something like 30 seconds.
  7. SSO sets a secure cookie on *.example.com containing the Guid
  8. SSO redirects back to http://turkey.example.com/orders/12
  9. Turkey can now retrieve the ticket from the cookie
  10. Turkey calls SSO server and exchanges the ticket for the token.
  11. Turkey stores token in the browser (typically a cookie)
Now let's imagine that Frank wants some nice juicy baboons to go with that turkey:
  1. Frank visits: http://monkey.example.com/order-in-bulk
  2. Monkey sees that Frank has no stored token and redirects to https://sso.example.com/login
  3. SSO sees that Frank is already logged in as he has a stored token.
  4. SSO stores a new (Guid, token, expiry) triple on the server
  5. Process is identical to the initial login the rest of the way

paypal new express checkout documention

https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-orderAuthPayment-curl-etc/#step-6-capture-the-first-payment-future


express checkout method
https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/
1.SetExpressCheckout
https://developer.paypal.com/docs/classic/api/merchant/GetExpressCheckoutDetails_API_Operation_NVP/
2.GetExpressCheckoutDetails
https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/
3.DoExpressCheckoutPayment



https://gist.github.com/xcommerce-gists/4121491

https://github.com/GeorgeOld/Paypal-NVP-PHP-code-examples

Wednesday, 9 January 2019

socket.io tutorial for node js

https://socket.io/get-started/chat/

encode decode url in javascript

let url ="{{base_url_laravel}}/api/rest/v1.6/question/retrieve_question?question_title=testQuestion2+4@@~$&limit=20&order=asc&sort_by=card_number&start_index=1";

let encodeUrl=encodeURIComponent(url);
console.log(`enodeurl----${encodeUrl}`);

let decodedUrl=decodeURIComponent(encodeUrl);
console.log(`decodedurl-----${decodedUrl}`);

Tuesday, 8 January 2019

paasing argument in node js module

https://stackoverflow.com/questions/35087024/what-does-requiremoduleparameter-mean



var mod = require('module'),
    module = mod(parameter);


https://stackoverflow.com/questions/13151693/passing-arguments-to-require-when-loading-module

Monday, 7 January 2019

HTTP vs HTTP2

https://medium.com/@factoryhr/http-2-the-difference-between-http-1-1-benefits-and-how-to-use-it-38094fa0e95b