Skip to content

Instantly share code, notes, and snippets.

View marcelsud's full-sized avatar

Marcelo Santos marcelsud

View GitHub Profile
<?php
namespace Acme\Services;
class Container {
private $services = array();
public function set($name, $instance)
{
$this->services[$name] = $instance;
}
<?php
namespace Acme\Services;
class SomeDatabaseMapper
{
public function findAll($table)
{
//Find all entries in some way
}
}
<?php
namespace Acme\Movie;
class SomeDatabaseMapper
{
public function findAll($table)
{
//Find all entries in some way
}
}
<?php
namespace Acme\Services;
class ServiceLocator {
private $services = array();
public function set($name, $instance)
{
$this->services[$name] = $instance;
}
@marcelsud
marcelsud / gist:6919308
Created October 10, 2013 14:29
Text editor in one line
data:text/html;charset=utf-8, <title>TextEditor</title> <link rel="shortcut icon" href="http://g.etfv.co/https://docs.google.com"/> <style> html{height: 100%;} body{background: -webkit-linear-gradient(#f0f0f0, #fff); padding: 3%; height: 94%;} .paper { font: normal 12px/1.5 "Lucida Grande", arial, sans-serif; width: 50%; height: 80%; margin: 0 auto; padding: 6px 5px 4px 42px; position: relative; color: #444; line-height: 20px; border: 1px solid #d2d2d2; background: #fff; background: -webkit-gradient(linear, 0 0, 0 100%, from(#d9eaf3), color-stop(4%, #fff)) 0 4px; background: -webkit-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -moz-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -ms-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -o-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; -webkit-background-size: 100% 20px; -moz-background-size: 100% 20px; -ms-background-size: 100% 20px; -o-background-size: 100% 20p
<?php
function validateEmail($email)
{
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException("Invalid email");
} else {
$domain = end(explode('@', $email));
if (!checkdnsrr($domain, 'MX')) {