Skip to content

Instantly share code, notes, and snippets.

View tayhimself's full-sized avatar

Salim Q tayhimself

View GitHub Profile
@tayhimself
tayhimself / GulpRevVersionStrategy.php
Created October 26, 2017 22:47
VersionStrategy for using assets versioned with gulp-rev in Symfony
<?php
namespace AppBundle\Twig;
use Exception;
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
class GulpRevVersionStrategy implements VersionStrategyInterface
{
private $manifestFilename;
@tayhimself
tayhimself / symfony_session.md
Last active September 5, 2017 01:11
Symfony session request timeout detect

config.yml :

services:
    mycompany.demobundle.listener.request:
        class: MyCompany\DemoBundle\RequestListener
        arguments: [@router, @security.context]
        tags:
             - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
@tayhimself
tayhimself / RateLimitListener.php
Created August 11, 2017 13:42
Rate limits with FOSAuthServerBundle
<?php
namespace MyApp\ApiBundle\Listener;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Doctrine\ORM\EntityManager;
@tayhimself
tayhimself / Installing_wkhtmltopdf.md on CentOS
Last active June 15, 2017 22:11
Installing wkhtmltopdf
wget the appropriate file from here
https://wkhtmltopdf.org/downloads.html#stable
```bash
sudo yum install -y xorg-x11-fonts-75dpi xorg-x11-fonts-Type1
sudo yum install -y urw-fonts libXext libXrender fontconfig libfontconfig.so.1
sudo cp wkhtmltox/bin/wkhtmltopdf /usr/bin/.
sudo chmod 755 /usr/bin/wkhtmltopdf
$monologHandler = new Monolog\Logger(
'Logger',
array(
new Monolog\Handler\StreamHandler('/tmp/log.txt', Monolog\Logger::DEBUG)
)
);
$stack = GuzzleHttp\HandlerStack::create();
$stack->push(
GuzzleHttp\Middleware::log(
@tayhimself
tayhimself / ios-version.js
Created April 27, 2017 16:41 — forked from Craga89/ios-version.js
JavaScript iOS version detection
/*
* Outputs a float representing the iOS version if user is using an iOS browser i.e. iPhone, iPad
* Possible values include:
* 3 - v3.0
* 4.0 - v4.0
* 4.14 - v4.1.4
* false - Not iOS
*/
var iOS = parseFloat(
# On the local machine the command below creates a public key in .ssh/id_rsa.pub
ssh-keygen -t rsa
# Copy this to the remote server
scp .ssh/id_rsa.pub user@remote-ip:/home/tayhimself/.
# ssh in to the remote server and cd into the home dir
cat id_rsa.pub >> .ssh/authorized_keys
# OR
# do it in 1 step
@tayhimself
tayhimself / PHPYumCentOS.md
Last active June 10, 2016 20:02
Update PHP packages on CentOS with yum

Use sudo or su or whatever to switch to root

If you want to install the remi repositories for PHP for example

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm

Now in order to update use the remi as well as the default repos, first check what repos are installed, enable them and run update. Some examples below

@tayhimself
tayhimself / Node tips
Last active November 18, 2015 21:15
Delete node and npm
# Delete npm modules
npm -g ls | grep -v 'npm@' | awk '/@/ {print $2}' | awk -F@ '{print $1}' | xargs sudo npm -g rm
# First:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
#go to /usr/local/lib and delete any node and node_modules
# CentOS 6.5 APC guide from http://www.tecmint.com/install-apc-alternative-php-cache-in-rhel-centos-fedora/
# php v 5.3.3
yum install php-pear php-devel httpd-devel pcre-devel gcc make
pecl install apc
# Add the extension to apc.ini
echo "extension=apc.so" > /etc/php.d/apc.ini