Skip to content

Instantly share code, notes, and snippets.

@m1roff
m1roff / loading.svg
Last active May 10, 2018 17:39
SVG snake loadign
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@m1roff
m1roff / README-setup-tunnel-as-systemd-service.md
Created May 22, 2018 08:24 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/[email protected]. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@m1roff
m1roff / fn.getTopLevelDomain.sql
Created April 15, 2021 11:17
Parse Top Level Domain from URL
DROP FUNCTION IF EXISTS getTopLevelDomain;
DELIMITER ##
CREATE FUNCTION getTopLevelDomain (strURL varchar(1000), level tinyint)
RETURNS varchar(1000)
BEGIN
IF ISNULL(level) THEN
SET level = 2;
END IF;
IF POSITION('http://' IN strURL) > 0 OR POSITION('https://' IN strURL) > 0
THEN
@m1roff
m1roff / enumMethods.groovy
Last active February 20, 2022 19:17
PhpStorm. LiveTemlate. Generate comments for ENUM
File inputFile = new File(_1);LineNumberReader reader = inputFile.newReader();
def outputLine = '';
while ((line = reader.readLine()) != null) {
def cleanLine = line.trim();
def m = cleanLine =~ /private const\\\s(.*)\\\s=/;
if (m.size() > 0) {
outputLine = outputLine + ' * @method static ' + _2 + ' ' + m[0][1] + '''()\n''';
};
};
return outputLine + '';
@m1roff
m1roff / main.php
Created November 2, 2023 20:55
Labeling: PHP-Script-to-Iterate-Over-Days-of-Month-with-German-Names
<?php
$forMonth = '2023-11-01';
$months = [
1 => 'Янв', 2 => 'Фев', 3 => 'Мар', 4 => 'Апр',
5 => 'Май', 6 => 'Июн', 7 => 'Июл', 8 => 'Авг',
9 => 'Сен', 10 => 'Окт', 11 => 'Ноя', 12 => 'Дек'
];
@m1roff
m1roff / convert.sh
Created January 15, 2024 14:58
Creating PDF from images with OCR
#!/bin/bash
# Creating PDF from images with OCR
#
# brew install tesseract tesseract-lang pdftk-java
#
mkdir -p pdf_output
for file in $(ls RU_*.jpg | awk -F'[_\.]' '{ printf "%s\t%s\n", $2, $0 }' | sort -k1,1n | cut -f2-); do