Skip to content

Instantly share code, notes, and snippets.

View madmis's full-sized avatar
🙃
Always ready for challenges

Dmytro madmis

🙃
Always ready for challenges
View GitHub Profile
@madmis
madmis / has_code.php
Created August 15, 2019 08:23
hasCode testing
<?php
function hashCode($s)
{
$h = 0;
$len = strlen($s);
for ($i = 0; $i < $len; $i++) {
$h = (int) (63 * $h + ord($s[$i])) & -1;
//$h = (int) (63 * $h + ord($s[$i])) & 0xffffffff
}
@madmis
madmis / dep_tree.php
Created January 13, 2017 08:26
Symfony services dependencies tree
#!/usr/bin/env php
<?php
set_time_limit(0);
require_once __DIR__.'/bootstrap.php.cache';
require_once __DIR__.'/AppKernel.php';
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;

Keybase proof

I hereby claim:

  • I am madmis on github.
  • I am madmis (https://keybase.io/madmis) on keybase.
  • I have a public key whose fingerprint is 835B 8773 4599 6DDF 251A DFDF 90A4 758B 0D5B 8125

To claim this, I am signing this object:

@madmis
madmis / sens.sql
Created August 11, 2016 13:18
Sensitive
DO
$do$
DECLARE
backlog RECORD;
backlogUsrId app.backlog_user.id%TYPE;
users VARCHAR[] := array['usr1','usr2'];
usr VARCHAR;
ownerRoleId app.role.id%TYPE;
BEGIN
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
@madmis
madmis / create_user.sql
Created March 4, 2016 10:04
Create user
// Show users
select * from mysql.user;
select host, user, password from mysql.user;
// Create user
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
// Grant privileges
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
GRANT LOCK TABLES, ALTER, INSERT, SELECT, UPDATE, CREATE TEMPORARY TABLES, TRIGGER, CREATE VIEW, SHOW VIEW, EXECUTE ON db_.* TO 'newuser'@'localhost';
<?php
namespace library\ExternalConfig\Provider;
use library\ExternalConfig\Entity\Size\Byte;
/**
* Class PHPProvider
* @package library\ExternalConfig\Provider
*/
@madmis
madmis / fastcgi_finish_request.php
Created September 30, 2015 11:49
PHP 7 fastcgi_finish_request - test
<?php
$requestType = $_SERVER['HTTP_X_REQUESTED_WITH'] ?? 'not ajax';
$html = <<<EOL
<html>
<!-- BEGIN HEAD -->
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
@madmis
madmis / gist:febb842bdc336943f0d3
Last active August 29, 2015 14:16
nginx location alias
location ~ ^/api/(?<module>.+)/doc/ {
autoindex on;
index index.html;
alias "/home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/$1";
error_log /var/log/nginx/hub-test-error.log debug;
}
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
@madmis
madmis / nginx.conf
Last active August 29, 2015 14:01 — forked from leon/nginx.conf
server {
listen 80;
root /home/dimon/www/avto.dev/web/;
server_name avto.dev;
set $front_part app_dev;
set $front $front_part.php;
rewrite ^/$front_part\.php/?(.*)$ /$1 permanent;