Skip to content

Instantly share code, notes, and snippets.

View michabbb's full-sized avatar
💯
Need help ? Call me.....

Micha(el) Bladowski michabbb

💯
Need help ? Call me.....
View GitHub Profile
<?php declare(strict_types=1);
class Mode_test_exception extends Mode_test {
public function exception(): void
{
$this->throwerror($this->aConfig['error_reporting']['service']);
}
private function throwerror(array $params): void
@michabbb
michabbb / backup_mysql_schema_with_git.sh
Created January 18, 2022 11:26
backup mysql schema with git
#!/bin/bash
NOW=`date +%Y%m%d%H%M%S`
GIT_MYSQL=/backup/mysql
for T in `mysql -u root -N -B -e 'SELECT t.TABLE_NAME FROM information_schema.TABLES t WHERE t.TABLE_SCHEMA = "my_database" AND t.ENGINE != "MEMORY"'`;
do
echo "Backing up $T"
mysqldump -d --lock-tables=false --single-transaction=TRUE --skip-comments -u root my_databaswe $T | sed 's/ AUTO_INCREMENT=[0-9]*//g' > $GIT_MYSQL/$T.sql
done;
git add -A && git commit -m "schema from $NOW" && git push
@michabbb
michabbb / index.js
Last active January 27, 2023 22:08
lambda function to handle eBay Marketplace Account Deletion Notifications
const EventNotificationSDK = require('event-notification-nodejs-sdk');
const https = require('https');
// https://github.com/eBay/event-notification-nodejs-sdk/blob/main/lib/constants.js
const constants = {
ALGORITHM: 'ssl3-sha1',
AUTHORIZATION: 'Authorization',
BASE64: 'base64',
BEARER: 'bearer ',
ENVIRONMENT: {
@michabbb
michabbb / laravel_command_db_create_triggers.php
Last active April 18, 2021 12:30
In case u never use laravel timestamp columns in your models
<?php
namespace App\Console\Commands\helper;
use DB;
use Doctrine\DBAL\Exception;
use Illuminate\Console\Command;
class db_create_triggers extends Command
{
@michabbb
michabbb / debugging_sendmail.txt
Created August 6, 2020 15:09
debugging sendmail php
/usr/local/bin/phpsendmail
==================================================================================================
#!/usr/local/bin/php
<?php
/**
This script is a sendmail wrapper for php to log calls of the php mail() function.
Author: Till Brehm, www.ispconfig.org
(Hopefully) secured by David Goodwin <david @ _palepurple_.co.uk>
*/
@michabbb
michabbb / mysql_float_to_decimal_column_helper_select.sql
Created July 28, 2020 14:24
Helper SELECT: Changing FLOAT to DECIMAL in MySQL
SELECT
CONCAT('ALTER TABLE `',c.TABLE_NAME,'` CHANGE COLUMN `',c.COLUMN_NAME,'` `',c.COLUMN_NAME,'` ',REPLACE(c.COLUMN_TYPE,'float','decimal'),' ',IF(c.COLUMN_DEFAULT='NULL','DEFAULT NULL',' NOT NULL'),';')
FROM information_schema.COLUMNS c
WHERE c.TABLE_SCHEMA = 'mydatabase'
AND c.COLUMN_TYPE LIKE 'float%'
@michabbb
michabbb / findSellerStandardsProfiles.json
Created June 11, 2020 10:02
ebay findSellerStandardsProfiles response example
{
"standardsProfiles": [
{
"standardsLevel": "ABOVE_STANDARD",
"program": "PROGRAM_US",
"cycle": {
"cycleType": "CURRENT",
"evaluationDate": "2018-07-20T19:30:32.000Z"
},
"evaluationReason": "Default",
@michabbb
michabbb / Dockerfile
Created April 23, 2020 00:02
Dockerfile for pt-table-sync
FROM debian:9
RUN apt-get update && apt-get install -y \
libdbd-mysql-perl \
libdbi-perl \
libio-socket-ssl-perl \
libterm-readkey-perl \
perl \
wget \
&& rm -rf /usr/share/doc/* && \
@michabbb
michabbb / compare_large_table_by_hash.sql
Created April 22, 2020 23:18
mysql: Compare large tables by hash
/* create tmp table with entries that exist */
DROP TEMPORARY TABLE IF EXISTS source;
CREATE TEMPORARY TABLE source (compare_hash char(32) PRIMARY KEY) ENGINE = MEMORY
SELECT
compare_hash
FROM table_source AS s;
/* create tmp table with entries that SHOULD exist */
DROP TEMPORARY TABLE IF EXISTS target;
CREATE TEMPORARY TABLE target (compare_hash char(32) PRIMARY KEY) ENGINE=MEMORY
@michabbb
michabbb / Dockerfile
Created March 10, 2020 08:33
Docker php 7.4
FROM php:7.4-fpm-alpine3.11
COPY docker-php-ext-* docker-php-entrypoint /usr/local/bin/
RUN chmod u+x /usr/local/bin/docker-php-ext-* /usr/local/bin/docker-php-entrypoint
ENV IMAGICK_VERSION 3.4.4
ENV PHPMEMCACHED_VERSION 3.1.5
ENV PHPXDEBUG_VERSION 2.9.1
ENV PHPREDIS_VERSION 5.1.1
ENV GEARMAN_VERSION 2.0.3