Search This Blog

Wednesday, January 22, 2020

Java CMD -D arguments Custom

Note your java class or jar name should be at last and not first before -D.

Ex:
YES = java -jar -Dfiles=c1 -Dexcludes=va2 filename.jar
NO = java -jar filename.jar -Dfiles=c1 -Dexcludes=va2


In Program
Properties systemProperties = System.getProperties();
System.out.println( systemProperties.get ( "files" ) );
System.out.println( systemProperties.get ( "excludes" ) );


Wednesday, January 15, 2020

Java Stream API - Get Max value from two list.

Double max = volist.stream().map(vo -> modellist .stream()
  .collect(Collectors.averagingDouble(model ->
  jarowinklerdistance.apply(model.getCity(), vo.getCity())))
  ).max(Double::compare).get();
 
  System.out.println(max);

Monday, January 13, 2020

Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

1. You are missing the @SpringBootApplication annotation on your Start class 
2. SpringApplication.run ( , args );  
3. in all the area in that java file.

Sunday, January 5, 2020

Jenkins :: 'cmd' is not recognized as an internal or external command, operable program or batch file. Build step 'Execute Windows batch command' marked build as failure

1. Open jenkins http://localhost:8080
2. Click Jenkins config (Manage Jenkins -> Configure System -> Global properties -> Environment variables: name=PATH, value= PATH >)


Note: add C:\WINDOWS\System32; rather than %SystemRoot%\system32


%systemroot% not taking in jenkins.

so your path value is C:\WINDOWS\System32;c:\jdk......




Tuesday, December 24, 2019

Flask Ask - modulenotfounderror no module named 'pip.req' flask-ask

Try like below.


pip install git+https://github.com/johnwheeler/flask-ask.git@v0.8.8

pip install flask-ask




#Enjoy

Tuesday, December 10, 2019

Python Google Speech Setup and Example (WINDOWS)

1. Download SOX latest version - https://sourceforge.net/projects/sox/files/sox/

2. Install it (ex: C:\Program Files (x86)\sox-14-4-2 )
     2.1 download 2 (libmad-0.dll, libmp3lame-0.dll) DLLs and copy to C:\Program Files (x86)\sox-14-4-2;

                 https://app.box.com/s/tzn5ohyh90viedu3u90w2l2pmp2bl41t


3. Set environment path in system variable

4. Restart the IDE or CMD prompt

5. in cmd prompt
        set path=%path%;C:\Program Files (x86)\sox-14-4-2;
       echo %path%

6. pip install google_speech
    pip install sox

7. create a sample test.py


from google_speech import Speech

# say "Hello World"
text = "Hello This is Vijay DR";
lang = "en";
speech = Speech(text, lang);
speech.play();

# you can also apply audio effects while playing (using SoX)
# see http://sox.sourceforge.net/sox.html#EFFECTS for full effect documentation
sox_effects = ("speed", "1.5");
speech.play(sox_effects);

# save the speech to an MP3 file (no effect is applied)
speech.save("output.mp3");


8. cmp prompt py test.py



enjoy !
vijay

Wednesday, November 27, 2019

IText - Alignment, Page Size Html to Pdf

Document document = new Document ();
PdfWriter writer = PdfWriter.getInstance ( document, new FileOutputStream ( "d:/fhpl.pdf" ) );
document.setMargins ( 0.1f, 0.1f, 0.1f, 0.1f );
document.setPageSize ( PageSize.A3 );
document.open ();
XMLWorkerHelper.getInstance ().parseXHtml ( writer, document, new FileInputStream ( "d:/fhpl1.html" ) );
document.close ();



Note: Before document.open(); to place all your customize settings.

Flying Saucer HTML to PDF

Add this maven

<!-- https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf-itext5 -->

<dependency>

    <groupId>org.xhtmlrenderer</groupId>

    <artifactId>flying-saucer-pdf-itext5</artifactId>

    <version>9.1.19</version>

</dependency>


