Skip to content

Instantly share code, notes, and snippets.

View agarzon's full-sized avatar
🕶️
Hunting bugs....

AG agarzon

🕶️
Hunting bugs....
  • Zend Certified Engineer
  • Canada, Montreal
View GitHub Profile
@agarzon
agarzon / googleize.sh
Created October 24, 2014 21:44
Automatically set up the Plesk DNS to work with Google Apps in a domain
#!/bin/bash
if [ -z "$1" ]
then
echo "Please provide a domain name as argument"
exit 1
fi
DOMAIN=$1
IP=`dig +short A $DOMAIN`
@agarzon
agarzon / dnsBulk.sh
Created October 6, 2014 21:15
Plesk, DNS Bulk Apply Settings
#!/bin/sh
ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk '{print $2}'`
PRODUCT_ROOT_D=`grep PRODUCT_ROOT_D /etc/psa/psa.conf | awk '{print $2}'`
mysql="${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa"
query="select name from domains;"
domains=`echo $query | $mysql `
@agarzon
agarzon / DbHelper.php
Last active January 1, 2022 08:49
Codeception DB helper to extend database functionalities (update & delete)
<?php
namespace Codeception\Module;
/**
* Additional methods for DB module
*
* Save this file as DbHelper.php in _support folder
* Enable DbHelper in your suite.yml file
* Execute `codeception build` to integrate this class in your codeception
*/
@agarzon
agarzon / myip.sh
Created July 18, 2014 18:43
The fastest way to find your own public IP
dig +short myip.opendns.com @resolver1.opendns.com
@agarzon
agarzon / calendar.php
Last active September 4, 2017 20:39
Calendar generator function
<?php
function build_calendar($month, $year) {
$daysOfWeek = array('S','M','T','W','T','F','S');
$firstDayOfMonth = mktime(0,0,0,$month,1,$year);
$numberDays = date('t',$firstDayOfMonth);
$dateComponents = getdate($firstDayOfMonth);
$monthName = $dateComponents['month'];
$dayOfWeek = $dateComponents['wday'];
$calendar = "<table class='calendar'>";
$calendar .= "<caption>$monthName $year</caption>";
@agarzon
agarzon / html2txt.php
Created October 15, 2013 19:46
PHP Text Browser
<?php
header("Content-Type: text/plain");
function strip_html_tags( $text )
{
$text = preg_replace(
array(
// Remove invisible content
'@<head[^>]*?>.*?</head>@siu',
'@<style[^>]*?>.*?</style>@siu',
@agarzon
agarzon / wp-delete-unused-files.php
Last active June 14, 2017 20:40
Explore Upload folder to remove unused files and save disk space. Wordpress shell script
<?php
/**
* Wordpress shell script
* Explore Upload folder to remove unused files and save disk space
*
* @category Wordpress
* @package Wordpress.shell
*
* @author Alexander Garzon <agarzon@php.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
@agarzon
agarzon / installSourceCodePro.sh
Last active December 28, 2021 14:58
Install Source Code Pro fonts on Linux
version=1.017R
echo "\n* Downloading version $version of source code pro font"
rm -f SourceCodePro_FontsOnly-$version.zip
rm -rf SourceCodePro_FontsOnly-$version
wget https://github.com/downloads/adobe/source-code-pro/SourceCodePro_FontsOnly-$version.zip
echo "\n* Unziping package"
unzip SourceCodePro_FontsOnly-$version.zip
mkdir -p ~/.fonts
@agarzon
agarzon / videoConverter.sh
Created September 3, 2013 20:34
Video converter
#!/bin/bash
#Author: Alexander Garzon
ERROR() {
echo $0 ERROR: $1 >&2
exit 2
}
# -- Sanity check on parameters
[ $# -ne 1 ] && ERROR 'Please provide video file'
@agarzon
agarzon / countDown.js
Created August 29, 2013 18:52
Calculate remaining time
var diffSeconds = Math.round(new Date("September 21, 2013 12:00:00 PM").getTime()/1000.0) - Math.round(new Date().getTime()/1000.0);
var days = Math.floor(diffSeconds / 86400);
var hours = Math.floor(diffSeconds / 3600) % 24;
var minutes = Math.floor(diffSeconds / 60) % 60;
var seconds = diffSeconds % 60;
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;