Skip to content

Instantly share code, notes, and snippets.

@sumitpore
sumitpore / .env
Last active October 26, 2019 14:14
Postcss Based Project Starter Kit. I name primary postcss file as 'main.pcss' or index.pcss. Files ending with pcss extension are converted to css file
NODE_ENV=development
@sumitpore
sumitpore / class-nonce.php
Last active July 2, 2019 16:18
PHP Nonce Class
<?php
/**
* This class does the operations related to Nonce
*
* It takes care of creating a nonce & verifying a nonce
*
* Example
*
* STEP 1 - CREATION OF NONCE:
* <code>
@sumitpore
sumitpore / readme.md
Last active June 5, 2019 03:16
Image with Caption in Github Readme
| ![Image Alt Text](https://image_url) |
|:--:|
| *Image Caption* |
@sumitpore
sumitpore / convert-zip-structure-to-associative-array.php
Last active April 14, 2022 12:44
Convert Zip Structure to Associative Array using PHP
<?php
/**
* Borrowed from https://stackoverflow.com/a/38407568/1994640
*
* Fixed fatal errors and unwanted creation of empty arrays
*/
$filePath = 'hello.zip';
$za = new ZipArchive();
if ($za->open($filePath) !== true) { // check for the zip archive
@sumitpore
sumitpore / xdebug.ini
Created May 10, 2019 10:31
xdebug Config
zend_extension=xdebug.so
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.trace_enable_trigger=1
xdebug.trace_format=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.show_mem_delta=1
xdebug.auto_trace=0
xdebug.profiler_output_dir=/tmp
@sumitpore
sumitpore / gist:73ec89098f4c5ac4f9befcaca89b7287
Created April 17, 2019 11:16
Check if Ajax Request in PHP
<?php
if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
{
# Ex. check the query and serve requested data
}
@sumitpore
sumitpore / gist:1777cbf54693091d95f1f1ee231eeb34
Created April 14, 2019 03:01
Keywords to use in code to ignore WordPress rules when it makes no sense
// @codingStandardsIgnoreLine. -> Ignore One Line
// @codingStandardsIgnoreStart. -> Start Ignoring Piece of Code
// @codingStandardsIgnoreEnd. -> End Ignoring Piece of Code. #2 & #3 are used in conjunction to ignore a block of code.
// WPCS: XSS OK. -> Suppress XSS warning. Use only when you know that the text is safe
@sumitpore
sumitpore / gist:f23c0532eb06af0cd8aea71c3beb72b6
Created March 22, 2019 03:17
Command to list all Services Running on Different Ports
netstat -tulpn
@sumitpore
sumitpore / nginx.sh
Created March 20, 2019 10:21
Nginx Start Stop Script
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@sumitpore
sumitpore / settings.json
Last active October 10, 2019 12:50
VSCode settings.json for PHP Projects. I don't give specific phpcs standards in this config instead I place `.phpcs.xml.dist` in the project directory.
{
"breadcrumbs.enabled": true,
"phpcs.enable": true,
"phpcs.showSources": true,
"phpcs.executablePath": "/usr/local/bin/phpcs",
"phpcs.autoConfigSearch": true,
"phpcs.ignorePatterns": [
"*/vendor/*",
"*/vendors/*",
],