Code 

        String inputFile = "d:/xxx.html";
        String url = new File(inputFile).toURI().toURL().toString();
        String outputFile = "d:/xxx.pdf";
        OutputStream os = new FileOutputStream(outputFile);
       
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(url);
        renderer.layout();
        renderer.createPDF(os);
       

        os.close();


Note
It will throw if any " QName production: QName::=(NCName':')?NCName. ' Exception in thread "main" org.xhtmlrenderer.util.XRRuntimeException: "  Then your html tag has problem. correct that html tag and re run it.

for ex: <Table width: 50%"> 
     to
      <table width="50%">

Tuesday, November 26, 2019

Linux nMap commands

nmap
nmap -O
nmap -sA
nmap -r
nmap -sS
nmap -sP
nmap --iflist
nmap -PS
nmap -PO
nmap -PU
nmap -sU
nmap -v -sT -PN --spoof-mac 0
nmap -v -sS -A -T4

Thursday, November 7, 2019

NSE options Data Pulling with beta.nseindia.com

Beta version they are giving it as JSON which is very easy for us.

See the sample url. 

1. JSON output,
2. Directly use the JSON for your business logic.
3. Before install requests, simplejson plugin
     pip install simplejson
     pip install requests

Same for older version - sample code and output

http://drvijayy2k2.blogspot.com/2019/08/python-code-to-pull-nse-option.html

Code

import requests
import simplejson as json

result = requests.get ( "https://beta.nseindia.com/api/quote-derivative?symbol=NIFTY&identifier=OPTIDXNIFTY07-11-2019" );
resultJson = json.loads( result.content )
#print ( resultJson["info"] );
strikePricesDetailsJson = resultJson["stocks"]
for strikePrice in strikePricesDetailsJson:
    spDetails = strikePrice["metadata"];
    #print ( spDetails );
    print ( spDetails["optionType"] , " : ", spDetails["strikePrice"] , " : ", spDetails["lastPrice"]);



Output

Call  :  12350  :  0
Put  :  11050  :  0

Call  :  12750  :  0


{'metadata': {'instrumentType': 'Index Options', 'expiryDate': '28-Dec-2023', 'optionType': 'Put', 'strikePrice': 12700, 'identifier': 'OPTIDXNIFTY28-12-2023PE12700.00', 'openPrice': 0, 'highPrice': 0, 'lowPrice': 0, 'closePrice': 0, 'prevClose': 1005, 'lastPrice': 0, 'change': -1005, 'pChange': -100, 'numberOfContractsTraded': 0, 'totalTurnover': 0}, 'underlyingValue': 11998.1, 'volumeFreezeQuantity': 5001, 'marketDeptOrderBook': {'totalBuyQuantity': 225, 'totalSellQuantity': 0, 'bid': [{'price': 645.05, 'quantity': 75}, {'price': 645, 'quantity': 75}, {'price': 597, 'quantity': 75}, {'price': 0, 'quantity': 0}, {'price': 0, 'quantity': 0}], 'ask': [{'price': 0, 'quantity': 0}, {'price': 645, 'quantity': 0}, {'price': 0, 'quantity': 0}, {'price': 0, 'quantity': 0}, {'price': 0, 'quantity': 0}], 'carryOfCost': {'price': {'bestBuy': 645.05, 'bestSell': 0, 'lastPrice': 0}, 'carry': {'bestBuy': -70.5660812600072, 'bestSell': 0, 'lastPrice': 0}}, 'tradeInfo': {'tradedVolume': 0, 'value': 0, 'vmap': 0, 'premiumTurnover': 0, 'openInterest': 6, 'changeinOpenInterest': 0, 'pchangeinOpenInterest': 0, 'marketLot': 75}, 'otherInfo': {'settlementPrice': 0, 'dailyvolatility': 0.91, 'annualisedVolatility': 17.45, 'impliedVolatility': 0, 'clientWisePositionLimits': 19597661, 'marketWidePositionLimits': 0}}}



Hit Counter


View My Stats