Skip to content

Instantly share code, notes, and snippets.

🏔
Seeking enlightenment

Klemen Tušar techouse

🏔
Seeking enlightenment
Block or report user

Report or block techouse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@techouse
techouse / timemachine_exclude_dev_dirs.sh
Last active Sep 17, 2019
Instruct Time Machine to exclude some development directories
View timemachine_exclude_dev_dirs.sh
#!/usr/bin/env bash
# This simple bash script is aimed at excluding some development specific directories.
#
# In this configuration it will instruct Time Machine to exclude directories named:
# - env
# - node_modules
# - vendor
# - venv
#
@techouse
techouse / weekOfMonth.js
Created Mar 19, 2019
Get the week of month using date-fns
View weekOfMonth.js
import {
differenceInDays,
startOfMonth,
startOfWeek,
getDate
} from 'date-fns'
const weekOfMonth = function (date) {
const firstDayOfMonth = startOfMonth(date)
const firstDayOfWeek = startOfWeek(firstDayOfMonth)
View InsertIgnore.php
<?php
namespace App;
trait InsertIgnore
{
/**
* @param array $attributes
*
* @return static
@techouse
techouse / php_depcheck.pl
Last active Jan 18, 2017
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)
View php_depcheck.pl
#!/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 / blacklist.py
Created Jan 6, 2017
Add a set of IPs to an ipset. Requires RHEL/CentOS/Fedora Linux, FirewallD and IPset.
View blacklist.py
#!/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 / iptables_countryban.pl
Last active Nov 21, 2016
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
View iptables_countryban.pl
#!/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 / psky.sh
Last active Nov 8, 2016
Protected SKY IP checker. Check if the given IP is blacklisted via http://psky.me/
View psky.sh
#!/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 / insultme.sh
Last active Jul 3, 2017
Make your Linux distro verbally insult you.
View insultme.sh
#!/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 / send_mail.py
Last active Feb 22, 2017
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/).
View send_mail.py
#!/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 / sqlite3mysql.py
Last active Jun 24, 2019
A simple Python 3 script to transfer the data from SQLite 3 to MySQL. Requires MySQL Connector/Python 2.0.4 or higher.
View sqlite3mysql.py
#!/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
You can’t perform that action at this time.