Skip to content

Instantly share code, notes, and snippets.

@sokratisg
sokratisg / sysctl.conf
Last active January 5, 2024 00:03
Tuned sysctl.conf for use by CentOS/RHEL 6.x or later
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Turn on execshield
# 0 completely disables ExecShield and Address Space Layout Randomization
# 1 enables them ONLY if the application bits for these protections are set to “enable”
# 2 enables them by default, except if the application bits are set to “disable”
# 3 enables them always, whatever the application bits
@sokratisg
sokratisg / pdns-pipebackend.py
Created April 7, 2014 22:38
PowerDNS PipeBackend python example
#!/usr/bin/python -u
import sys, os, time
import random
class DNSLookup(object):
"""Handle PowerDNS pipe-backend domain name lookups."""
ttl = 30
@sokratisg
sokratisg / permissions.sql
Created June 13, 2014 10:26
MySQL permissions for Backup Admin
CREATE USER 'backupadmin'@'localhost' IDENTIFIED BY '<secret_password>';
GRANT LOCK TABLES, SELECT ON <DB_NAME>.* TO 'backupadmin'@'localhost';
GRANT RELOAD ON *.* TO 'backupadmin'@'localhost';
GRANT CREATE, INSERT, DROP ON mysql.ibbackup_binlog_marker TO 'backupadmin'@'localhost';
GRANT CREATE, INSERT, DROP ON mysql.backup_progress TO 'backupadmin'@'localhost';
GRANT CREATE, INSERT, SELECT, DROP ON mysql.backup_history TO 'backupadmin'@'localhost';
GRANT REPLICATION CLIENT ON *.* TO 'backupadmin'@'localhost';
GRANT SUPER ON *.* TO 'backupadmin'@'localhost';
GRANT CREATE TEMPORARY TABLES ON mysql.* TO 'backupadmin'@'localhost';
FLUSH PRIVILEGES;
[uwsgi]
project = matterllo
base = /home/bots
chdir = %(base)/%(project)
home = %(base)/pyenv/%(project)
module=run:app
die-on-term = true
master = true
processes = 1
threads = 2
@sokratisg
sokratisg / cdpinfo.pl
Created June 19, 2014 09:44
listen & print Cisco CDP through tcpdump or snoop
#!/usr/bin/perl -w
#
# Listen for Cisco Discovery Protocol (CDP) packets
# and print out key values such as switch, port and vlan.
#
# This script depends on either "snoop" (Solaris) or
# "tcpdump" (Linux, AIX, and others). Both of those programs generally
# must be run as root.
#
# It has been tested on Solaris 10 and Linux (CentOS, Ubuntu)
@sokratisg
sokratisg / Postfix: sender-dependent SASL authentication.md
Created April 24, 2017 10:35 — forked from zmwangx/Postfix: sender-dependent SASL authentication.md
Postfix: sender-dependent SASL authentication — relay to multiple SMTP hosts, or relay to the same host but authenticate as different users (e.g., two Gmail accounts)

This is a sequel to "Postfix: relay to authenticated SMTP".

I would like to send mail from two different Gmail accounts using Postfix. Here is the relevant section in the Postfix documentation: Configuring Sender-Dependent SASL authentication.

As a concrete example, here's how to set up two Gmail accounts (only relevant sections of the config files are listed below):

/etc/postfix/main.cf:
    # sender-dependent sasl authentication
    smtp_sender_dependent_authentication = yes

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay

description "uWSGI application server in Emperor mode"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid bots
setgid www-data
exec /usr/local/bin/uwsgi --emperor --emperor-nofollow /etc/uwsgi/apps
@sokratisg
sokratisg / gist:7894195
Created December 10, 2013 17:07
json_decode example
<?php
$json = '{"image_intro":"storage\/images\/media\/fotografies\/thumbnail.jpg","float_intro":"","image_intro_alt":"fragkoul
$obj = json_decode($json);
echo $obj->{'image_intro'} . '<br>';
?>
@sokratisg
sokratisg / vimrc
Created September 13, 2014 22:15
vim-enhanced configuration
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
@sokratisg
sokratisg / wp_update_content.sql
Created May 24, 2015 21:52
WP convert http to https
UPDATE wp_posts
SET post_content = ( Replace (post_content, 'src="http://', 'src="//') )
WHERE Instr(post_content, 'jpeg') > 0
OR Instr(post_content, 'jpg') > 0
OR Instr(post_content, 'gif') > 0
OR Instr(post_content, 'png') > 0;
UPDATE wp_posts
SET post_content = ( Replace (post_content, "src='http://", "src='//") )
WHERE Instr(post_content, 'jpeg') > 0