Skip to content

Instantly share code, notes, and snippets.

View SergeyAlekseevN's full-sized avatar
🎯
Focusing

Sergey Alekseev SergeyAlekseevN

🎯
Focusing
View GitHub Profile
@SergeyAlekseevN
SergeyAlekseevN / CustomWebFilter.java
Created April 20, 2020 13:40
CustomWebFilter.java
**
* Workaround of https://github.com/spring-projects/spring-boot/issues/9785 from https://stackoverflow.com/a/45190717/1477873
*
* @author Sergey Alekseev
*/
@Component
public class CustomWebFilter implements WebFilter {
@NotNull
@Override
public Mono<Void> filter(ServerWebExchange exchange, @NotNull WebFilterChain chain) {
@SergeyAlekseevN
SergeyAlekseevN / selenium-links.md
Last active November 17, 2019 11:17
Web UI Test automation links
@SergeyAlekseevN
SergeyAlekseevN / git_mass.sh
Created November 11, 2019 20:29
Mass operations for git local repos
#!/bin/sh
COMMAND="$1"
IGNORED_MODULES=$(cat .ignored_modules 2> /dev/null)
RED_COLOR='\033[0;31m'
GREEN_COLOR='\033[0;32m'
GRAY_COLOR='\033[0;2m'
NO_COLOR='\033[0m'
_EXPOSE_PARAMS="shift 2"
@SergeyAlekseevN
SergeyAlekseevN / git_rename_commits.sh
Created November 11, 2019 20:28
GIT rename commits
git filter-branch --env-filter '
WRONG_EMAIL="wrong@email.com"
NEW_NAME="Sergey Alekseev"
NEW_EMAIL="sergey@alekseev.bz"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@SergeyAlekseevN
SergeyAlekseevN / page_to_screenshot.js
Created November 11, 2019 20:26
Puppeteer script to make screenshot of page
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://github.com');
await page.screenshot({path:`page-screenshot-${new Date()}.png`});
await browser.close();
})();
@SergeyAlekseevN
SergeyAlekseevN / page_to_pdf.js
Created November 11, 2019 20:25
Puppeteer script for make PDF file from URL
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://github.com', {waitUntil: 'networkidle2'});
await page.pdf({path: 'page.pdf', format: 'A4'});
await browser.close();
})();
@SergeyAlekseevN
SergeyAlekseevN / angular-links.md
Created November 1, 2019 12:21
Angular links
@SergeyAlekseevN
SergeyAlekseevN / sony_unlock_bios.py
Created November 1, 2019 12:16
Master Password Generator for Sony laptops (16 characters otp)
#!/usr/bin/python
# Copyright 2009-2010: dogbert <dogber1@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@SergeyAlekseevN
SergeyAlekseevN / ShudownExecutorService.java
Last active January 10, 2019 10:22
The following method shuts down an ExecutorService in two phases, first by calling shutdown to reject incoming tasks, and then calling shutdownNow, if necessary, to cancel any lingering tasks:
void shutdownAndAwaitTermination(ExecutorService pool) {
pool.shutdown(); // Disable new tasks from being submitted
try {
// Wait a while for existing tasks to terminate
if (!pool.awaitTermination(60, TimeUnit.SECONDS)) {
pool.shutdownNow(); // Cancel currently executing tasks
// Wait a while for tasks to respond to being cancelled
if (!pool.awaitTermination(60, TimeUnit.SECONDS))
System.err.println("Pool did not terminate");
}
@SergeyAlekseevN
SergeyAlekseevN / create.java
Last active November 8, 2018 12:28
Create instanse of class with 1+ args constructor using ByteBuddy
public class A {
private String message;
public A(String message) {
this.message = message;
}
public String getMessage() {
return message;
}