Skip to content

Instantly share code, notes, and snippets.

@highel
highel / Main.java
Created April 20, 2024 09:51
Command line tool to remove unneeded PDF pages
package org.example;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
@highel
highel / pillow-simd-libjpeg-turbo.md
Created November 13, 2023 22:59 — forked from willprice/pillow-simd-libjpeg-turbo.md
Pillow-SIMD with libjpeg/turbo

sudo apt-get install gcc-multilib

# The following steps are based on
# https://docs.fast.ai/performance.html#installation

$ conda install -y -c conda-forge gxx_linux-64 
$ conda uninstall -y --force jpeg libtiff
$ conda install -y -c conda-forge libjpeg-turbo --no-deps
@highel
highel / remove_sms.py
Last active September 16, 2023 22:43 — forked from GWuk/zte_sms.py
Remove all SMS from ZTE MF283V modem. This modem has tendency to overflow after you cant view SMS in UI. Tested on Russian Tele 2 version.
import requests
import json
import base64
url = 'http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=sms_data_total&page=0&data_per_page=500&mem_store=1&tags=10&order_by=order+by+id+desc'
s = requests.Session()
s.headers.update({'Host': '192.168.0.1'})
s.headers.update({'Referer': 'http://192.168.0.1/index.html'})
r = s.get(url)
:if ( [/ping 8.8.8.8 count=5 size=64 interval=2s ] =0) do={
:log error "-----No ping";
/system routerboard usb power-reset duration=2;
:log error "----Reset USB Power";
/delay 30s
:log error "disable";
/interface disable lte1;
/delay 5s
:log error "enable";
/interface enable lte1;
@highel
highel / build.gradle
Created January 6, 2018 16:55 — forked from AntonKosov/build.gradle
android + gradle + idea + git + private keystore
// Tags:
// Version name: ignore leading non-digits and everything after the first underscore
// Version code: take digits after the first underscore
// e.g. tag xxx1.2.3.foo-bar_15_baz will yield versionName 1.2.3.foo-bar and versionCode 15
// Output filename:
// <project name>-<release|debug>-<version (from last tag)|"dev" (doesn't have tag)>[-NOTRELEASE (exist changes after last tag)]-<last short commit hash>[-dirty (exist changes)].apk
// Sample:
// myproject-debug-dev-094cf50.apk
// myproject-debug-0.1.0-094cf50.apk
@highel
highel / Split.java
Created January 5, 2018 17:35
split text with delimeters
public class Split {
public static Pattern whitespace = Pattern.compile("\\s+");
public static void main(String[] s) {
List<Block> blocks = splitWithDelimiters("r2ejh2j 24 3");
blocks = splitWithDelimiters("СЛОН ТОПТПАИТ 24 3343");
blocks = splitWithDelimiters(" топтает ");
blocks = splitWithDelimiters(" тооп");
blocks = splitWithDelimiters(" ");
blocks = splitWithDelimiters("");
@highel
highel / SpringBootExternalTest.java
Last active October 25, 2017 12:03
Launch full fledged Spring Boot application in separate test. This is only for integration testing with HTTP protocol, normally you should use Spring Test MVC framework to test controllers and Spring less unit testing of separate classes.
public class SpringBootExternalTest {
static CompletableFuture<Throwable> initializationException;
@BeforeClass
public static void startSpringContext() {
initializationException = new CompletableFuture<>();
Thread appThread = new Thread(() -> {
SpringApplication springApplication = new SpringApplication(
SpringBootApplication.class);
springApplication.addListeners((ApplicationListener<ApplicationReadyEvent>) event -> initializationException.complete(null));
@highel
highel / gist:f2c1867fd764a4b1374886fec3accb36
Created July 25, 2016 16:24
CryptoPRO Tomcat Connector
<Connector port="8443" maxHttpHeaderSize="8192"
protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false"
algorithm="GostX509"
keystoreProvider="JCP"
sslProtocol="GostTLS"
keystoreType="HDImageStore"
@highel
highel / keycloak.sh
Created July 20, 2016 17:30 — forked from paoloantinori/keycloak.sh
Keycloak Admin API Rest Example
#!/bin/bash
export TKN=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin" \
-d 'password=admin' \
-d 'grant_type=password' \
-d 'client_id=admin-cli' | jq -r '.access_token')
curl -X GET 'http://localhost:8080/auth/admin/realms' \
@highel
highel / gist:81ee0b3da8bf3c6c31490ea87af88fac
Last active June 30, 2016 15:50
Compressing connector for Pentaho
Enable GZIP Traffic compression for slow LAN - actually sacrifices performance to much faster network access - you should not apply this mindlessly
server.xml
<Connector
className="Http11Nio2Protocol"
enableLookups="false"
compression="force"
URIEncoding="UTF-8" port="8080" protocol="HTTP/1.1"
connectionTimeout="40000"
socket.directBuffer="true"
redirectPort="8443" />