This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create db - if it doesnt exist, and setup user ready to | |
# read and write | |
# | |
# Usage: db-user-setup.sh <database> <user> <password> | |
EXPECTED_ARGS=3 | |
E_BADARGS=65 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim /etc/yum.repos.d/centos.repo | |
# | |
# Adding the following contents, note the ‘5’ has to be hardcoded to either 5 or 6 depending on your RHEL version. | |
# | |
[centos] | |
name=CentOS $releasever - $basearch | |
baseurl=http://ftp.heanet.ie/pub/centos/5/os/$basearch/ | |
enabled=1 | |
gpgcheck=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tail -f /var/run/mysqld/mysqld.log | grep 'insert' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get Table Sizes | |
SELECT NOW(), | |
TABLE_SCHEMA, | |
TABLE_NAME, | |
ENGINE, | |
TABLE_ROWS, | |
DATA_LENGTH / 1024 / 1024, | |
INDEX_LENGTH / 1024 / 1024, | |
DATA_FREE, | |
AUTO_INCREMENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
watch -n 1 --differences "mysql -u mon -e 'show processlist' | grep -v Sleep" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
foreach $key (keys(%ENV)) { | |
printf("%-30.30s: $ENV{$key}\n", $key); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Replace filenames found in code and create a backup of original | |
find . -type f \( -name "*.php" -or -name "*.jpg" \) -exec bash -c 'gsed -i.bak "s/(\W`basename {}`\W/)`basename {}`/Ig"/src/ *' \; | |
######################## | |
# Explanation | |
# find | |
# . : Recursively from current directory, | |
# -type f : files only - not folders, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
# Determine Context | |
use constant IS_MOD_PERL => exists $ENV{'MOD_PERL'}; | |
use constant IS_PSGI => exists $ENV{'psgi.version'}; | |
use constant IS_CGI => IS_MOD_PERL || IS_PSGI || exists $ENV{'GATEWAY_INTERFACE'}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
# import LOCK_* and SEEK_END constants | |
use Fcntl qw(:flock SEEK_END); | |
# Open the file | |
open(my $xml, ">>", "sample.xml") or die "Can't open xml $!"; | |
# Lock the file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use feature qw/say/; | |
use POSIX qw(strftime tzset); | |
say strftime("%Y %d %m %H:%M:%S GMT", gmtime(time)); # GMT | |
say strftime("%Y %d %m %H:%M:%S %Z", localtime(time)); # Local Time | |
# Set to custom timezone | |
$ENV{TZ} = 'America/Los_Angeles'; | |
tzset; |