Tuesday, August 29, 2017

Friday, August 25, 2017

powershell code that copy big file and show progress bar

1) copy following code into powershell console

function Copy-File {
    param( [string]$from, [string]$to)
    $ffile = [io.file]::OpenRead($from)
    $tofile = [io.file]::OpenWrite($to)
    Write-Progress -Activity "Copying file" -status "$from -> $to" -PercentComplete 0
    try {
        [byte[]]$buff = new-object byte[] 4096
        [int]$total = [int]$count = 0
        do {
            $count = $ffile.Read($buff, 0, $buff.Length)
            $tofile.Write($buff, 0, $count)
            $total += $count
            if ($total % 1mb -eq 0) {
                Write-Progress -Activity "Copying file" -status "$from -> $to" `
                   -PercentComplete ([int]($total/$ffile.Length* 100))
            }
        } while ($count -gt 0)
    }
    finally {
        $ffile.Dispose()
        $tofile.Dispose()
        Write-Progress -Activity "Copying file" -Status "Ready" -Completed
    }
}

2)use following command to copy file and show progress bar in powershell console
Copy-File -from FromFileLocationAndName -to toFileLocationAndName



Monday, June 12, 2017

get details information about SAP sales orders

1) T-code ST04
2) left side SQL Command Editor
    select * from vbap where VBELN='0004714464' order by POSNR;
use export button in result table to export resultset

Monday, June 5, 2017

‘q’ Parameter in HTTP ‘Accept’ Header

‘q’ Parameter in HTTP ‘Accept’ Header

A REST API can return the resource representation in many formats – to be more specific MIME-types. A client application or browser can request for any supported MIME type in HTTP Accept header. Technically, Acceptheader can have multiple values in form of comma separated values.
For example, an Accept header requesting for text/html or application/xml formats can be set as:
Accept : text/html,application/xml

The ‘q’ Parameter

Sometimes client may want to set their preferences when requesting multiple MIME types. To set this preference,q parameter (relative quality factor) is used.
Value of q parameter can be from 0 to 1. 0 is lowest value (i.e. least preferred) and 1 is highest (i.e. most preferred).
A sample usage can be:
Accept : text/html, application/xml;q=0.9, */*;q=0.8
In above example, client is indicating the server that it will prefer to have the response in text/html format, first. It server does not support text/html format for requested resource than it shall send application/xml format. If none of both formats are available, then send the response in whatever format it support (*/*).
  • One of the benefit of ‘q’ parameter is to minimize the client-server interactions, which could have happened due to failed content negotiations.
  • It also allow clients to receive content types of which they may not be aware, an asterisk “*” may be used in place of either the second half of MIME type value, or both halves.
Here’s how the HTTP spec defines it:
Each media-range MAY be followed by one or more accept-params, beginning with the “q” parameter for indicating a relative quality factor. The first “q” parameter (if any) separates the media-range parameter(s) from the accept-params. Quality factors allow the user or user agent to indicate the relative degree of preference for that media-range, using the qvalue scale from 0 to 1. Default value is 1.
If there are two MIME types for given same q value, then more specific type, between both, wins.
For example if both application/xml and */* had a preference of 0.9 then application/xml will be served by the server.
If no Accept header field is present, then it is assumed that the client accepts all media types. If anAccept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response.

Wednesday, May 31, 2017

see outlook email details include internet headers

1) double click the email in outlook
2) click file menu in top
3) make sure info is selected in left menu list
4) click the Properties button in right side
5)  open up the properties window include all information we need to check

Thursday, May 18, 2017

simulate http post with difference tools

1)curl
1       curl -A "Mozilla/5.0" -verbose -X POST http://xxx.yyy.com/Sale/BillOfSaleExport --ntlm --negotiate -u domain\\Test.msmanager1:Password -d@data1.txt --trace log1.log
2   2)wget
w   wget -d -S --post-file=data_sale_bill1.txt --http-user=domain\\Test.msmanager1 --http-password=Password http://xxx.yyy.com/Sale/BillOfSaleExport
3     3)FireFox with Firebug
c    change the request header and body make sure they are match the log from curl/wget,we will get same binary data as curl and wget, since NTLM/kerberos need noegiate, so user will get two time 401 http code, finally get 200 code and data back.



p

44) SOAPUI
55) other browser like chrome/IE



3

3

Monday, May 15, 2017

oracle db table lock

in oracle db, some time we need lock a table for long time db update, here is the command
lock table table_name in exclusive mode;

after update, we need commit or rollbak to release the lock

other application can use following code to check the lock

SELECT
    B.Owner,
    B.Object_Name,
    A.*
FROM
    V$Locked_Object A,
    All_Objects B
WHERE
    A.Object_ID = B.Object_ID and A.OBJECT_ID=1211103;

object_id is the table's object_id in table all_objects

create a short name for long name executable file in windows 7 64bit

when create a  link for executable file in 64bits windows, we should use hard link
ln -P "notepad++.exe" npp.exe

sybbolic linked will result a error says unsupported 16 bits application

Thursday, May 11, 2017

Format xml output from curl

curl -s http://localhost:8983/solr/gettingstarted/select?q=video |tidy -xml -i -

Wednesday, March 1, 2017

H2 database server mode

1) start H2 server with tcp parameter

java -cp h2-1.4.191.jar org.h2.tools.Server -tcp -tcpAllowOthers -trace

2) connet to db by following url

jdbc:h2:tcp//localhost/~/test
 userName:SA, no password

HSQLDB Server mode

1) user following  command to start hsqldb in server mode

   bin>runServer.bat -database.0 file.mydb --dbname.0 xdb

    xdb is alias of database

2) use following URl and user name to connect
 
   jdbc:hsqldb:hsql://localhost/xdb

Tuesday, February 21, 2017

Tuesday, February 14, 2017

types of keystores

ystore is a storage facility to store cryptographic keys and certificates. They are most frequently used in SSL communications to prove the identity of servers and clients. A keystore can be a file or a hardware device. Three are three kinds of entries can be stored in a keystore depending on the types of keystores.
The three types of entries are:
PrivateKey : This is a type of keys which are used in asymmetric cryptography. It is usually protected with password because of its sensitivity. It can also be used to sign a digital signature.
Certificate : A certificate contains a public key which can identify the subject claimed in the certificate. It is usually used to verify the identity of a server. Sometimes it is also used to identify a client when requested.
SecretKey : A key entry which is sued in symmetric cryptography.
Depending on what entries the keystore can store and how the keystore can store the entries, there are a few different types of keystores in Java: JKS, JCEKS, PKCS12, PKCS11 and DKS. You can find the introduction of these keystore on Oracle's Java Cryptography Architecture description.
Next, we will have an overview of these keystore types.
JKS, Java Key Store. You can find this file at sun.security.provider.JavaKeyStore. This keystore is Java specific, it usually has an extension of jks. This type of keystore can contain private keys and certificates, but it cannot be used to store secret keys. Since it's a Java specific keystore, so it cannot be used in other programming languages. The private keys stored in JKS cannot be extracted in Java.
JCEKS, JCE key store(Java Cryptography Extension KeyStore). It is a super set of JKS with more algorithms supported. It is an enhanced standard added later by Sun. You can find this file at com.sun.crypto.provider.JceKeyStore. This keystore has an extension of jceks. The entries which can be put in the JCEKS keystore are private keys, secret keys and certificates. This keystore provides much stronger protection for stored private keys by using Triple DES encryption.
The provider of JCEKS is SunJCE, it was introduced in Java 1.4. Hence prior to Java 1.4, only JKS can be used.
PKCS12, this is a standard keystore type which can be used in Java and other languages. You can find this keystore implementation at sun.security.pkcs12.PKCS12KeyStore. It usually has an extension of p12 or pfx. You can store private keys, secret keys and certificates on this type. Unlike JKS, the private keys on PKCS12 keystore can be extracted in Java. This type is portable and can be operated with other libraries written in other languages such as C, C++ or C#.
Currently the default keystore type in Java is JKS, i.e the keystore format will be JKS if you don't specify the -storetype while creating keystore with keytool. However, the default keystore type will be changed to PKCS12 in Java 9 because its enhanced compatibility compared to JKS. You can check the default keystore type at$JRE/lib/security/java.security file:
PKCS11, this is a hardware keystore type. It provides an interface for the Java library to connect with hardware keystore devices such as SafeNet's Luna, nCipher or Smart cards. You can find this implementation at sun.security.pkcs11.P11KeyStore. When you load the keystore, you no need to create a specific provider with specific configuration. This keystore can store private keys, secret keys and certificates. When loading the keystore, the entries will be retrieved from the keystore and then converted into software entries.
DKS, Domain KeyStore is a keystore of keystore. It abstracts a collection of keystores that are presented as a single logical keystore. Itself is actually not a keystore. This new keystore type is introduced in Java 8. There is a new classDomainLoadStoreParameter which closely relates to DKS.
This keystore is located at sun.security.provider.DomainKeyStore.java.
Windows-MY, this is a type of keystore on Windows which is managed by the Windows operating system. It stores the user private keys and certificates which can be used to perform cryptographic operations such as signature verification, data encryption etc. Since it's a kind of native keystore, Java doesn't have a general API to access it. Oracle provides a separate API to access the Windows-MY keystore -- SunMSCAPI. The provider class for this API is sun.security.mscapi.SunMSCAPI.
BKS, BoucyCastle keystore, is a keystore format provided the popular third party Java cryptographic library provider -- BouncyCastle. It is a keystore similar to the JKS provided by Oracle JDK. But it supports storing secret key, private key and certificate. It is frequently used in mobile application developments.
In Java, there are a few choices on how a keystore can be processed. Writing the Java code is apparently a choice. Apart from this, a tool comes along with the JDK can also be used, it is called keytool.
keytool is a command line tool. It can be used to create keystore, generate keys, import and export certificates etc. For a full list of commands keytool supports, you can refer to Oracle keytool guideline.
If you are using IBM JDK, there is one more tool which can be used, it is ikeyman. ikeyman is a GUI tool which can provide a straightforward view of the keystore. The entries in the keystore. Keys and certificates can be created using ikeyman as well. It is a tool used frequently by system administrators.

Friday, February 10, 2017

JBOSS CLI

jboss-cli.bat --connect controller=xxx1.yyy.com --gui

Thursday, January 26, 2017

transaction code summary

SAP Easy Access -> Tools -> Customizing -> IMG -> Execute Project (SPRO) -> SAP Reference IMG

t-code:The SAP Project Reference Object (SPRO)
define a company:OX15 (new entries)
define a company code:OX02(new entries)
Assign Company Code to Company or use the transaction code OX16
Defining a business area t-code:OX03
To define a segment t-code(no tcode_ ,only form menu IMG -> Enterprise Structure -> Definition ->Financial Accounting -> Define Segment


Maintain Fiscal Year Variant tcode:OB29