Skip to content

Instantly share code, notes, and snippets.

View techouse's full-sized avatar
🏔️

Klemen Tusar techouse

🏔️
View GitHub Profile
@techouse
techouse / difm.pl
Last active June 16, 2016 15:57
Super lean DI.FM player for *nix
#!/usr/bin/env perl
use warnings;
use strict;
use autodie;
use LWP::UserAgent;
use JSON;
use DBIx::Simple;
use Text::Table;
my $mplayer = `/usr/bin/which mplayer 2>&1`;
@techouse
techouse / sqlite3mysql.py
Last active May 29, 2023 13:37
A simple Python 3 script to transfer the data from SQLite 3 to MySQL. Requires MySQL Connector/Python 2.0.4 or higher.
#!/usr/bin/env python3
import logging
import sqlite3
import sys
import re
from math import ceil
from os.path import realpath, isfile
import mysql.connector
from mysql.connector import errorcode
@techouse
techouse / send_mail.py
Last active February 22, 2017 13:44
Since sendmail wasn't enough for me, I wrote a simple Python script that can send emails directly from a terminal shell. Requires the validators package (https://pypi.python.org/pypi/validators/).
#!/usr/bin/env python3
__author__ = "Klemen Tušar"
__email__ = "techouse@gmail.com"
__copyright__ = "GPL"
__version__ = "1.0.2"
__date__ = "2017-02-22"
__status__ = "Production"
import os, smtplib, validators
@techouse
techouse / insultme.sh
Last active July 3, 2017 13:44
Make your Linux distro verbally insult you.
#!/bin/sh
# This script will give you a random English insult pulled from the url below.
# Evil hint: set up a cronjob :D
curl -s 'http://www.hyperhero.com/en/insults.htm' |
awk '/BEGINN INSULTS/ { show=1; next } /END INSULTS/ { show=0 } show' |
grep -oPi '^.*<br>' |
sed 's/<br>//' |
shuf -n 1 |
@techouse
techouse / psky.sh
Last active November 8, 2016 10:19
Protected SKY IP checker. Check if the given IP is blacklisted via http://psky.me/
#!/bin/sh
if [[ -z $1 ]] ; then
echo "psky.sh <IP>"
echo ""
echo "Protected SKY IP checker"
echo "Check if the given IP is blacklisted"
echo ""
return 1;
fi
REVERSE=$(echo $1 | awk -F '.' '{ print $4 "." $3 "." $2 "." $1 }')
@techouse
techouse / iptables_countryban.pl
Last active July 8, 2022 01:05
Ban whole countries with iptables and Perl. I wrote this script cause modern software like ipset doesn't work and/or exist on older machines running CentOS/RHEL 5
#!/usr/bin/env perl
use strict;
use warnings;
use LWP::Simple;
use File::Basename;
use IO::File;
my $debug = 0;
my $restore = defined $ARGV[0] && $ARGV[0] eq '--restore' ? 1 : 0; # optional --restore command line argument
my $config_file = dirname(__FILE__) . '/iptables_configuration.txt';
@techouse
techouse / blacklist.py
Created January 6, 2017 11:27
Add a set of IPs to an ipset. Requires RHEL/CentOS/Fedora Linux, FirewallD and IPset.
#!/usr/bin/env python3
__author__ = "Klemen Tušar"
__email__ = "techouse@gmail.com"
__copyright__ = "GPL"
__version__ = "1.0.2"
__date__ = "2017-01-06"
__status__ = "Production"
import re, subprocess
@techouse
techouse / php_depcheck.pl
Last active January 18, 2017 08:54
Detect deprecated PHP functions based on a list of functions in CSV format, like this one https://da.gd/CupI (save it as depcheck.csv in the same folder as this Perl sript)
#!/usr/bin/env perl
use warnings;
use strict;
use utf8;
use IO::File;
use IO::Handle;
use File::Find::Rule;
use File::Spec;
use Text::CSV_XS;
use Cwd qw(abs_path);
@techouse
techouse / InsertIgnore.php
Created July 3, 2017 13:29
insertIgnore
<?php
namespace App;
trait InsertIgnore
{
/**
* @param array $attributes
*
* @return static
@techouse
techouse / weekOfMonth.js
Created March 19, 2019 15:51
Get the week of month using date-fns
import {
differenceInDays,
startOfMonth,
startOfWeek,
getDate
} from 'date-fns'
const weekOfMonth = function (date) {
const firstDayOfMonth = startOfMonth(date)
const firstDayOfWeek = startOfWeek(firstDayOfMonth)