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 / 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)
@thelebster
thelebster / backup.py
Created November 12, 2020 07:33 — forked from efann/backup.py
# Date updated: November 7, 2016
#
# Python routine for copying a complete directory structure up to Dropbox.
# Uses Python SDK for API v2
# https://www.dropbox.com/developers/documentation/python
import dropbox
import os
import time
@thelebster
thelebster / webp-instructions.md
Created September 11, 2020 06:23
WebP Support in ImageMagick and PHP

WebP support in ImageMagick and php

This applies specifically to MAMP Pro, but should also be applicable to other local development setups.

ImageMagick does not install with WebP support enabled by default. In order to get this working, there are a few steps you have to take.

  1. Install or recompile ImageMagick with support for WebP.

brew install imagemagick --with-webp

@thelebster
thelebster / retry.sh
Created July 10, 2020 19:37 — forked from sj26/LICENSE.md
Bash retry function
# Retry a command up to a specific numer of times until it exits successfully,
# with exponential back off.
#
# $ retry 5 echo Hello
# Hello
#
# $ retry 5 false
# Retry 1/5 exited 1, retrying in 1 seconds...
# Retry 2/5 exited 1, retrying in 2 seconds...
# Retry 3/5 exited 1, retrying in 4 seconds...

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.

Mac

git config --global core.excludesfile ~/.gitignore

Windows

git config --global core.excludesfile %USERPROFILE%\.gitignore