Skip to content

Instantly share code, notes, and snippets.

View sebas5384's full-sized avatar
🏠
Working from home

Sebastian sebas5384

🏠
Working from home
View GitHub Profile
@sebas5384
sebas5384 / UserLogin.php
Created October 2, 2019 22:40
Drupal GraphQL Cookie Login
<?php
namespace Drupal\graphql_cookie\Plugin\GraphQL\Mutations;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\graphql\Plugin\GraphQL\Mutations\MutationPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use GraphQL\Type\Definition\ResolveInfo;
@sebas5384
sebas5384 / compositions.js
Last active May 28, 2019 23:22
Recompose HoCs for Next.js
/**
* Check if code is running on production mode.
*/
export const isProduction = () =>
typeof process !== "undefined" && process.env.NODE_ENV === "production"
/**
* Check if code is running on development mode.
*/
export const isDevelopment = !isProduction()
import { split, pipe, concat, uniq, join } from "ramda"
import { isDevelopment, isClient } from "app/lib/func"
// During development, use Drupal's own cache-tags header.
const headerName = isDevelopment() ? "X-Drupal-Cache-Tags" : "Cache-Tag"
const separator = isDevelopment() ? " " : ","
const splitTags = split(separator)
const mergeTags = pipe(
concat,
uniq,
@sebas5384
sebas5384 / settings.acquia.php
Created July 22, 2015 19:25
Drupal: Acquia Search configurations by environment for Search API Acquia
<?php
// Configs on Acquia Servers.
if (isset($_ENV['AH_SITE_ENVIRONMENT'])) {
switch ($_ENV['AH_SITE_ENVIRONMENT']) {
case 'dev':
$conf['search_api_acquia_overrides']['acquia_search'] = array(
'path' => '/solr/**CHANGE_ME**.dev.solr4',
'host' => '**CHANGE_ME**.acquia-search.com',
'port' => 80,
@sebas5384
sebas5384 / custom_search.module
Last active August 29, 2015 14:25
Drupal: Fulltext with partial matching for Search API Solr
<?php
/**
* Provide Solr dynamic fields as Search API data types.
*
* This serves as a placeholder for documenting additional keys for
* hook_search_api_data_type_info() which are recognized by this module to
* automatically support dynamic field types from the schema.
*
* @return array
* In addition to the keys for the individual types that are defined by
#!/bin/bash
#
# Original for 5.3 by Ruben Barkow (rubo77) http://www.entikey.z11.de/
# release 1 PHP5.4 to 5.3 by Emil Terziev ( foxy ) Bulgaria
# Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474
# OK, here's how to do the Apt magic to get PHP packages from the precise repositories:
echo "Am I root? "
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
@sebas5384
sebas5384 / schema.xml
Last active August 29, 2015 14:20
Schema.xml for Search API Solr with Apache Solr using N Gram enabled.
<?xml version="1.0" encoding="UTF-8" ?>
<!--
This is the Solr schema file. This file should be named "schema.xml" and
should be in the conf directory under the solr home
(i.e. ./solr/conf/schema.xml by default)
or located where the classloader for the Solr webapp can find it.
For more information, on how to customize this file, please see
http://wiki.apache.org/solr/SchemaXml
@sebas5384
sebas5384 / languages.xml
Created December 13, 2014 14:59
PHP pt-br: faq/languages.xml
Index: faq/languages.xml
===================================================================
--- faq/languages.xml (revision 335261)
+++ faq/languages.xml (working copy)
@@ -1,115 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- EN-Revision: 300233 Maintainer: narigone Status: ready -->
-<!-- Reviewed: yes Maintainer: thiago -->
- <chapter xml:id="faq.languages" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
- <title>O PHP e as outras linguagens</title>
@sebas5384
sebas5384 / ini.xml
Created December 13, 2014 13:40
PHP pt-br: appendices/ini.xml
Index: appendices/ini.xml
===================================================================
--- appendices/ini.xml (revision 335261)
+++ appendices/ini.xml (working copy)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- $Revision$ -->
+<!-- EN-Revision: 322056 Maintainer: none Status: ready --><!-- CREDITS: sebas5384@gmail.com -->
<appendix xml:id="ini" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
/**
* Implements hook_install().
*/
function power_one_install() {
// The "generation_site" entity type already exists at this point.
// Create a new entity bundle using ECK's API.
$new_bundle = function($name, $label, $entity_type) {
$bundle = new Bundle();
$bundle->name = $name;