Skip to content

Instantly share code, notes, and snippets.

View keopx's full-sized avatar

Ruben Egiguren keopx

View GitHub Profile
<?php
/*
+----------------------------------------------------------------------+
| APC |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2011 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
{% block version -%}
vcl 4.0;
{% endblock %}
# This Varnish VCL has been adapted from the Four Kitchens VCL for Varnish 3.
# Default backend definition. Points to Apache, normally.
backend default {
{% block backend -%}
.host = "{{ varnish_default_backend_host }}";
@keopx
keopx / Concurrent_apache.sh
Last active July 7, 2017 08:44
Concurrent connections Apache
#!/bin/bash
# RAM consumed in MB per connection
ps -ylC apache2 --sort:rss | awk '{SUM += $8; I += 1} END {print SUM/I/1024}'
# System consumed in MB.
ps -N -ylC apache2 --sort:rss | awk '{SUM += $8} END {print SUM/1024}'
(RAMTOTAL – RAM_RESTOPROCESOS) / RAM_POR_CONEXIÓN
@keopx
keopx / settings.local.php
Last active March 25, 2024 12:22
Drupal 8 Redis settings.local.php
<?php
/**
* Set redis configuration.
*/
/** @see: https://docs.platform.sh/frameworks/drupal8/redis.html */
if (extension_loaded('redis')) {
// Set Redis as the default backend for any cache bin not otherwise specified.
// $settings['cache']['default'] = 'cache.backend.redis';
aptitude install optipng jpegoptim
optipng *.png
jpegoptim *.jpg
<?php
namespace Drupal\view_mode_page\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Routing\AccessAwareRouterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@keopx
keopx / ReferencedEntityLoad.php
Created April 18, 2017 13:18
How to get instance of referenced entity - The path to referenced entity is very long
<?php
// $id = some node ID
// $field = field name for entity reference field
$node = Node::load($id);
/** @var \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $referenceItem */
$referenceItem = $node->get($field)->first();
/** @var \Drupal\Core\Entity\Plugin\DataType\EntityReference $entityReference */
$entityReference = $referenceItem->get('entity');
@keopx
keopx / settings.cache.php
Created April 2, 2017 08:24
Drupal backend cache memcache OR redis.
<?php
# KO memcache: http://cgit.drupalcode.org/memcache/tree/README.txt?h=8.x-2.x
//$settings['memcache']['servers'] = ['memcached:11211' => 'default'];
//$settings['memcache']['bins'] = ['default' => 'default'];
//$settings['memcache']['key_prefix'] = '';
/**
* Memcache Configuration.
*/
/*
@keopx
keopx / langoliers.rb
Created March 28, 2017 16:46 — forked from robinsloan/langoliers.rb
Tweet delete script
require "rubygems"
require "twitter"
require "json"
# things you must configure
TWITTER_USER = "your_username"
MAX_AGE_IN_DAYS = 1 # anything older than this is deleted
# get these from dev.twitter.com
CONSUMER_KEY = "your_consumer_key"
@keopx
keopx / WiFi_killer_1535.sh
Created March 27, 2017 13:13
[SOLVED] Killer 1535 Linux not working
#!/usr/bin/bash
sudo apt-get install git
git clone https://github.com/jeremyb31/ath10k-firmware.git
sudo cp -r ath10k-firmware/ /lib/firmware/ath10k/