Skip to content

Instantly share code, notes, and snippets.

View fubhy's full-sized avatar

Sebastian Lorenz fubhy

View GitHub Profile
use Guzzle\Cache\CacheAdapterInterface;
/**
* Custom cache adapter.
*
* Leverages the default Drupal cache bin system for caching Guzzle responses.
*/
class DrupalCacheAdapter implements CacheAdapterInterface {
/**
@fubhy
fubhy / gist:e9b486f160fc6743267e
Created June 30, 2014 15:13
Compass and LibSass
# Convert .scss to .css (including live reload). In some cases (e.g. when using
# Compass) the 'images' task has to run before this one so that utility
# functions like 'image-url' don't cause errors when evaluated before the image
# has been created.
gulp.task 'styles', ['images'], ->
sassConfig =
outputStyle: if isProduction then 'compressed' else 'expanded'
# Source maps are currently broken in 'gulp-sass'.
#sourceComments: 'map'
@fubhy
fubhy / SassMeister-input.scss
Created November 14, 2014 11:41
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// Toolkit (v2.6.0)
// ----
@import "toolkit";
@mixin static($mixin-name, $extend: true) {
@if $extend == true {
import React from 'react/addons';
import isArray from 'lodash/lang/isArray';
import isObject from 'lodash/lang/isObject';
import isFunction from 'lodash/lang/isFunction';
// @todo Remove this once React 0.14 lands (parent based contexts).
export default function renderChildren() {
const { children, ...props } = this.props;
if (isFunction(children)) {
@fubhy
fubhy / SassMeister-input.scss
Created July 21, 2015 13:08
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$rendering-for-ie: true !default;
@mixin media($media-query, $render-for-ie: true) {
@if $rendering-for-ie == false {
@media (#{$media-query}) {
@content;
@fubhy
fubhy / SassMeister-input.scss
Created July 22, 2015 12:47
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
@function image-url($path) {
@return '../images/#{$path}';
}
.foo {
background: url(image-url('asd.png'));
# The routes of the project.
#
# Each route describes how an incoming URL is going
# to be processed by Platform.sh.
"http://{default}/":
type: upstream
upstream: "php:php"
"http://www.{default}/":
node_page_edit:
pattern: '/music/{album}/{artist}'
defaults:
_content: 'Drupal\music\MusicController::view'
requirements:
_permission: 'yeap'
options:
parameters:
album:
converter: 'paramconverter.typed_data'
foo_route:
pattern: '/some/random/{entity_type}/{entity}/route'
options:
parameters:
entity:
type: entity:{entity_type}
+ public function convert($definition, $name, array $defaults, Request $request) {
+ // Only continue if there is a value for the given parameter.
+ if (!isset($defaults[$name])) {
+ return;
+ }
+ $entity_type = substr($definition['type'], strlen('entity:'));
+ if ($storage = $this->entityManager->getStorageController($entity_type)) {
+ return $storage->load($defaults[$name]);
+ }
+ }