Skip to content

Instantly share code, notes, and snippets.

Avatar

Denis Žoljom dingo-d

View GitHub Profile
@carlalexander
carlalexander / expect-header-fix.php
Last active Aug 13, 2021
WordPress "Expect" header fix
View expect-header-fix.php
<?php
/**
* By default, cURL sends the "Expect" header all the time which severely impacts
* performance. Instead, we'll send it if the body is larger than 1 mb like
* Guzzle does.
*/
function add_expect_header(array $arguments)
{
$arguments['headers']['expect'] = '';
@wcomnisky
wcomnisky / install-php-amqp.sh
Last active Sep 15, 2021
Install PHP AMQp on MacOS
View install-php-amqp.sh
#!/bin/bash
brew search librabbitmq
brew install rabbitmq-c
pecl install amqp
# set the path to librabbitmq install prefix [autodetect] : /usr/local/Cellar/rabbitmq-c/0.10.0
# if it fails follow the following (reference: https://github.com/pdezwart/php-amqp/issues/355#issuecomment-563203121):
@Serlych
Serlych / epub.css
Last active Nov 25, 2020 — forked from maticrivo/epub.css
You Don't Know JS Ebooks
View epub.css
body {
text-align: justify;
}
code, pre {
font-family: "Hack", monospace;
}
h1, h2, h3, h4, h5, h6 {
text-align: left;
@esausilva
esausilva / nonascii.md
Last active Oct 7, 2020
Find non-ASCII characters
View nonascii.md

One-liner for finding non-ASCII characters

# Linux
$ grep --color='auto' -P -n "[\x80-\xFF]" file.js

# Mac OS X after 'brew install pcre'
$ pcregrep --color='auto' -n "[\x80-\xFF]" file.js
@fsuste
fsuste / Gems.md
Last active Oct 23, 2020
List of problematic gems and fixes
View Gems.md

Eventmachine 1.0.8.

You can also update eventmachine to 1.0.9. and that should fix the problem

gem install eventmachine -v '1.0.8' -- --with-cppflags=-I/usr/local/opt/openssl/include

Nokogiri 1.6.*

@tmaiaroto
tmaiaroto / Dockerfile
Last active Aug 11, 2021
WordPress on Amazon ECS
View Dockerfile
FROM alpine:3.3
MAINTAINER Tom Maiaroto <tom@outdoorsy.co>
# Install packages
RUN apk --update --repository http://dl-3.alpinelinux.org/alpine/edge/main add \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
php7 \
@DomenicF
DomenicF / get_current_post_type.php
Last active Mar 12, 2020 — forked from bradvin/get_current_post_type.php
Get the current post_type context in the WordPress admin.
View get_current_post_type.php
<?php
/**
* gets the current post type in the WordPress Admin
*/
function get_current_post_type() {
global $post, $typenow, $current_screen;
//we have a post so we can just get the post type from that
if ( $post && $post->post_type ) {
return $post->post_type;
@lysender
lysender / using-aws-kms.php
Created Nov 10, 2015
Using AWS KMS API via PHP SDK
View using-aws-kms.php
<?php
use Aws\Kms\KmsClient;
// Somewhere in the controller or model
$this->load->config('aws');
// Not needed for EC2 instance role based authorization - for my local instance only
$key = $this->config->item('aws_s3_access_key');
$secret = $this->config->item('aws_s3_secret_key');
@anderly
anderly / woocommerce-add-custom-product-data-tab.php
Last active Jun 2, 2021
WooCommerce - Add Custom Product Data Tab
View woocommerce-add-custom-product-data-tab.php
// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'my_text_domain' ),
'target' => 'my_custom_product_data',
);
return $product_data_tabs;
}
@benlk
benlk / 0-toc.md
Last active Jun 15, 2021
Collection of notes on WP_UnitTestCase
View 0-toc.md
  1. Table of contents
  2. General information
    1. Terms
    2. General structure of a test
    3. WordPress-specific assertions and test functions
      • enqueues
      • creating posts
      • creating terms
      • attaching images
      • ?