This is a simple demo of how to create and use a Response Interceptor in AngularJS. In this case we are using the interceptor to convert the objects created from a JSON data load into typed instances of a custom "class".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Laravel\File; | |
/** | |
* Put this in laravels libraries dir and make sure to | |
* remove Response in /config/application.php | |
* This file will be autoloaded by default. | |
* | |
* @author Nico R <lt500r@gmail.com> | |
*/ | |
class Response extends \Laravel\Response |
NOTE: Some recent, major refactoring has made some sections of this document inaccurate. It will be updated soon.
I am a PHP developer that has done a lot of Ruby on Rails development over the last few years. There are a few gems I found especially useful again and again.
- drapergem/draper for decorating model instances
- collectiveidea/interactor for small service objects
- elabs/pundit for authorizing a user against a resource
This is in response to a conversation between a few engineers I consider experts in their respective fields:
- Jeffrey Way (of Laracasts) as a technical educator aiming to investigate exposing newcomers to DDD in an easier-to-digest/grasp way.
- Konstantine Kudryashov (Behat, phpSpec, Inviqa) as a BDD consultant
- Mathias Verraes (dddinphp.org, http://verraes.net/) as a significant DDD resource and independent consultant.
Additional context can be sought reading backwards from https://twitter.com/mdwheele/status/527233999744557056. The stream is a bit broken, but the general gist/context is there.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// TODO: remove when bug is fixed, https://github.com/laravel/framework/issues/8972 | |
// Copied from the change that fixed it in 5.5: https://github.com/laravel/framework/pull/18400/files/01d6896cb402d7b641c84ed8d541b1bc96af34ce#diff-6a9cb621261ef4a702081454957adfb2 | |
trait EloquentDirtyFix | |
{ | |
public function getDirty() | |
{ | |
$dirty = []; | |
foreach ($this->getAttributes() as $key => $value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Written on 2013-02-04 by Philipp Klaus <philipp.l.klaus →AT→ web.de>. | |
Check <https://gist.github.com/4707775> for newer versions. | |
Uses dnspython: install with `pip install dnspython3` | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class API::V1::BaseController < ApplicationController | |
skip_before_filter :verify_authenticity_token | |
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xv | |
### Country list | |
# CHANGE WITH YOUR COUNTRIES | |
COUNTRIES="europe/france/guadeloupe europe/france/guyane europe/france/mayotte europe/france/martinique europe/france/reunion europe/france" | |
# SMALL SUBSET FOR TESTING: | |
COUNTRIES="europe/france/guyane europe/france/mayotte" | |
NOMINATIM="/var/www/Nominatim" | |
cd $NOMINATIM/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
This function saved my life. | |
found on: http://www.sitepoint.com/forums//showthread.php?t=438748 | |
by: crvandyke | |
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?! | |
*/ | |
$array = json_decode(json_encode($object), true); |
OlderNewer