Skip to content

Instantly share code, notes, and snippets.

[$USER]
user = $USER
group = $USER
listen = /run/php/fpm-$USER.sock
listen.owner = $USER
listen.group = $USER
listen.mode = 0666
pm = dynamic
@num8er
num8er / polyfills.php
Last active December 4, 2024 20:51
PHP 5.3 to 7.x migration polyfill collection.
<?php
namespace Polyfills
{
final class Ereg
{
public static function ereg($pattern, $string, &$regs = null)
{
if ($pattern === '' || $pattern === null) {
trigger_error('ereg(): REG_EMPTY', E_USER_WARNING);
@num8er
num8er / fpm-pool.conf
Created March 3, 2020 15:12
Copy of php fpm pool config with comments
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[num8er]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unum8ersocket)
; - 'chroot'
@num8er
num8er / stdout
Last active December 4, 2019 01:42
Some text N_abc_New_New_New_N! other text N_ghi_jkl_N and other text:;.#{}()[]N_abc_New_N.!@
Немного текста abc_New_New_New ! другой текст ghi_jkl и другой текст:;. # {} () [] abc_New ! @
Some text N_abc_New_New_New_N! other text N_ghi_jkl_N and other text:;.#{}()[]N_abc_New_N.!@
Lego_New New_Friends_New Lego_New
---------
Some text N_abc_New_New_New_N! other text N_ghi_jkl_N and other text:;.#{}()[]N_abc_New_N.!@
Du texte abc_New_New_New ! autre texte ghi_jkl et autre texte:;. # {} () [] abc_New ! @
---------
@num8er
num8er / match.php
Last active December 3, 2019 08:37
WrapperMatcher (matching anything between opening and closing patterns)
<?php
class WrapperMatcher {
private $startPattern = 'N_';
private $endPattern = '_N';
/**
* WrapperMatcher constructor.
*
<?php
function matchStringsBetweenWrappers($string) {
preg_match_all('/\[N\](.*?)\[\/N\]/u', $string, $matches);
array_walk($matches[0], function(&$item) {
$item = trim($item);
});
return $matches;
}
@num8er
num8er / match.php
Last active November 27, 2019 07:18
Matching substrings between wrappers (with unicode chars in input)
<?php
function matchStringsBetweenWrappers($string, $start, $end) {
// preserving symbols from being removed
$preserveDashPlaceholder = md5($string.'1');
$string = str_replace('-', $preserveDashPlaceholder, $string);
$preserveQuotePlaceholder = md5($string.'2');
$string = str_replace("'", $preserveQuotePlaceholder, $string);
$preserveWildcardPlaceholder = md5($string.'3');
$string = str_replace('*', $preserveWildcardPlaceholder, $string);
$preserveExclamationPlaceholder = md5($string.'4');
const config = require('./config.json');
(async () => {
for (let i = 0; i < config.serverList.length; i++) {
const {serverIp, serverPort} = config.serverList[i];
const serverInfo = await getServerInfo(serverIp, serverPort);
if (serverInfo && serverInfo.constructor.name === 'Object') {
config.serverList[i] = {...config.serverList[i], ...serverInfo};
}
}
@num8er
num8er / methods.swift
Last active August 15, 2019 01:18
Sending push notification using OneSignal API where title and content passed from iOS app as json body
func panic() {
let url = URL(string: "https://mywebsite.com/send.php")!
let parameters = ["title": "Some title", "content": "Some content"]
let body = try! JSONSerialization.data(withJSONObject: parameters, options: [])
let request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = body
/*
const originalText = 'Hello World';
const widgets = [
{position: 2, text: '111'},
{position: 4, text: '222'},
{position: 6, text: '333'}
];
Given text and widgets, need to inject widget text in positions.