Skip to content

Instantly share code, notes, and snippets.

View ddmitov's full-sized avatar

Dimitar D. Mitov ddmitov

View GitHub Profile
@ddmitov
ddmitov / sqlite-triggers.sql
Created August 5, 2014 09:43
Example SQLite triggers
CREATE TRIGGER calculate_vat_new AFTER INSERT ON inventory
BEGIN
UPDATE inventory SET PRICE_VAT = new.PRICE/100*20+new.PRICE WHERE id = new.id;
END;
CREATE TRIGGER calculate_vat UPDATE OF PRICE ON inventory
BEGIN
UPDATE inventory SET PRICE_VAT = new.PRICE/100*20+new.PRICE WHERE id = old.id;
END;
@ddmitov
ddmitov / jpg-resizer.pl
Created March 20, 2016 08:22
Simple resizer for multiple JPG images based on the 'convert' binary from ImageMagick. Full path to a directory containing JPG files is the first and only command line argument needed. Original files are not overwritten! Resized images are saved in a subfolder.
#!/usr/bin/perl -w
use strict;
use warnings;
my $FOLDER_TO_OPEN = $ARGV[0];
opendir (my $directory_handle, $FOLDER_TO_OPEN) or die $!;
my $output_directory_name = "converted-images";
@ddmitov
ddmitov / opera-session-converter.sh
Last active June 25, 2017 20:21
Opera Session Converter, v.0.1 will convert all your Opera session files in the current folder to plain text files with URLs only."
#!/usr/bin/env bash
# Welcome message:
echo " "
echo "Opera Session Converter, v.0.1."
echo "Will convert all your Opera session files in the current folder to"
echo "plain text files with URLs only."
echo "Old files will be preserved and new files with"
echo "a .win.txt extension will be created."
echo "Input files must be without spaces!"
@ddmitov
ddmitov / sshexec.pl
Created August 16, 2018 11:37
Execute remote commands using Perl5, Net::OpenSSH and a private key
#!/usr/bin/perl
use Net::OpenSSH;
my $ssh = Net::OpenSSH->new('root@server.domain.name', key_path => '/path/to/private_key');
$ssh->error and die "Couldn't establish SSH connection: ".$ssh->error;
my ($stdin, $stdout, $stderr, $pid) = $ssh->open3("ls -l");
my @output = <$stdout>;
@ddmitov
ddmitov / check-urls.py
Last active October 6, 2018 18:34
Simple Python URL Tester for my Markdown files
#! /usr/bin/python
###############################################################################
# URL Tester
# Version 0.2
#
# Usage:
# python check-urls.py CREDITS.md
#
# CREDITS
@ddmitov
ddmitov / turtle-chessboard.py
Last active May 28, 2020 20:02
Implementation of the famous Python Turtle Chessboard task
#!/usr/bin/python3
# Turtle Chessboard v.1.0
# by Dimitar D. Mitov
# https://github.com/ddmitov
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
@ddmitov
ddmitov / initials-maker.py
Last active August 28, 2020 20:33
Extracts Initials from any name that can be written in Latin letters
#!/usr/bin/python3
# Initials Maker v.1.0
# by Dimitar D. Mitov
# https://github.com/ddmitov
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
@ddmitov
ddmitov / selenium.py
Created August 29, 2020 10:47
Minimal testing script for the Selenium Python package
#!/usr/bin/python3
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--window-size=1920x1080')
import os
import json
def lambda_handler(event, context):
json_region = os.environ['AWS_REGION']
return {
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
#!/usr/bin/env python3
# Snake Works 2020.
# https://github.com/ddmitov/
#
# /^\/^\
# _| O| O|
# \/ / \_/\_/ \
# \____|____ \
# \_______ \ ______