Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjaminhu

  • Liftkeeper
  • Budapest, Hungary
View GitHub Profile
@agarzon
agarzon / install-php-tools.sh
Last active Feb 10, 2021
Install globally popular PHP dev tools like composer, phpunit, phpcs, phpmd, phpcpd, deployer, robo, codeception, etc.
View install-php-tools.sh
#!/bin/bash
#To execute it directly: sudo bash <(curl -s https://gist.githubusercontent.com/agarzon/ecb0b92d4c8e1bbde126534c76721a58/raw/install-php-tools.sh)
BIN_PATH=/usr/local/bin/
#COMPOSER
sudo curl -LsS https://getcomposer.org/composer.phar -o ${BIN_PATH}composer
sudo chmod a+x ${BIN_PATH}composer
@m4munib
m4munib / php_command_pattern.php
Created May 29, 2016
Abstract Class - PHP Command
View php_command_pattern.php
<?php
interface InterfaceCommand {
function execute();
}
abstract class AbstractCommand implements InterfaceCommand {
/**
@ozanhazer
ozanhazer / test_runner.sh
Last active Jun 16, 2019
A very basic PHPUnit runner and watcher for TDD
View test_runner.sh
#!/usr/bin/env bash
# Author: M.Ozan Hazer
#
# TEST RUNNER SCRIPT
#
# Expects phpunit to be installed via composer to make sure that the
# right version of phpunit is used
#
# `w` option is for watching the app and test directories for the
# simplest TDD setup
@marcellodesales
marcellodesales / ec2-host-from-tag-to-env-vars.sh
Last active Feb 10, 2021
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
View ec2-host-from-tag-to-env-vars.sh
######
# Author: Marcello de Sales (marcello.desales@gmail.com)
# Description: Create Create Environment Variables in EC2 Hosts from EC2 Host Tags
#
### Requirements:
# * Install jq library (sudo apt-get install -y jq)
# * Install the EC2 Instance Metadata Query Tool (http://aws.amazon.com/code/1825)
#
### Installation:
# * Add the Policy EC2:DescribeTags to a User
@popravich
popravich / PostgreSQL_index_naming.rst
Last active Feb 21, 2021
PostgreSQL index naming convention to remember
View PostgreSQL_index_naming.rst

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@pastuhov
pastuhov / AcceptanceHelper.php
Last active Feb 16, 2021
codeception page load wait helper
View AcceptanceHelper.php
<?php
namespace tests\codeception\common\_support;
use Codeception\Exception\ModuleException;
/**
*
*/
class AcceptanceHelper extends \Codeception\Module
@mindplay-dk
mindplay-dk / session-life-cycle.md
Last active Jan 9, 2021
Complete overview of the PHP SessionHandler life-cycle
View session-life-cycle.md

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@ysasaki
ysasaki / cloudwatch-php-fpm-status.sh
Last active Jan 13, 2021
php-fpm status to AWS CloudWatch
View cloudwatch-php-fpm-status.sh
#!/bin/bash
AWS_DEFAULT_REGION="ap-northeast-1"
AWS_ACCESS_KEY_ID="YOUR ACCESS KEY HERE"
AWS_SECRET_ACCESS_KEY="YOUR SECRET ACCESS KEY HERE"
INSTANCE_ID_URL="http://169.254.169.254/latest/meta-data/instance-id"
INSTANCE_ID=$(curl -s ${INSTANCE_ID_URL})
SERVER_STATUS_URL="http://localhost/php-fpm-status"
@fredbradley
fredbradley / README.md
Last active Nov 4, 2019
Disk Space Checker
View README.md

class.DiskSpaceCheck.php

This class is quick and simple to install into any PHP application, and is easy to customise to the display you require.

The script finds the amount of total disk space on your system, and then the total free space. We then calculate the used space and give it to you as a percentage.

Developer

This class was developed by Fred Bradley - http://twitter.com/fredbradley

Setting the path to check

You can choose the path of the disk that you want to check (if you have multiple disks mounted, for example). You can do this by setting the first paramater when calling calling the Class to the directory that you want to check. EG: $disk = new DiskSpaceCheck('/var/www/vhosts/');

@nadar
nadar / PostMessageToSlackChannel.php
Last active Oct 23, 2020
Post a message to a slack channel with PHP
View PostMessageToSlackChannel.php
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar