Skip to content

Instantly share code, notes, and snippets.

View shubaivan's full-sized avatar
🏠
Working from home

shubaivan shubaivan

🏠
Working from home
View GitHub Profile
@shubaivan
shubaivan / TagAwareQueryResultCache.php
Last active April 16, 2020 07:44 — forked from dmaicher/TagAwareQueryResultCache.php
use symfony/cache 3.2 tag aware cache as Doctrine DBAL query result cache
<?php
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
use Symfony\Component\Cache\CacheItem;
use Symfony\Component\Cache\DoctrineProvider;
class TagAwareQueryResultCache extends DoctrineProvider
{
/**
@shubaivan
shubaivan / gist:79b3a6b13e5fd36f3b46d959e4513f01
Created April 1, 2019 13:34 — forked from aschroder/gist:2469319
Magento REST API PHP test harness (admin and customer)
<?php
/**
* Copyright Magento 2012
* Example of products list retrieve using Customer account via Magento
REST API. OAuth authorization is used
*/
$callbackUrl = "http://yourhost/oauth_customer.php";
$temporaryCredentialsRequestUrl =
"http://magentohost/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);
@shubaivan
shubaivan / cmd.sh
Created September 28, 2018 13:37 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@shubaivan
shubaivan / php-apcu-bc_on_ubuntu_16.04.md
Created June 27, 2018 14:21 — forked from philbot9/php-apcu-bc_on_ubuntu_16.04.md
Install php-acpu-bc on Ubuntu 16.04

The php-apcu-bc package provides a backwards compatibility layer from apcu -> apc, and is reuqired for some older PHP code bases (e.g. Yii 1). The package is not (yet) available in the Ubuntu 16.04 repos. To install it, use php-pear:

sudo apt-get install php-dev php-pear
sudo pecl install apcu_bc-beta

Then edit /etc/php/7.0/apache2/php.ini and add the following at the end of the file:

@shubaivan
shubaivan / 1-Explanations.md
Created March 14, 2018 11:01 — forked from danvbe/1-Explanations.md
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
public function read_file_docx($filename)
{
$striped_content = '';
$content = '';
if(!$filename || !file_exists($filename)) return false;
$zip = zip_open($filename);
if (!$zip || is_numeric($zip)) return false;