Skip to content

Instantly share code, notes, and snippets.

@reanim8ed
reanim8ed / sample.php
Last active December 28, 2021 19:38
[Suma žodžiais] #php
function skaicius_zodziais( $skaicius ) {
// neskaiciuosim neigiamu ir itin dideliu skaiciu (iki milijardu)
if ( $skaicius < 0 || strlen( $skaicius ) > 9 ) return;
if ( $skaicius == 0 ) return 'nulis';
$vienetai = array( '', 'vienas', 'du', 'trys', 'keturi', 'penki', 'šeši', 'septyni', 'aštuoni', 'devyni' );
$niolikai = array( '', 'vienuolika', 'dvylika', 'trylika', 'keturiolika', 'penkiolika', 'šešiolika', 'septyniolika', 'aštuoniolika', 'devyniolika' );
@reanim8ed
reanim8ed / sample.md
Last active September 15, 2021 20:51
[Symfony performance] #symfony #opcache

OPcache

Symfony 4.4 can generate a preloading file for your application in the cache directory. The generated file name includes both the environment and kernel names

During container compilation (e.g. when running the cache:clear command), Symfony generates a file with the list of classes to preload in the var/cache/ directory. Rather than use this file directly, use the config/preload.php file that is created when using Symfony Flex in your project:

; php.ini
opcache.enable=1

opcache.preload=/path/to/project/config/preload.php
@reanim8ed
reanim8ed / sample.md
Last active September 15, 2021 20:33
[WP debug] #wordpress
  • In order to enable debugging, prevent errors and warnings from being displayed and log errors, you need these three lines in your wp-config:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
  • Writing Other Information To The Log
if ( ! function_exists('write_log')) {
@reanim8ed
reanim8ed / sample.md
Created July 30, 2021 17:39
[Apache current config] #apache

apachectl -S for running config, apachectl -M to show loaded modules

@reanim8ed
reanim8ed / sample.md
Last active July 30, 2021 09:17
[Xdebug in docker] #xdebug
  1. In docker-compose.yml expose 9000 port for php:
version: '3'

services:

  webserver:
    image: nginx:latest
    ports:
- 8080:80
@reanim8ed
reanim8ed / sample.md
Last active April 10, 2025 22:07
[Install wkhtmltopdf] #pdf #wkhtmltopdf #centos

Install wkhtmltopdf on CentOS 8:

  • Install wget: sudo yum -y install wget

  • yum install:

    • xorg-x11-server-Xvfb
    • xorg-x11-fonts-Type1
    • xorg-x11-fonts-75dpi
    • dejavu-sans-fonts
    • urw-fonts
@reanim8ed
reanim8ed / sample.md
Last active July 23, 2021 13:35
[Order ArrayCollection by array & lt chars] #symfony #php
// $optionNames - array to sort by;
// $options - array collection to sort

$collator = new Collator('lt_LT');
$collator->sort($optionNames);

// Reorder iterator by already ordered option names
$optionIterator = $options->getIterator();
@reanim8ed
reanim8ed / sample.md
Created July 13, 2021 17:31
[Bitnami apache autoredirect to www] #bitnami #redirect #apache
  1. Edit: /opt/bitnami/apache2/conf/bitnami/bitnami.conf
  2. Find: <VirtualHost _default_:80>
  3. Add:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  1. Find: ``
@reanim8ed
reanim8ed / sample.md
Created June 20, 2021 21:09
[Cron in CentOS 8] #centos #cron

Installing Cron

Almost every Linux distribution has some form of cron installed by default. However, if you’re using a CentOS machine on which cron isn’t installed, you can install it using dnf. sudo dnf install crontabs

This will install cron on your system, but you’ll need to start the daemon manually. You’ll also need to make sure it’s set to run whenever the server boots. You can perform both of these actions with the systemctl command. sudo systemctl start crond.service

To set cron to run whenever the server starts up, type: sudo systemctl enable crond.service