Skip to content

Instantly share code, notes, and snippets.

GIT_SSH_COMMAND='ssh -i private_key_file' git clone host:repo.git
@maintux
maintux / osx_launchd_wrapper
Created May 12, 2016 08:14
wrapper for launchd
#! /bin/bash
command=$2
sudo=""
case "$1" in
nginx)
service=/Library/LaunchDaemons/homebrew.mxcl.nginx.plist
sudo="sudo "
;;
@maintux
maintux / redis_smtp_scheduler.rb
Created September 28, 2015 12:15
redis_smtp_scheduler.rb
require 'rubygems'
require 'redis'
r = Redis.new(:host => "127.0.0.1", :port => 6379, :db => 5)
r.multi do
r.del 'smtp_servers'
r.del 'smtp_servers_conf'
r.rpush 'smtp_servers', 11
r.rpush 'smtp_servers', 12
@maintux
maintux / clean_postfix_queue.rb
Created July 30, 2015 09:31
Clean messages from postfix queue older than 8 hours
#!/usr/bin/env ruby
# /usr/bin/clean_postfix_queue.rb
# */10 * * * * /usr/bin/clean_postfix_queue.rb
require 'time'
IO.popen("/usr/sbin/postqueue -p") do |readme|
readme.each do |line|
q_id = nil
if line =~ /^(\w+)(\*|\!)?\s/
q_id = $1
end
@maintux
maintux / backup_mongo
Last active January 7, 2017 12:08
Backup MongoDB on AWS S3
#!/bin/bash
TIMESTAMP=$(date +%F-%H%M)
MONGODUMP_PATH="/usr/bin/mongodump"
S3CMD_PATH="/usr/bin/s3cmd"
MONGO_DATABASES=$(echo "show dbs" | mongo | cut -d' ' -f1 | tail -n +3 | head -n -1)
S3_BUCKET="backup"
BACKUPS_DIR="/backups"
mkdir -p $BACKUPS_DIR
chmod 777 $BACKUPS_DIR
@maintux
maintux / gist:6213709
Created August 12, 2013 18:39
Trick to add empty directories to git
for i in `find . -type d -empty`; do touch $i/.gitignore; done
@maintux
maintux / update_wordpress_domain.sql
Created December 14, 2012 19:06
SQL snippet to update wordpress domain
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');