Skip to content

Instantly share code, notes, and snippets.

View m4tlch's full-sized avatar
🏠
Working from home

Paul Nike m4tlch

🏠
Working from home
  • Ukraine
View GitHub Profile
@m4tlch
m4tlch / array-insert-after.php
Created November 9, 2021 21:34 — forked from wpscholar/array-insert-after.php
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@m4tlch
m4tlch / Info for PHPStorm.md
Created June 25, 2021 08:12 — forked from Pen-y-Fan/Info for PHPStorm.md
PHPStorm Tips, Tricks and setup

PHPStorm

PhpStorm Tips, ticks and standard setup

  1. Tips and Tracks for PHPStorm (PHPStorm Tips and Tricks.md)
  2. Standard setup for PHP projects (Standard.md)
<?php
$array = array_map("str_getcsv", explode("\n", $csv));
print json_encode($array);
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
@m4tlch
m4tlch / curl_dont_wait_for_response.php
Last active July 3, 2019 13:58
Curl without waiting response
<?php
<?php
///amo integra begin
$values = $hook->getValues();
$subject = $modx->getOption('emailSubject', $formit->config, 'form-'.$modx->resource->get('emailSubject'));
$name = $values['name'];
$phone = $values['phone'];
$email = $values['email'];
@m4tlch
m4tlch / respond_and_process.php
Created July 3, 2019 12:26 — forked from alexllnk/respond_and_process.php
PHP: Send response and continue processing
<?php
// Buffer all upcoming output...
ob_start();
// Send your response.
echo "Testing response";
// Get the size of the output.
$size = ob_get_length();
@m4tlch
m4tlch / flock-queue.php
Last active June 28, 2019 10:28 — forked from alexllnk/gist:9246d5bd28883bf356983579f5db0176
queue requests with flock
public function request_queue_handler(Request $request)
{
header($_SERVER['SERVER_PROTOCOL'].' 200 OK');
$amo_subdomain = $_POST['account']['subdomain'];
$path_structure = '../'.$amo_subdomain.'/queue_files';
$queue_file_prefix = $path_structure.'/queue_file_';
$queue_flag_file = $path_structure.'/queue_flag';
$lead_name = $_POST['leads']['add'][0]['name'];
@m4tlch
m4tlch / respond_and_process.php
Created June 13, 2019 16:15 — forked from kfriend/respond_and_process.php
PHP: Send response and continue processing
<?php
// Buffer all upcoming output...
ob_start();
// Send your response.
echo "Testing response";
// Get the size of the output.
$size = ob_get_length();
@m4tlch
m4tlch / checkbox.blade.php
Created March 19, 2019 19:21 — forked from skadimoolam/checkbox.blade.php
Customizable form partials for Laravel - https://laravelcollections.com
@php
$d = $d ?? null; // default value
@endphp
<div class="form-group row">
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label>
<div class="col-md-8">
<input id="{{ $n }}" type="checkbox" class="form-control" name="{{ $n }}" value="1" @if(old($n, $d) == '1') checked @endif>
@if ($errors->has($n))
<small class="text-danger">{{ $errors->first($n) }}</small>