Skip to content

Instantly share code, notes, and snippets.

View atrauzzi's full-sized avatar

Alexander Trauzzi atrauzzi

View GitHub Profile
public function setSentAttribute($value) {
if($value instanceof DateTime)
$value = $value->format('Y-m-d H:i:s');
$this->attributes['sent'] = $value;
}
@atrauzzi
atrauzzi / gist:7827217
Created December 6, 2013 16:04
Static route helpers.
<?php namespace My\Namespace;
use Illuminate\Support\Facades\Route;
class Routes {
public static function all() {
static::allDevice();
static::allPlatform();
// http://stackoverflow.com/questions/20907068/how-to-create-a-strongly-typed-collection-that-only-contains-one-element-per-typ
class TypedSet<AbstractType> {
protected Dictionary<Type, AbstractType> data;
public TypedSet() {
data = new Dictionary<Type, AbstractType>();
}
public void Add(AbstractType subclassOfAbstract) {
using Nancy;
public class IndexModule : NancyModule {
// What would be neat is if I could teach Nancy new ways of handling the right side of routes.
public IndexModule() {
Get["/"] = typeof(MyProject.Controller.Home);
// This would perhaps run a standard method found on the class after instantiating it.
# Quesedeals
General docs can be found here:
http://drupalcode.org/project/restws.git/blob_plain/d371e6e274d9f3ad15de1c2bf15e45874ce008d3:/README.txt
What follows is the guts of what you're after...
## Endpoints
@atrauzzi
atrauzzi / gist:84fad78e206b1c45c968
Last active August 29, 2015 14:02
An example of something I saw.
public class BaseServiceClass
{
protected static DictionaryType AllTheDataInTheWorld;
public BaseServiceClass()
{
BaseServiceClass.AllTheDataInTheWorld = new DictionaryType();
}
<?php namespace BikeShed\Domain\Repository {
use BikeShed\Domain\User as UserModel;
interface User {
/**
* Searches Users without passwords by username.
*
@atrauzzi
atrauzzi / PHPStorm-Oct2014.xml
Created October 23, 2014 12:39
PHPStorm settings Oct 2014
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="4" />
@atrauzzi
atrauzzi / pre-run.sh
Created February 16, 2015 16:26
Docker pre-run workaround for inheriting host's .ssh.
#!/bin/sh
echo "Configuring SSH Environment for `whoami`..."
rm -rf ~/.ssh
cp -r ~/.host-ssh ~/.ssh
chown -R root:root ~/.ssh
chmod -R 400 ~/.ssh
"$@"
@atrauzzi
atrauzzi / Controller Sample.php
Last active November 11, 2015 16:49
Some of the things I love about Laravel 5 request handling.
<?php
use Illuminate\Routing\Controller;
use Illuminate\Foundation\Http\FormRequest;
//
use Illuminate\Http\Request;
/**
*
* Keep in mind, this uses a lot of idiomatic PHP. Any variable can be used as a nullable type and null