Skip to content

Instantly share code, notes, and snippets.

@javajack
javajack / example.cs
Created January 31, 2022 18:57 — forked from brandonmwest/example.cs
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://sandbox-api.dhan.co","description":"Generated server url"}],"paths":{"/orders/{order-id}":{"get":{"tags":["Orders"],"summary":"get order by id","description":"get order by id description","externalDocs":{"description":"short description of external docs","url":"http://localhost/deeplink#"},"operationId":"OrderByOrderId","parameters":[{"name":"access-token","in":"header","required":true,"schema":{"type":"string"}},{"name":"order-id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successful operation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}}}},"put":{"tags":["Orders"],"summary":"modify order","description":"modify order description","externalDocs":{"description":"short description of external docs","url":"http://localhost/deeplink#"},"operationId":"modifyOrder","parameters":[{"name":"access-token","in":"header","required":
public List<ProfileDocument> searchByTechnology(String technology) throws Exception {
SearchRequest searchRequest = new SearchRequest();
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
QueryBuilder queryBuilder = QueryBuilders
.boolQuery()
.must(QueryBuilders
.matchQuery("technologies.name", technology));
@javajack
javajack / readme.txt
Last active March 6, 2020 07:03
readme.txt
Test@12345
Test@1234
Test@123
@javajack
javajack / swagger-gen-example.txt
Created February 20, 2020 09:48
swagger code generator example with specific atguments
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i /home/ubuntu/fineract/fineract-provider/src/main/resources/swagger-ui/response.json -l java --library resttemplate -o /home/ubuntu/temp-swagger/
a
{
"sortParamsByRequiredFlag": {
"opt": "sortParamsByRequiredFlag",
"description": "Sort method arguments to place required parameters before optional parameters.",
"type": "boolean",
"default": "true"
},
@javajack
javajack / RetrofitConfig.java
Created January 7, 2020 05:18
Retrofit2 Spring Boot Ignore SSL Config
package com.ms.pwm.retail.bank;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
@javajack
javajack / fineract-setup.txt
Created January 4, 2020 19:48
fineract dev setup
1) install jdk
2) set java home environment variable /etc/environment
3) setup maven, ide, git, db access tool of your choice
4) install docker
5) docker run --name mysql-5.5 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mysql -d mysql:5.5
6) git clone https://github.com/apache/fineract.git
7) ./gradlew createDB -PdbName=mifosplatform-tenants
8) ./gradlew createDB -PdbName=mifosplatform-tenants
@javajack
javajack / resttemplate-ignore-ssl.txt
Created January 1, 2020 06:43
RestTemplate IgnoreSSL And Self Signed Certificates ~ Not For Production
/*
* Create a RestTemplate bean
* with trust all SSL certificates and SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
* replaced for new apache httpclient to NoopHostnameVerifier.INSTANCE
*/
@Bean
public RestTemplate restTemplate() throws NoSuchAlgorithmException, KeyManagementException {
/*
* Ignore untrusted certificates
@javajack
javajack / adoptopenjdk-openj9.txt
Created November 8, 2019 15:50
AdoptOpenJdk OpenJ9 Ubuntu Installation
Import the official AdoptOpenJDK GPG key
Import the AdoptOpenJDK DEB repo using add-apt-repository
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt update
@javajack
javajack / logback.xml
Created September 6, 2019 04:08
logback structured logging encoder example
<?xml version="1.0" encoding="UTF-8"?>
<!-- Base logback configuration provided for compatibility with Spring Boot-->
<configuration>
<conversionRule conversionWord="clr"
converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />