rubysecurity.org

Cloud Architect / DevOps Engineer / SRE / Developer | /root

Home About Books Blog Portfolio Archive

Tag Cloud


Currently Reading

Certified Kubernetes Administrator (CKA) Study Guide
Certified Kubernetes Administrator (CKA) Study Guide
38 / 155 Pages


Latest Book Reviews

Latest Posts


December 22, 2012

PHP memory_limit stress testing

by Alpha01

I wrote this code a couple of years ago that I found it was very useful when I was troubleshooting PHP memory limit settings. The script essentially creates one huge array until it runs out of memory.

<?php
ini_set('display_errors', true);
 
while (1) {
        echo 'Hello' . nl2br("\n");
        $array = array(1,2);
        while(1) {
                $tmp = $array;
                $array = array_merge($array, $tmp);
                echo memory_get_usage() . nl2br("\n");
                flush();
                sleep(1);
        }
}
?>
Tags: [ php apache ]
December 18, 2012

Finding the number of files inside a subdirectory

by Alpha01

for i in `ls .`; do echo $i; ls -laR $i| grep -v ^[.dlt] | grep -v ^$ | wc -l; echo "--------------------" ; done
Tags: [ bash ]
December 18, 2012

Setting phpMyAdmin to display a single database

by Alpha01

Edit config.inc.php

$cfg['Servers'][$i]['only_db'] = 'databasename';
Tags: [ php mysql ]
December 17, 2012

Creating a loopback file system for testing purposes

by Alpha01

Using the all mighty dd tool, this example the block size is 1024 bytes and a total of 5000 blocks:

dd if=/dev/zero of=/tmp/temploopbackimage.img bs=1024 count=5000

Associate the image file to the loopback device

losetup /dev/loop3 /tmp/temploopbackimage.img

Now you should be able to format /dev/loop3

Tags: [ testing ]
December 11, 2012

Flush DNS cache in Mac OS X

by Alpha01

Mountain Lion and Lion

sudo killall -HUP mDNSResponder

Snow Leopard

sudo dscacheutil -flushcache
Tags: [ macos networking ]