Skip to content

Instantly share code, notes, and snippets.

View islander's full-sized avatar

kiba islander

  • Innova Distribution
  • Moscow | Saint Petersburg
View GitHub Profile
@islander
islander / gist:631e9ca9b4d1c6443332
Created August 26, 2015 04:34
Python MySQL driver installation
apt-get install python-dev
apt-get install libmysqlclient-dev # libmariadbclient-dev
pip install MySQL-python
#!/usr/bin/expect
eval spawn -noecho $argv
interact {
\177 {send "\010"}
"\033\[3~" {send "\177"}
}
@islander
islander / ssh_config
Created June 11, 2014 04:58
proxy ssh connection through NAT
Host external.example.com
Hostname 198.51.100.32
User external_login
Host internal.example.com
Hostname 192.168.2.18
User internal_login
ProxyCommand ssh 198.51.100.32 nc %h %p
#!/bin/sh
# http://christoph-polcin.com/
TMP=/tmp
[ $# -lt 1 ] && \
echo "usage: $(basename $0) input_file [output.pdf]" && \
exit 1
[ ! -f "$1" ] && \
@islander
islander / dnsmasq.conf
Created August 25, 2015 01:08
SIP-phone configuration over DHCP (TFTP)
listen-address=192.168.1.254
interface=eth0
dhcp-range=192.168.1.1,192.168.1.253,12h
dhcp-option=150,192.168.1.254 # TFTP Server Address Option for DHCPv4 (RFC 5859)
address=/example.com/192.168.1.254
@islander
islander / month_range.py
Created September 9, 2015 07:12
Get the start and end date for the month
import datetime
import calendar
def get_month_day_range(date):
"""
For a date 'date' returns the start and end date for the month of 'date'.
Month with 31 days:
>>> date = datetime.date(2011, 7, 27)
>>> get_month_day_range(date)
@islander
islander / mysql_fast_drop_table.sql
Created October 15, 2015 04:44
MySQL fast drop big table
CREATE TABLE new_foo LIKE foo;
ALTER TABLE new_foo AUTO_INCREMENT = 1;
RENAME TABLE foo TO old_foo, new_foo TO foo;
DROP TABLE old_foo;
-A FORWARD -m string --string "BitTorrent" --algo bm --to 65535 -j DROP
-A FORWARD -m string --string "BitTorrent protocol" --algo bm --to 65535 -j DROP
-A FORWARD -m string --string "peer_id=" --algo bm --to 65535 -j DROP
-A FORWARD -m string --string ".torrent" --algo bm --to 65535 -j DROP
-A FORWARD -m string --string "announce.php?passkey=" --algo bm --to 65535 -j DROP
-A FORWARD -m string --string "torrent" --algo bm --to 65535 -j DROP
-A FORWARD -m string --string "announce" --algo bm --to 65535 -j DROP
-A FORWARD -m string --string "info_hash" --algo bm --to 65535 -j DROP
@islander
islander / fix_russian_sounds.sh
Created November 18, 2015 04:30
Fix russian language voicemail prompts for asterisk 11 in Ubuntu 14.04
#!/bin/sh
SOUNDS_DIR="/usr/share/asterisk/sounds/ru"
mkdir -p ${SOUNDS_DIR}
wget -q --no-check-certificate https://github.com/pbxware/asterisk-sounds/tarball/master -O- \
| tar xzv --strip-components 1 -C ${SOUNDS_DIR}
wget -q --no-check-certificate https://github.com/pbxware/asterisk-sounds-additional/tarball/master -O- \
| tar xzv --strip-components 1 -C ${SOUNDS_DIR}
@islander
islander / gist:e21555396045ee07eacd
Created November 24, 2015 02:33
Debian Jessie enable persistent journald
mkdir /var/log/journal
chgrp systemd-journal /var/log/journal
chmod 2755 /var/log/journal