Skip to content

Instantly share code, notes, and snippets.

View standa's full-sized avatar

Standa standa

  • Standa
  • Prague, Czech Republic, Europe
View GitHub Profile
@standa
standa / terminal.php
Created November 27, 2019 10:06
Ingenico POS Payment Terminal Test Script
<?php declare(strict_types=1);
namespace Maternia\Utils\Terminal;
error_reporting(E_ALL);
ini_set('display_errors', '1');
ob_implicit_flush();
const HOST = '192.168.0.176';
@standa
standa / mail.php
Last active October 6, 2018 10:27
OpenCart Mailgun And Database Mail Logging class
<?php
class Mail
{
// @author standa | additional features related to mailgun and logging
use MailgunTrait, LoggedEmailTrait;
public function send()
{
// ...
@standa
standa / DomainChecker.php
Created October 6, 2018 07:22
Multiple Domain Title Checker
<?php
DomainChecker::checkDomains();
/**
* @author standa <[email protected]>
* @version 2014-11-25
*/
class DomainChecker
{
@standa
standa / parse_mailgun_webhook_stdin.php
Last active October 6, 2018 10:24
Parse mailgun webhook
<?php
function parse_mailgun_webhook_stdin(): array
{
$raw = file_get_contents('php://input');
$json = json_decode($raw, true);
$order_id = $json['event-data']['user-variables']['order_id'] ?? $json['event-data']['user-variables']['order-id'] ?? null;
$mail_id = $json['event-data']['user-variables']['mail_id'] ?? $json['event-data']['user-variables']['mail-id'] ?? null;
$recipient = $json['event-data']['recipient'] ?? null;
@standa
standa / DefaultController.php
Created September 25, 2018 13:20
Router with callables
<?php
namespace League\Framework\Server\Controller;
use League\Plates\Engine;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
/**
* Example implementation of the default routing strategy (RequestResponseStrategy)
@standa
standa / order-callback.js
Created April 5, 2018 11:10
Apply a callback to orders you see in /admin/orders grid
var description = 'GoExpress delay of delivery for all the parcels from 3.04, because of Easter';
$('.data-admin input[name="orderIds[]"]').each((k,v) => {
var orderId = v.value
var data = new FormData()
data.append('order-report-type', 7) // DELAY
data.append('order-report-description', description)
var request = new XMLHttpRequest();
request.open("POST", "/admin/order-report/report/orderId/"+orderId);
request.send(data);
@standa
standa / gsx_db_web.php
Last active February 12, 2018 09:31
Update website via google spreadsheets
<?php
/**
* @see https://www.reddit.com/r/PHP/comments/7wu9w5/gsx_db_update_your_website_data_instantly_with_a/
*/
class Gsx_db {
var $google_page_id;
var $tables;
@standa
standa / upgrade-php-to-72.sh
Created January 18, 2018 14:28
Upgrade PHP 7.1 -> 7.2
#!/usr/bin/env bash
# TODO: EXPERIMENTAL run command by command as it will spit errors!
# ERRRORS: php-xdebug not working for php 7.2 yet!
if [ $EUID -ne 0 ]; then
exec sudo $0
fi
systemctl stop apache2
@standa
standa / logs-tee.php
Created January 4, 2018 14:29
Apache gzip logs by domain
<?php
/**
* Process all apache *.log.gz access logs in current directory
* - split data by domain (first field in access log)
*/
if (!is_dir('out')) {
mkdir('out');
}
@standa
standa / ping.php
Last active November 29, 2017 15:11
Error ping
<?php
/**
* @example Run as `php ping.php`
*
* Ping and keep pinging every 5 seconds.
*
* Print out only the errored packets
*/