Skip to content

Instantly share code, notes, and snippets.

View matrixcloud's full-sized avatar
🧑‍💻
Fighting

atom matrixcloud

🧑‍💻
Fighting
View GitHub Profile
@matrixcloud
matrixcloud / LoginClient.java
Created November 27, 2023 01:17
Send raw soap request with headers
public boolean login(String userId, String password) {
try {
val content = soapMessageLoader.load("soap/login_message.xml", usernameOfCredential, passwordOfCredential, userId, password);
log.info("Login content: {}", content);
val soapConnectionFactory = SOAPConnectionFactory.newInstance();
val endpoint = new URL(loginUrl);
val connection = soapConnectionFactory.createConnection();
val factory = MessageFactory.newInstance();
val message = factory.createMessage(new MimeHeaders(), new ByteArrayInputStream(content.getBytes()));
val response = connection.call(message, endpoint);
@matrixcloud
matrixcloud / Jenkinsfile
Created November 1, 2023 06:35
Jenkins pipline to build different artifacts
def get_version() {
if (env.TAG_NAME?.trim()) {
return "$TAG_NAME"
}
def baseVersion = sh(script: "mvn help:evaluate -Dexpression=project.version | grep -e '^[^\\[]'", returnStdout: true).trim()
if (env.BRANCH_NAME == 'master') {
return "$baseVersion-rc.$BUILD_NUMBER"
} else {
return "$baseVersion-alpha.$GERRIT_CHANGE_NUMBER-SNAPSHOT"
}
@matrixcloud
matrixcloud / go-gh.sh
Created June 1, 2023 01:41
Open your repository in github
url=$(git config --get remote.origin.url)
in_array=(${url//:/ })
open https://github.com/${in_array[1]}
@matrixcloud
matrixcloud / index.scss
Created April 6, 2023 10:25
React Pretty Pdf Viewer
.pdfViewer {
display: flex;
justify-content: center;
flex-direction: row;
}
.react-pdf__Document {
position: relative;
&:hover {
@matrixcloud
matrixcloud / install.sh
Last active February 11, 2023 09:32
Install ESLint and Prettier for React, Vite and Typescript project
npm i @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react pre-commit prettier -D
@matrixcloud
matrixcloud / fetch-pageable-data.js
Created January 10, 2023 02:46
javascript to get pageable data by generator
import axios from "axios"
const BASE_API = 'http://localhost:9090/actuator'
async function scheduleJob(jobId) {
try {
await axios.put(`${BASE_API}/jobs/${jobId}/schedule`)
} catch(e) {
console.error(`failed to schedule job ${jobId} due to ${e.message}`)
}
@matrixcloud
matrixcloud / KK.java
Last active November 11, 2022 09:22
JMH Benchmark Sample
@BenchmarkMode(Mode.AverageTime)
@Warmup(iterations = 3, time = 1)
@Measurement(iterations = 5, time = 5)
@Threads(4)
@Fork(1)
@State(value = Scope.Benchmark)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class KK {
private final XmlMapper xmlMapper;
@matrixcloud
matrixcloud / rules.pl
Created January 27, 2021 12:40
Gerrit commit message check for all projects
%filter to require all projects to have correct commit message
submit_filter(In, Out) :-
%unpack the submit rule into a list of code reviews
In =.. [submit | Ls],
%add commit message validator
require_commit_message_check(Ls, R),
%pack the list back up and return it
Out =.. [submit | R].
require_commit_message_check(S1, S2) :-
/**
* Created by atom on 6/13/2019.
*/
public class DefaultSslFactory {
private DefaultSslFactory() {}
public static SslContextFactory getSslContextFactory() {
SslContextFactory sslContextFactory = new SslContextFactory();
@matrixcloud
matrixcloud / check_table.sql
Created January 10, 2020 07:27
Check if table eexists
-- sql server
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'TheSchema' AND TABLE_NAME = 'TheTable'
-- postgresql
SELECT EXISTS (
SELECT 1
FROM information_schema.tables
WHERE table_schema = 'schema_name'
AND table_name = 'table_name'
);
-- oracle