Skip to content

Instantly share code, notes, and snippets.

View dusta's full-sized avatar
:octocat:
Visionary Programmer

Sławomir Kaleta dusta

:octocat:
Visionary Programmer
View GitHub Profile
@dusta
dusta / Cron.php
Created November 16, 2021 07:19
Example Dframe/Cron lock
<?php
use Dframe\Router\Response;
set_time_limit(0);
ini_set('max_execution_time', 0);
date_default_timezone_set('Europe/Warsaw');
require_once dirname(__DIR__) . '/../../../vendor/autoload.php';
require_once dirname(__DIR__) . '/../../../web/config.php';
@dusta
dusta / gist:c9ab5cfa1029721fc0a3fd025e5d332e
Created October 16, 2020 12:01
api call to microservice - dframe
<?php
try {
$client = new Client();
$response = $client->request('GET', 'NAME_MICROSERVICE:80/SLUG');
$body = \GuzzleHttp\json_decode($response->getBody(), true);
$statusCode = $response->getStatusCode();
} catch (GuzzleException $e) {
return Response::renderJSON(['code' => 500, 'message' => $e->getMessage()])->status(500);
}
@dusta
dusta / git-tips.md
Created April 9, 2020 10:07
Split folder or file in to a new repo

Replace DIR or FILE to you folder

git filter-branch --index-filter 'git rm --cached -qr --ignore-unmatch -- . && git reset -q $GIT_COMMIT -- DIR DIR FILE' --prune-empty -- --all
@dusta
dusta / bitbucket-pipelines.yml
Created February 11, 2020 14:35
bitbucket-pipelines deploy tag zip ftp
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.3
pipelines:
tags: # add the 'tags' section
v*: # specify the tag
@dusta
dusta / create-database.md
Last active February 21, 2024 10:47 — forked from NARKOZ/db_backup.sh
Cpanel db migration - Multiple export databases mysqldump - MySQL backup shell script

Old server

run this before multiple-import-mysql.sh

mysqldump -uroot -p --no-data --all-databases  > dump.sql 

New server

mysql -uroot -p &gt; dump.sql 
@dusta
dusta / Paginator.php
Created April 4, 2019 08:42
Paginator example
<?php
$page = (!isset($_GET['p']) or is_int($_GET['p']) != true) ? '1' : $_GET['p'];
$limit = '50';
$start = ($page - 1) * $limit;
// Example implement
//$sql = 'SELECT * FROM suppliers order by name ASC LIMIT ' . $start . ', ' . $limit;
@dusta
dusta / Router.php
Created November 18, 2018 14:54
Restful api Router for Dframe
<?php
/**
* DframeFramework
* Copyright (c) Sławomir Kaleta.
*
* @license https://github.com/dframe/dframe/blob/master/LICENCE (MIT)
*/
namespace Core;
@dusta
dusta / SearchBuilderWhereChunk.php
Last active December 30, 2019 08:29
Dframe/Database SearchBuilderWhereChunk
<?php
class Search
{
/**
* @var array
*/
public $search = [];
@dusta
dusta / SafeTransactionDframeDatabase.php
Created September 18, 2018 13:11
Safe multi Transaction Dframe\Database
<?php
namespace Model;
/**
* Class Database
* Klasa rozbudowuje transakcje o lvl
*
* @package Model
*/
class Database extends \Dframe\Database\Database
@dusta
dusta / Psr3Adapter.php
Created September 5, 2018 09:24
Dframe\ActivityLog PSR-3 adapter
<?php
/**
* PSR-3 Adapter for Dframe/activityLog
*/
namespace Dframe\ActivityLog\Helper;
use Dframe\ActivityLog\Activity;
use Psr\Log\AbstractLogger;