Skip to content

Instantly share code, notes, and snippets.

@flores
flores / deleteemails_matcheslist.pl
Created March 4, 2011 00:22
Dirty: Sometimes postfix has a shitton of messages and you want to delete everything going to a (newline separated) blacklist. (Perl)
#!/usr/bin/perl -w
die "usage $0 <path to email list>\n" unless @ARGV;
my $file=$ARGV[0];
my @queue=`postqueue -p |grep -v ^- |awk 'BEGIN{RS="\\n\\n"} ; {print \$1"\t"\$NF}'`;
my @list_users=`cat $file`;
@flores
flores / email_deleteifNOTmatcheslist.rb
Created March 4, 2011 00:24
Dirty: Sometimes postfix has a shitton of messages and you want to delete everything EXCEPT stuff going to a (newline) separated whitelist. (Ruby)
#!/usr/bin/ruby
raise "usage #{$0} <path to email list>\n" unless ARGV.count > 0;
file=ARGV[0];
# postqueue -p prints the existing postfix queue
# this awk was just a cheap way to regex using its record separator for multiple newlines.
queue=`postqueue -p |grep -v ^- |awk 'BEGIN{RS="\\n\\n"} ; {print \$1"\t"\$NF}'`;
@flores
flores / gist:855854
Created March 4, 2011 22:45
SendGrid API check & wrapper to see if critical addresses have been accidentally unsubscribed
#!/usr/bin/perl
use LWP::UserAgent;
# the junk you may need to change
my @importantusers = qw( sales customersupport support and_any_other_critical_address );
my @importantdomains = qw( someimportantdomain.com somevanitydomain.com whatever.com );
my $api_user = 'username';
my $api_key = 'password';
@flores
flores / Use sed to reduce known_hosts pain
Created March 15, 2011 06:33
Use sed to reduce known_hosts pain
### The pain after a host is updated:
lo@padlet:~/someproject$ git pull
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for repo.somedomain.com has changed,
and the key for the corresponding IP address x.x.x.x
is unchanged. This could either mean that
DNS SPOOFING is happening or the IP address for the host
l:~/agent-plugins# ./log_freshness.py
Usage: ./log_freshness.py <log file to check>
l:~/agent-plugins# ./log_freshness.py /var/log/apache2/access.log
status ok everything looks good, modified 163 seconds ago
l:~/agent-plugins# ./log_freshness.py /var/log/apache2/error.log
status err /var/log/apache2/error.log not modified in 2745 seconds
@flores
flores / gist:904958
Created April 6, 2011 01:29
haproxyctl "enable/disable all EXCEPT <server>"
l:~/haproxyctl# ./haproxyctl "show health"
# pxname svname status weight
http FRONTEND OPEN
sinatra sinatra_downoi DOWN 1
sinatra sinatra_rindica DOWN 1
sinatra sinatra_guinea UP 1
sinatra BACKEND UP 1
ei guinea UP 1
ei BACKEND UP 1
drop guinea UP 1
alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
alias b='sudo'
alias white='aterm -fg black -bg white +sb &'
alias x='startxfce4'
alias compiz='SKIP_CHECKS=yes LIBGL_ALWAYS_INDIRECT=1 INTEL_BATCH=1 compiz --replace --indirect-rendering &'
@flores
flores / gist:918333
Created April 13, 2011 20:29
s3cmd little demo for @blovett
Commands:
Make bucket
s3cmd mb s3://BUCKET
Remove bucket
s3cmd rb s3://BUCKET
List objects or buckets
s3cmd ls [s3://BUCKET[/PREFIX]]
List all object in all buckets
s3cmd la
Put file into bucket
@flores
flores / gist:920984
Created April 15, 2011 01:54
blueprint make clean removes man files, breaks subsequent install
For ticket...
lo@puter:~/blueprint$ make clean
rm -f \
control \
blueprint/**.pyc \
man/man*/*.[12345678] man/man*/*.html
lo@puter:~/blueprint$ make
make: Nothing to be done for `all'.
@flores
flores / JSON from SQL
Created April 26, 2011 21:57
SQL concat into JSON
SELECT CONCAT(
CONCAT("{'key':",column1,","),
CONCAT("'field2name':",column2,","),
CONCAT("'field3name'",column3,"}")
) FROM table