Skip to content

Instantly share code, notes, and snippets.

server {
listen 127.0.0.1:80;
server_name localhost;
root /var/www/localhost;
index index.php;
access_log off;
; configuration for php opcache module
; priority=10
zend_extension=opcache.so
opcache.memory_consumption=128
; same string in one file can be used for other files to improve memory
; in MB
opcache.interned_strings_buffer=32
@tricarte
tricarte / php-fpm.conf
Created June 7, 2022 09:28
php-fpm config for nginx location block
# This file also includes fastcgi.conf file from nginx root
include snippets/fastcgi-php.conf;
# First chunk of the fastcgi response header (by default getconf PAGESIZE)
fastcgi_buffer_size 8k;
# With php-fpm (or other unix sockets):
# fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root;
fastcgi_pass unix:/run/php/php-fpm.sock;
@tricarte
tricarte / example.com.conf
Last active January 30, 2023 14:07
nginx-virtualhost-template
# | Config file for example.com host |
# ----------------------------------------------------------------------
#
# This file is a template for an Nginx server.
# This Nginx server listens for the `example.com` host and handles requests.
# Replace `example.com` with your hostname before enabling.
server {
server_name example.com;
@tricarte
tricarte / ffmpeg.md
Created October 22, 2019 18:58 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@tricarte
tricarte / wp-dos-patch.sh
Created July 7, 2019 14:29
patch wordpress for cve-2018-6389
#! /bin/bash
if [[ -f wp-login.php && -f wp-admin/load-scripts.php && -f wp-admin/includes/noop.php ]]
then
sed -i "1 s/^.*$/<?php\ndefine('CONCATENATE_SCRIPTS', false);/" wp-login.php
sed -i -e "s/^require( ABSPATH . WPINC . '\/script-loader.php' );$/require( ABSPATH . 'wp-admin\/admin.php' );/g" wp-admin/load-scripts.php
sed -i -e "s/^require( ABSPATH . WPINC . '\/script-loader.php' );$/require( ABSPATH . 'wp-admin\/admin.php' );/g" wp-admin/load-styles.php
echo """<?php
/**
* Noop functions for load-scripts.php and load-styles.php.
@tricarte
tricarte / fragment-cache.php
Created July 7, 2019 07:20
wordpress fragment cache
<?php
// https://css-tricks.com/wordpress-fragment-caching-revisited/
function fragment_cache($key, $ttl, $function) {
if ( is_user_logged_in() ) {
call_user_func($function);
return;
}
$key = apply_filters('fragment_cache_prefix','fragment_cache_').$key;
$output = get_transient($key);
if ( empty($output) ) {