Skip to content

Instantly share code, notes, and snippets.

View thelebster's full-sized avatar
:octocat:
Do nothing, it is ok.

Anton Lebedev thelebster

:octocat:
Do nothing, it is ok.
View GitHub Profile
@thelebster
thelebster / drupal-standalone-php-script.md
Created January 24, 2021 09:45
Drupal: Execute standalone PHP script

Drupal: Execute standalone PHP script

Install Drush - a command-line shell and Unix scripting interface for Drupal.

Basic example

Place file script.php under the Drupal root directory:

<?php
@thelebster
thelebster / drupal-access-aws-vpc-based-elasticsearch-cluster-locally.md
Last active November 14, 2021 08:05
Allow insecure connections to the AWS VPC-based Elasticsearch cluster in Drupal 8/9 during local development

Allow insecure connections to the AWS VPC-based Elasticsearch cluster in Drupal 8/9 during local development

Wanted to be able to debug some Elasticsearch-related issues or cases within the production environment. To make this work, you need to ignore the invalid SSL certificate and adjust the Elasticsearch cluster index name, that usually tied to the database name.

Make Elasticsearch cluster accessible locally

Suppose you already have an EC2 instance running in the same VPC as your Elasticsearch cluster and that instance security group allows access to the Elasticsearch cluster.

@thelebster
thelebster / letsencrypt.py
Last active January 23, 2021 21:22 — forked from gpjt/letsencrypt.py
Sample acme code to get a certificate from Let's Encrypt #letsencrypt
# There's a lack of sample code for acme/Let's Encrypt out there, and
# this is an attempt to at least slightly remedy that. It's the result
# of my first day's hacking on this stuff, so almost certainly contains
# errors and oversights.
#
# It's not designed to be specifically useful if what you want is
# just a cert -- certbot or dehydrated are better for that. It is sample
# code for people who are building automated systems to deal with large
# numbers of Let's Encrypt certificates to play with.
#
@thelebster
thelebster / kibana_nginx.conf
Created December 25, 2020 11:51
Nginx reverse proxy for accessing AWS ElasticSearch Kibana
server {
listen 443 ssl;
server_name kibana.domain.com;
rewrite ^/$ https://$host/_plugin/kibana redirect;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@thelebster
thelebster / amazon-cloudwatch-agent.log
Created December 22, 2020 10:24 — forked from mdemblani/amazon-cloudwatch-agent.log
Cloudwatch Agent Configuration Snippets
2020-05-06T10:17:35Z I! will use file based credentials provider
2020-05-06T10:17:35Z I! cloudwatch: publish with ForceFlushInterval: 1m0s, Publish Jitter: 37s
2020-05-06T10:17:35Z I! Starting AmazonCloudWatchAgent (version 1.237768.0)
2020-05-06T10:17:35Z I! Loaded outputs: cloudwatch cloudwatchlogs
2020-05-06T10:17:35Z I! Loaded inputs: tail cpu diskio processes statsd swap disk mem netstat socket_listener
2020-05-06T10:17:35Z I! Tags enabled: host=ip-X-X-X-X
2020-05-06T10:17:35Z I! Agent Config: Interval:1m0s, Quiet:false, Hostname:"ip-X-X-X-X", Flush Interval:1s
2020-05-06T10:17:35Z I! Started the statsd service on :8125
2020-05-06T10:17:35Z I! Statsd listener listening on: [::]:8125
2020-05-06T10:17:35Z I! will use file based credentials provider
@thelebster
thelebster / wikipedia-infoboxes-in-pandas.ipynb
Created December 8, 2020 20:36 — forked from aculich/wikipedia-infoboxes-in-pandas.ipynb
How to extract Wikipedia infoboxes and wikitables using Pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thelebster
thelebster / DataLoaderBatchService.php
Created December 8, 2020 13:56 — forked from acrosman/DataLoaderBatchService.php
A Drupal 8 batch job to load large amounts of data into a Pantheon web site. Relies on Batch Services sandbox module: https://www.drupal.org/sandbox/acrosman/3025562
<?php
namespace Drupal\example_pantheon_loader;
use Drupal\Core\Database\Connection;
use Drupal\batch_service_interface\AbstractBatchService;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\file\Entity\File;
use Drupal\Core\File\FileSystem;
@thelebster
thelebster / Drupal8_views_query_alter.php
Created November 30, 2020 11:57 — forked from brooke-heaton/Drupal8_views_query_alter.php
Alters a Drupal 8 view by adding a Left Join and Where condition
<?php
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\query\QueryPluginBase;
/**
* Implementation of hook_views_query_alter
* @param type $view
* @param type $query
@thelebster
thelebster / databaseService.php
Last active November 25, 2020 14:58 — forked from WengerK/databaseService.php
Drupal 8 - Print raw SQL queries for debugging
<?php
/**
* Debugging using the database connection.
*/
/** @var \Drupal\Core\Database\Connection */
$connection = \Drupal::service('database');
$query = $connection->select('node', 'node');
$query->fields('node', ['nid'])
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)