Skip to content

Instantly share code, notes, and snippets.

View ephrin's full-sized avatar
🎯
Focusing

Volodymyr Myrza ephrin

🎯
Focusing
  • Vinnytsia/Ukraine
View GitHub Profile
@ephrin
ephrin / traverse.js
Created January 12, 2023 09:13 — forked from sphvn/traverse.js
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
var traverse = function(o, fn) {
for (var i in o) {
fn.apply(this,[i,o[i]]);
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
}
}
}
// usage
@ephrin
ephrin / nginx.conf
Last active September 24, 2017 13:01 — forked from x86demon/fastcgi_params
nginx server config for monolitic repo
server {
listen 80;
server_name "~^(?<application>[a-zA-Z0-9_-]+)\.(?<folder>[a-zA-Z0-9_-]+)\.loc$";
root /home/eprhin/ws/oro/$folder/application/$application/web;
#index app.php access_log /var/log/nginx/$host.access_log main;
error_log /var/log/nginx/monolitic.error_log info;
try_files $uri $uri/ @rewrite;
location @rewrite {
<?php
session_start();
error_reporting(E_WARNING || E_ERROR);
//error_reporting(E_ALL);
include($_SERVER["DOCUMENT_ROOT"] . "/sturtup.inc.php");
include(LIBS_PATH . "functions.php");
$calc_region = (int)$_POST["calсRegion"];
@ephrin
ephrin / gist:3bfebb98fd581b5b4963
Created February 26, 2016 17:40 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
<?php
namespace Acme\DemoBundle\Handler;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
class XHRAuthenticationFailureHandler extends DefaultAuthenticationFailureHandler
@ephrin
ephrin / pool.md
Created December 16, 2015 20:49 — forked from krakjoe/pool.md
Pooling

Easy pthreads Pools

The final solution !!

Since the first version of pthreads, PHP has had the ability to initialize Worker threads for users. Onto those Worker threads are stacked objects of class Stackable for execution concurrently.

The objects stacked onto workers do not have their reference counts changed, pthreads forces the user to maintain the reference counts in userland, for the extremely good reason that this enables the programmer to keep control of memory usage; and so, execute indefinitely.

This is the cause of much heartache for newcomers to pthreads; if you do not maintain references properly you will, definitely, experience segmentation faults.

@ephrin
ephrin / MenuBuilder.php
Created October 8, 2015 06:58 — forked from nateevans/MenuBuilder.php
KNP Menu Bundle with Bootstrap 3 and Font Awesome 4 (see http://bit.ly/1sd1rJr , thanks to Niels Mouthaan!)
<?php
namespace Acme\HelloBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class MenuBuilder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
@ephrin
ephrin / config.yml
Last active August 29, 2015 14:22 — forked from orgjscom/config
global:
originPreset: original
presets:
original:
crop: false #default - could be omitted
quality: 90 #default - could be omitted
resize: byMax #byMax, byMin, width, height
size: [1920,1920] # 0 - width, 1 - height
z500:
crop: true,
@ephrin
ephrin / parent.php
Last active December 17, 2015 07:39 — forked from shmaltorhbooks/parent.php
!__METHOD__ => __FUNCTION__
$reflect = new \ReflectionClass(get_class($this));
return $reflect->getParentClass()->getMethod(__FUNCTION__)->invokeArgs($this, func_get_args());
@ephrin
ephrin / parent.php
Last active December 17, 2015 06:49
call parent::__METHOD__ with func_get_args
$reflect = new \ReflectionClass(get_class($this));
return $reflect->getParentClass()->getMethod(__METHOD__)->invokeArgs($this, func_get_args());