Skip to content

Instantly share code, notes, and snippets.

@arlaneenalra
arlaneenalra / procSize.sh
Created November 15, 2013 13:33
Calculate the average RSS size, total RSS size, and number of a given set of processes and display the results once a second.
#!/bin/sh
while (true) ; do clear; ps aux | grep apache | grep -v grep | awk '{sum+=$6} END {print "Total Size = ", sum; print "Averae Size = ", sum/NR; print "Number Of Processes = ", NR}'; sleep 1; done
@arlaneenalra
arlaneenalra / array_splice.php
Last active December 28, 2015 06:29
A crude array_splice that preserves keys.
<?php
function array_splice_preserve ($input, $offset, $length, $replacement) {
$keys = array_keys($input);
$values = array_values($input);
array_splice($keys, $offset, $length, array_keys($replacement));
array_splice($values, $offset, $length, array_values($replacement));
return array_combine($keys, $values);
};