Skip to content

Instantly share code, notes, and snippets.

@bclinkinbeard
bclinkinbeard / README.md
Created August 21, 2012 01:35
AngularJS Response Interceptor Demo

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".

@Sentences
Sentences / response.php
Created October 24, 2012 10:38
Laravel Response extend for inline displaying of images
<?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
@deefour
deefour / deefour-request-handling.md
Last active November 11, 2016 19:22
A work-in-progress attempt to explain how a few small packages aide me in application development.

NOTE: Some recent, major refactoring has made some sections of this document inaccurate. It will be updated soon.

Handling Requests in Laravel With the Help of Ruby-Inspired Packages

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.

@mdwheele
mdwheele / proposal.md
Last active January 3, 2018 20:25
Discussing how to make DDD easier to learn.

Edit: A bit of context as more than expected are happening upon the gist.

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.

@crashkonijn
crashkonijn / EloquentDirtyFix.php
Created May 11, 2018 09:34
Fixes the cast dirty problems in < Laravel 5.5 projects. Tested with L5.3
<?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) {
@pklaus
pklaus / ddns.py
Last active September 17, 2021 12:42
A script to update the A and AAAA RRs of HOSTNAME on a DNS server according to your current external IP address using nsupdate / TSIG. This script is tested to run on Mac OS X (10.8-10.9) but you should be able to get it up and running in almost no time on any Unix or Linux system that ships nsupdate. I use this script to update my own DDNS serv…
#!/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`
"""
@dhoelzgen
dhoelzgen / base_controller.rb
Last active October 7, 2021 16:19
CORS in Rails 4 APIs
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'
#!/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
@victorbstan
victorbstan / php_object_to_array.php
Created December 17, 2010 04:18
recursively cast a PHP object to array
<?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);