Skip to content

Instantly share code, notes, and snippets.

View gerzenstl's full-sized avatar

Luis Gerzenstein gerzenstl

View GitHub Profile
@gerzenstl
gerzenstl / FormExample.php
Created May 15, 2019 13:45
Custom ajax progress indicator for Drupal 8
$form['test_button'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
'#ajax' => [
'callback' => 'mymodule_ajax_callback',
'progress' => [
'type' => 'mycustomspinner',
'message' => 'My custom message',
],
'wrapper' => 'js_ajax_test_form_wrapper',
@gerzenstl
gerzenstl / website.conf
Created December 13, 2018 21:56
Nginx detailed logging
log_format upstream_logging '[$time_local] $remote_addr - $remote_user - $server_name | to: $request | Reuest Time: $request_time | status: $status | Request Body: $request_body';
server {
access_log /var/log/nginx/website.com_access.log upstream_logging;
error_log /var/log/nginx/website.com_error.log;
}
#!/bin/sh
## A useful snippet for deploy on Fridays
set -e
DAYOFWEEK=$(date +"%u")
if [ "$DAYOFWEEK" -eq 5 ]; then
echo "┐┌┐┌┐┐┌┐┌┐";
@gerzenstl
gerzenstl / config
Created September 10, 2018 17:46
SSH standard config file
## General settings
Host *
ServerAliveInterval 120
## Settings from personal accounts
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git
@gerzenstl
gerzenstl / useful-redis-commands.sh
Created July 17, 2018 17:31
Useful commands to use with Redis from CMD
// Removes all keys under a specific cache key. To use it, replace the "yourcacheprefix" string with the cache prefix used on your app.
redis-cli KEYS "yourcacheprefix:*" | xargs --delim='\n' redis-cli DEL
function getMachineName(text) {
return text.toLowerCase().replace(/\W/g, '-');
}
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int daysPerMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
bool leapYear = false;
@gerzenstl
gerzenstl / drupal-strip-leading-trailing-whitespaces.php
Created March 4, 2016 22:27
Drupal - Strips all leading and trailing white spaces on form fields.
/**
* Implements hook_form_alter().
*/
function my_module_form_alter(&$form, &$form_state, $form_id) {
/**
* We give a special treatment to all custom forms.
*/
if (substr($form_id, 0, 4) === 'my_module') {
array_unshift($form['#validate'],'my_module_trim_form_values');
@gerzenstl
gerzenstl / useful-drush-commands.sh
Last active March 3, 2017 04:48
Useful drush commands
# Flush memcache on [site domain] domain
drush ev "dmemcache_flush()" --uri="[site domain]"
# Flush varnish cache on [site domain] domain
drush ev "_varnish_terminal_run(array('ban req.http.host ~ [site domain]'))";
# Truncates all cache tables with SQL queries
echo "SHOW TABLES LIKE 'cache%'" | $(drush sql-connect) | tail -n +2 | xargs -L1 -I% echo "DELETE FROM %;" | $(drush sql-connect) -v
@gerzenstl
gerzenstl / gist:571bd4d9ef6154291199
Last active August 29, 2015 14:26
useful-varnish-commands.sh
For V3
## Look at an incoming client request of a specific URL:
varnishlog -c -m RxURL:"webiste.com/misite.html"
##Look at a a backend request of a specific URL:
varnishlog -b -m TxURL:"webiste.com/misite.html"
## See requests for one specific Hostname:
varnishlog -c -m RxHeader:"Host: webiste.com"