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 / 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 / drupal-http-head-get-status-code.php
Last active July 27, 2020 05:06
Drupal: Get status code from a HTTP HEAD request
$status_code = (string) \Drupal::httpClient()->head($uri, ['http_errors' => false])->getStatusCode();
@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
@thelebster
thelebster / jq to filter by value.md
Created June 14, 2020 21:32 — forked from ipbastola/jq to filter by value.md
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@thelebster
thelebster / settings.local.php
Created June 4, 2020 05:30 — forked from keopx/settings.local.php
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';
@thelebster
thelebster / bash-smtp-auth-email
Created June 3, 2020 08:20 — forked from fbatschi/bash-smtp-auth-email
How to send an email from bash via SMTP Auth
echo "PUT YOUR MAIL BODY HERE" | mailx -s "SUBJECT" -S smtp=smtp://yoursmtpserver.com -S smtp-auth=login -S smtp-auth-user=YOUR_USERNAME -S smtp-auth-password=YOUR_PASSWORD -S from="Sender Name <sender@mail.com>" recipient@mail.com
@thelebster
thelebster / do-userdata-docker+nginx+github.sh
Last active March 11, 2020 07:16
DigitalOcean User Data: Install Ningx, Docker CE and add GitHub SSH key
#!/bin/bash
apt-get -y update
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
apt-get -y update
apt-cache policy docker-ce
apt-get -y install docker-ce
export DOCKER_STATUS=$(systemctl status docker)
@thelebster
thelebster / spinner.html
Last active February 27, 2020 05:42
Material Design Spinner (https://codepen.io/mrrocks/pen/EiplA)
<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
<style>
// This is just to center the spinner
html, body { height: 100%; }
body {