Skip to content

Instantly share code, notes, and snippets.

View amr's full-sized avatar

Amr Youssef amr

  • Affirm
  • San Francisco, CA
View GitHub Profile
@amr
amr / convert-security-defs.py
Created September 3, 2012 11:39
SS2 Security Permissions Defs to SS3 intercept-url tag
#!/usr/bin/env python
def is_comment(line):
return line.startswith('<!--')
def is_empty(line):
return len(line) == 0
if __name__ == '__main__':
f = open('/tmp/definitions.txt', 'r')
@amr
amr / avg-apache-process.sh
Created May 11, 2011 10:11
Tells you the average size of your Apache processes
#!/bin/bash
#
# Tells you the average size of your Apache processes
# It must run on a live apache server (unless you know what you are doing).
# It requires pmap, /proc, ps, grep, awk, sed and bc,
#
# Written by: Amr Mostafa" <amr.mostafa@egyptdc.com>
#
# Courtesy of Egypt Development Centre (c).
@amr
amr / find-futex-wait.sh
Created November 30, 2010 18:37
Find processes executing futex with FUTEX_WAIT (helps find deadlock-ed processes)
#!/bin/bash
#
# Find all processes that are executing a futex(2) call with op=FUTEX_WAIT
# In some cases this can be helpful in finding deadlock-ed processes.
#
test ! $UID -eq 0 && echo -e "WARNING: Not running as root, only processes for this user are being scanned\n" >&2;
pids=$(ps -u $UID -opid --no-headers)
for pid in $pids; do
<?php
/**
* @file
* Retrieves various load indicators from servers using SNMP.
*
* Licensed under GPL v3 or later.
* Copyright 2009 (c) Egypt Development Center.
*/
/**
#!/bin/bash
SLEEP=1
THRESHOLD=500
while [ 1 ]
do
threads=`mysqladmin stat | awk '{ print $4 }'`
echo "Active threads: $threads"
if [ $threads -gt $THRESHOLD ]; then
log="/root/mysql-monitor/logs/sqls-$threads-`date +%s`.log"
#!/bin/sh
#
# Shuffles given playlist outside mplayer instead of using -shuffle
#
# Usage:
#
# mplayer-shuffle-playlist <playlist-file> [mplayer-options] ...
#
PLAYLIST=$(mktemp mplayer-shuffle-playlist.XXXXX)
<?php
$regex = '#^\\{\\|(.*?)(?:^\\|\\+(.*?))?(^(?:((?R))|.)*?)^\\|}#msi';
$source = "==GUIDE TO UNITED NATIONS HUMAN RIGHTS MACHINERY==
{| border=1
|'''remit'''
|International
Covenant on Civil and Political Rights (ICCPR)
· periodic reports every 5
#!/bin/bash
# Print average apache process size
# Licensed under GPL v3 or later
#
# =| USAGE |===================================================================
#
# echo <apache-parent-process-id> | ./apache_avg_procsize.sh
#
# On Debian this translates to:
#