Preventing Memory Leaks in PHP

Image resizing need memory. I use this script to prevent memory leak.

I use Intervention Image library for resizing I often get ‘Allowed memory size of …. bytes exhausted (tried to allocate … bytes)’ message.

////////////////////////////////////////////////////
//get memory_limit info from php.ini
$memoryAvailable = filter_var(ini_get(“memory_limit”), FILTER_SANITIZE_NUMBER_INT) * 1048576;

//getting the image width and height
$imageInfo = getimagesize($destinationPath . ‘/’ . $filename);

//This is quite rough and includes a fudge factor, 2.5, which you may want to experiment with.
$requiredMemory = ( $imageInfo[0] * $imageInfo[1] * ($imageInfo[‘bits’] / 8) * $imageInfo[‘channels’] * 2.5 );

//check memory usage
if (memory_get_usage() + $requiredMemory < $memoryAvailable) {

//we have enough memory to resize the image.
}
////////////////////////////////////////////////////

Laravel log viewer

Inspired by Micheal Mand’s Laravel 4 log viewer.

Log Viewer for Laravel 5 (compatible with 4.2 too).

Install:

composer require rap2hpoutre/laravel-log-viewer

Add Service Provider to config/app.php in providers section

‘Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider’,

Add a route in app/Http/routes.php (or choose another route):

Route::get(‘logs’, ‘\Rap2hpoutre\LaravelLogViewer\LogViewerController@index’);

my advice:
//protect log viewer with superamin filter

Route::get(logs”, [
‘before’ => ‘superadmin’,
“uses” => ‘\Rap2hpoutre\LaravelLogViewer\LogViewerController@index’
]);

https://github.com/rap2hpoutre/laravel-log-viewer

kullancs

A KUTYÁS TURIZMUS MIATT TUDTAK A KULLANCSFAJOK TELJESEN SZÉTSZÓRÓDNI AZ ORSZÁG TERÜLETÉN, ÉS A KUTYÁK MIATT VANNAK TELE VELÜK A VÁROSI PARKOK IS.

https://index.hu/belfold/2019/04/26/kullancs_kullancsszovetseg_lyme/

Dr. Lakos András

Nem félünk a kullancstól
Természetes, hogy vannak, így természetesen védekezhetünk is ellenük: http://allyouneed.blog.hu/2017/03/28/nem_felunk_a_kullancstol

Így szabadulj meg a vérszívóktól! : http://index.hu/index2/#bloghu/okosodjvelunk/2016/09/23/igy_szabadulj_meg_a_verszivoktol

Egyetek bőségesen fokhagymás ételeket, ugyanis ezek számukra kellemetlen szagúvá teszik a vért, így pedig kevésbé tűntök „csábító falatnak” a vérszívók számára. Igaz, mások számára is… J

Kullancskisokos: tévhitek és teendők, hogy elkerülje a bajt : http://divany.hu/eletmod/2016/05/01/kullancskisokos/

kullancsriasztó házilag

Természetes kullancsriasztó, ami tényleg működik!: http://www.kiskegyed.hu/test-es-lelek/megelozes/termeszetes-kullancsriaszto-ami-tenyleg-mukodik-135225

A citromos illat távol tartja a kullancsokat.

http://sporolok.blog.hu/2014/08/23/szunyog_es_kullancsriaszto_hazilag

Run your own auction site on your PHP – MySQL hosting service

Laravel auction software (PHP – MySQL ) on Codester:

https://www.codester.com/items/4105/php-laravel-auction-multi-vendor-auction-script?ref=smartcodecreator

Everybody loves eBay. However, not everyone likes the commissions you have to pay to sell on the site.

What if you love the idea of eBay but want to run an auction from site of your own? This could be to sell general items or it could be to sell very specific items at auction.

There are many reasons to create a website based around auction software. You don’t have to completely go down the general eBay item route, but instead have a site that runs a very specific auction.

An example that springs to mind instantly would be to create a website that allows you to run a charity auction for a selection of items on one evening. This would work in the same way as eBay but run over the space of a single evening.

Other reasons to setup your own auction website would be to avoid paying commissions on each auction item as well as having the ability to style the website in any manner you wish.

