Skip to content

Instantly share code, notes, and snippets.

@ajbm6
ajbm6 / SystemInfo.php
Created August 10, 2017 21:52
System info for Linux and Windows (PHP)
<?php
namespace Odan\Util;
/**
* System infos for Linux (Ubuntu) and Windows.
*
* - Total RAM
* - Free RAM
* - Disk size
@ajbm6
ajbm6 / webserver-test.php
Created August 10, 2017 21:50
Webserver and PHP configuration tester
<?php
/**
* Webserver and PHP configuration tester
*
* @author odan
* @license MIT
*/
if (!isset($_SESSION)) {
session_name('phptest');
@ajbm6
ajbm6 / age.js
Created August 10, 2017 21:49
Get age by date of birth (JavaScript)
/**
* Returns age from date of birth
*
* @param {Date} date
* @returns {Number}
*/
function getAge(date) {
var now = new Date();
var age = now.getFullYear() - date.getFullYear();
return age;
@ajbm6
ajbm6 / slim-xampp.md
Created August 10, 2017 11:55
Running multiple Slim Framework PHP sites with XAMPP

Running multiple Slim Framework sites with XAMPP

You can then run a slim framework app it with PHP's built-in webserver:

$ cd [my-app-name]; php -S localhost:8080 -t public public/index.php

The problem is that you have to enter this command every day again and again. If you are running more then one app you have to use the next free port.

I want to configure my XAMPP to have 2 (or more) different localhosts and sites with 2 different root directories.

@ajbm6
ajbm6 / 01-dependencies.php
Created July 30, 2017 21:16 — forked from dewey92/01-dependencies.php
Slim 3 controller
<?php
$c = new \App\Base\Container();
/**
* Register the CallableResolver we just wrote
* to overwrite the default resolving behaviour of the Slim app
*/
$c['callableResolver'] = function ($c) {
return new \App\Base\CallableResolver($c); // See number 04-CallableResolver.php
<?php
require_once 'hangedman.php';
$words = array();
$numwords = 0;
function printPage($image, $guesstemplate, $which, $guessed, $wrong) {
echo <<<ENDPAGE
<!DOCTYPE html>