Skip to content

Instantly share code, notes, and snippets.

@majuansari
majuansari / ConsumerCommand.php
Created December 19, 2020 19:12 — forked from srigi/ConsumerCommand.php
PHP rdkafka
<?php
declare(strict_types = 1);
namespace App\Kafka;
use RdKafka;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@majuansari
majuansari / intro.markdown
Created April 23, 2018 06:18 — forked from tillsanders/intro.markdown
Laravel: drag-and-drop repositioning with auto-save of DB entries

Laravel: drag-and-drop repositioning with auto-save of DB entries

Use case: Database entries are represented in a table. By grabbing and moving a row up or down the table, you can change the entries' order/position. The changes are submitted automatically via ajax.

  • Uses jQueryUI (custom download: sortable is needed)
  • newly created elements are added to the top (see route /jobs/create)
#!/bin/bash
# Setup the various file and folder permissions for Laravel
touch /var/www/html/myapp/storage/logs/laravel.log
mkdir /var/www/html/myapp/bootstrap/cache
chown -R php-fpm:php-fpm /var/www/html/myapp
find /var/www/html/myapp -type d -exec chmod 755 {} +
find /var/www/html/myapp -type f -exec chmod 644 {} +
@majuansari
majuansari / AccessTokenController.php
Created January 30, 2018 17:55
Passport token update
<?php
namespace App\Http\Controllers;
use GuzzleHttp\Exception\ClientException;
use Laravel\Passport\Http\Controllers\AccessTokenController as PassportAccessTokenController;
use League\OAuth2\Server\Exception\OAuthServerException;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response as Psr7Response;
php artisan cache:clear
php artisan view:clear
php artisan config:cache
php artisan optimize
@majuansari
majuansari / ETagMiddleware.php
Created January 9, 2018 15:47 — forked from mogetutu/ETagMiddleware.php
ETag middleware laravel 5
<?php namespace App\Http\Middleware;
use Closure;
class ETagMiddleware {
/**
* Implement Etag support
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
@majuansari
majuansari / byte-sizetuts.md
Created May 22, 2017 11:03 — forked from honkskillet/byte-sizetuts.md
A series of golang tutorials with youtube videos.
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Subscriptions - [email protected]</title>
</head>
<body>
<outline text="webdev" title="webdev">
<outline htmlUrl="https://deliciousbrains.com" title="Delicious Brains" xmlUrl="https://deliciousbrains.com/feed/" type="rss" text="Delicious Brains"/>
<outline htmlUrl="http://ferd.ca/" title="Ferd.ca" xmlUrl="http://ferd.ca/feed.rss" type="rss" text="Ferd.ca"/>
<outline htmlUrl="http://michaelbrooks.co.uk" title="Michael Brooks - RSS Feed" xmlUrl="https://michaelbrooks.co.uk/rss.xml" type="rss" text="Michael Brooks - RSS Feed"/>
@majuansari
majuansari / gist:205c6f3816034f2b5239cd0c8a2d5b80
Created March 21, 2017 14:39 — forked from jessedearing/gist:2351836
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@majuansari
majuansari / eloquent-cheatsheet.php
Created February 13, 2017 03:30 — forked from hassansin/eloquent-cheatsheet.php
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/