Free PHP obfuscator, Encoding PHP

PHP: Code obfuscation in 10 steps: https://www.blubgoo.com/php-code-obfuscation-in-10-steps/

PhpMinify: http://www.binpress.com/app/phpminify/632

********************
Encoding & Decoding PHP Code: https://perishablepress.com/encoding-decoding-php/

Example: https://perishablepress.com/tools/decoding/

PHP Classes: http://www.phpclasses.org/package/4926-PHP-Obfuscate-PHP-as-base64-encoded-strings.html

GitHub: PHP Obfuscator

Ncryptd, open-source: http://ncryptd.com/

PHP Obfuscator

https://github.com/naneau/php-obfuscator

This is an “obfuscator” for PSR/OOp PHP code. Different from other obfuscators, which often use a (reversible) eval() based obfuscation, this tool actually parses PHP, and obfuscates variable names, methods, etc. This means is can not be reversed by tools such as UnPHP. This library was written out of the need to obfuscate the source for a private library which for various reasons could not be shared without steps to protect the source from prying eyes. It is not technically feasible to “encrypt” PHP source code, while retaining the option to run it on a standard PHP runtime.

install: git clone https://github.com/naneau/php-obfuscator , composer install

Run: path//php-obfuscator$ ./bin/obfuscate obfuscate input output

input, output – directories in the php-obfuscator folder.

 

Design Patterns

Design Patterns
https://refactoring.guru/design-patterns/abstract-factory

PHP Design Patterns

This is a collection of known design patterns and some sample code how to implement them in PHP. Every pattern has a small list of examples (most of them from Zend Framework, Symfony2 or Doctrine2 as I’m most familiar with this software).

https://github.com/domnikl/DesignPatternsPHP

Egy nagyon hasznos, példákkal teletűzdelt összefoglaló a PHP-ban használatos (divatos) programozási mintákról .

Creational

AbstractFactory
Builder
FactoryMethod
Multiton (is considered an anti-pattern! )
Pool
Prototype
SimpleFactory
Singleton  (is considered an anti-pattern! )
StaticFactory

Structural

Adapter
Bridge
Composite
DataMapper
Decorator
DependencyInjection
Facade
FluentInterface
Proxy
Registry

Behavioral

ChainOfResponsibilities
Command
Iterator
Mediator
Memento
NullObject
Observer
Specification
State
Strategy
TemplateMethod
Visitor

More

Delegation
ServiceLocator
Repository

Balaton versek, dalok

Szeretem a Balatont

Akkordok: E A C G

Szeretem a Balatont, szeretlek nagyon, jó ide utazni.
Süt rám a nap, a víz simogat, nem illik belepisilni.

Drága itt minden, de jó lesz a lángos, meg egy vizibicikli.
Siófok alsó, Szabadifürdő, jó a vizet fröcskölni.

Akkor is jó, ha nem süt a Nap, a metorólógiát hallgatni.
Hideg van, esik az eső, valamiben reménykedni.

Szeretem a Balatont, szeretlek Balaton, jó ide utazni.
Süt rám a nap, a víz simogat, nem illik belepisilni.

 

Balaton vize

Itt vagyok a Balatonon, süt rám a Nap.
Anyukák a bikiniből majd kibuggyannak.
Fürdenek körülöttük a sok gyerekek.
Pistikém a pisit a vízbe eresszed.

Balatoni nyár, balatoni pisi.
Itt van az egész ország, sok itt a misi.
Mindenki a vízben áll,
jaj de szép ez a táj.

 

Balatoni zokni

Balatonra nem kell zokni.
Ezt könnyen meg lehet szokni.
Elég, ha kék az ég és zöld a fű,
az élet így gömbölyű.

 

Lumen – fast micro-framework by Laravel – Tutorial

Lumen is designed to build blazing fast micro-services and APIs. For example, if there is one aspect of your Laravel application that receives drastically more traffic than the rest of the application, you may choose to build that aspect of the application as a small, separate Lumen application.

http://lumen.laravel.com/docs/introduction

Developing a web application with Lumen and MySql
Lumen seems to be a very promising framework for the fast prototyping of small web apps.
http://loige.co/developing-a-web-application-with-lumen-and-mysql/