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 / GoogleApiAccess.md
Created December 26, 2021 12:59 — forked from lorisleiva/GoogleApiAccess.md
This gist describes two processes allowing us to access the Google API and to register some webhooks

Access Google API credentials and domain verification

This gist describes two processes allowing us to access the Google API and to register some webhooks. At the end of both processes we will obtain all variable needed to start using their API and we will have whitelisted all necessary URL to get started. We will be using the Google Calendar API and the Google Plus API to access the email address of the user.

This gist has been created as an Appendix to this article (part 1) and this article (part 3).

Note that, I will be using a randomly generated ngrok domain during this presentation. Simply replace b3093b51.ngrok.io with your domain name


@m4tlch
m4tlch / Form.js
Created December 26, 2021 12:58 — forked from lorisleiva/Form.js
// resources/js/services/Form.js
import FormErrors from './FormErrors'
export default class {
constructor (initialData = {}, submitCallback = null) {
this._initialData = initialData
this._submitCallback = submitCallback
this.errors = new FormErrors()
@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'];