Skip to content

Instantly share code, notes, and snippets.

@ajpaulson
ajpaulson / gist:18c8897f96d3d4e424a341f3399c06fa
Created July 10, 2017 13:59
Match staged files that aren't deletions under; /path/.yml, /foo/path/.yml, /foo/bar/path/*.yml etc
git grep --cached <SEARCH STRING> -- **/<PATH>/**.yml
@ajpaulson
ajpaulson / pip-in-code.py
Created June 3, 2016 09:21
use pip to install packages from within code/repl
import pip
def install(package):
pip.main(['install', package])
# Example
if __name__ == '__main__':
install('argh')
@ajpaulson
ajpaulson / hubot-bb.coffee
Last active March 30, 2016 15:33
Hubot bitbucket script - announces pushes in a channel/room
# Description:
# Announce bitbucket pushes to a room.
#
# Example Bitbucket webhook:
# http://hubot.example.com/botbucket?room=<room|channel_id>
#
# based on "bitbucket.coffee" by JRusbatch
#
# Extended by ajpaulson
module.exports = (robot) ->
@ajpaulson
ajpaulson / MalwareIPs
Created February 3, 2016 09:53
A list of IPs known to host Linux Malware.
202.102.200.101
58.242.2.2
202.38.64.1
211.91.88.129
211.138.180.2
218.104.78.2
202.102.199.68
202.175.3.3
202.175.3.8
202.112.144.30
http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming
http://bencane.com/2013/02/25/10-nmap-commands-every-sysadmin-should-know/
http://railsware.com/blog/2014/08/11/git-housekeeping-tutorial-clean-up-outdated-branches-in-local-and-remote-repositories/
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
http://jvns.ca/blog/2016/03/16/tcpdump-is-amazing/
http://2048.fi/awk.txt
@ajpaulson
ajpaulson / processkill.sql
Created December 2, 2015 09:51
Mysql processlist -> kill list method.
select concat('KILL ',id,';') from information_schema.processlist
where user='root' and time > 200 into outfile '/tmp/a.txt';
source /tmp/a.txt;
@ajpaulson
ajpaulson / replace-column.awk
Created October 21, 2015 09:54
Awk one-liner to read first column of a file and use those strings to replace the 15th column in a second file
awk -F, 'NR==FNR{a[NR]=$0;next} {$15=a[FNR]}1' OFS=, listofcorrect.txt replacemy15thcolumn.csv > output.csv
@ajpaulson
ajpaulson / count_em.sh
Created June 25, 2015 08:12
When you run out of inodes
#!/bin/bash
# count_em - count files in all subdirectories under current directory.
echo 'echo $(ls -a "$1" | wc -l) $1' >/tmp/count_em_$$
chmod 700 /tmp/count_em_$$
find . -mount -type d -print0 | xargs -0 -n1 /tmp/count_em_$$ | sort -n
rm -f /tmp/count_em_$$
@ajpaulson
ajpaulson / virtualhost.conf
Created May 29, 2015 08:47
Basic Apache Vhost
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin [email protected]
DocumentRoot /var/www/domain.com/
<Directory /var/www/domain.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
@ajpaulson
ajpaulson / update (create or delete) git hook
Created March 2, 2015 18:09
Git update Hook to test for creation or deletion
#!/usr/bin/env bash
# a null ref will have a hash consisting of 40 0s
n=0
zero=$(printf "%040d" $n)
# Update hooks take 3 args: refname, oldrev, and newrev
# --- Command line
refname="$1"
oldrev="$2"