Skip to content

Instantly share code, notes, and snippets.

View muhamed-didovic's full-sized avatar
😎

Muhamed muhamed-didovic

😎
View GitHub Profile
@muhamed-didovic
muhamed-didovic / new_vhost
Last active August 29, 2015 14:11 — forked from h4cc/new_vhost
#!/usr/bin/php
<?php
/**
* Script for creating a new Apache2 VHost and MySQL User + Database.
*
* @author Julius Beckmann (github@h4cc.de)
*/
if(6 != count($argv)) {
echo "--- New Vhost ---
<?php
// Switch architecture if needed
if(2147483647 == PHP_INT_MAX) {
$architecture = 'i386';
}else{
$architecture = 'amd64';
}
<?php
function flatten(array $array)
{
return call_user_func_array('array_merge', $array);
}
// CommandHandler Class
var CommandHandler = function(repository) {
this.handle = function(command) {
// do stuff with repository and command
}
}
// Elsewhere, create an instance of the class...
var myCommandHandler = new CommandHandler(repository);
var getClass = function() {
var funcNameRegex = /function (.{1,})\(/;
var results = (funcNameRegex).exec((this).constructor.toString());
return (results && results.length > 1) ? results[1] : "";
};
// define a class
function Animal() {}
// do this for all classes that need the getClass() method
<?php
class BankAccount
{
private $twitter;
public function __construct(Twitter $twitter)
{
$this->twitter = $twitter;
}
public function deposit($amount){
}
<?php
/** @Entity */
class Bug
{
/** @Column(type="integer") */
private $id;
/** @Column(length=50) */
private $status;
//...
}
<?php
class Foo
{
private $private;
public function __construct($value)
{
$this->private = $value;
}
public function getOther(Foo $object)
{
<?php
// client code
$customer = $customerRepository->find($id);
$orders = $customer->getOrders();
<?php
interface Thing {
public function execute();
}
class A implements Thing {
public function execute()