Skip to content

Instantly share code, notes, and snippets.

View ishansharma's full-sized avatar

Ishan Sharma ishansharma

View GitHub Profile
@ishansharma
ishansharma / uri.js
Created August 24, 2014 21:02 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@ishansharma
ishansharma / phpunit.xml
Created January 3, 2017 18:40
My XML configuration file for running PHPUnit test in WordPress
<phpunit
bootstrap="./tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">
<php>
<const name="WP_DEFAULT_THEME" value="epicbeat" />
<const name="WP_ENVIRONMENT" value="LOCAL" />
@ishansharma
ishansharma / phpunit-symlink.sh
Created January 3, 2017 18:43
Commands to run to create symlink to phpunit file
@ishansharma
ishansharma / phpunit-vagrant-phpstorm-error.txt
Created January 3, 2017 18:55
You may see this error when trying to run PHPUnit tests in Vagrant using PHPStorm. Here's a fix: http://ishan.co/?p=2086
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar '/usr/local/bin', file extension (or combination) not recognised or the directory does not exist' in /home/vagrant/.phpstorm_helpers/phpunit.php:181
@ishansharma
ishansharma / debug_stage_1.php
Created January 4, 2017 09:18
Debug example
<?php
$arr =array(
'test 1' => 'successful',
'test 2' => 'failure',
'test 3' => 1,
'test 4' => false
);
@ishansharma
ishansharma / generate-cert-and-key.sh
Created January 30, 2017 10:26
Generate SSL Certificate and Key on macOS
openssl genrsa -out example.com.key 2048
openssl req -new -x509 -key example.com.key -out example.com.cert -days 3650 -subj /CN=example.com
@ishansharma
ishansharma / add-ssl.confg
Created January 30, 2017 10:33
Add SSL certificate and key to VirtualHost
#adding custom SSL cert
SSLEngine on
SSLCertificateFile /vagrant/example.com.cert
SSLCertificateKeyFile /vagrant/example.com.key
@ishansharma
ishansharma / vhost-redirect.conf
Created January 30, 2017 10:37
Redirect http traffic to https on apache2
<VirtualHost *:80>
ServerName local.example.com
DocumentRoot /vagrant
Redirect permanent / https://local.example.com/
</VirtualHost>
@ishansharma
ishansharma / functions.php
Last active April 19, 2017 08:16
Subdirectory Fix
if ( epictions_uri_slot(1) == 'v1' ) :
if ( epictions_uri_slot( 2 ) == 'validate' ) :
$api->validateApiRequest();
elseif ( epictions_uri_slot( 2 ) == 'insert_curation_post' ) :
$api->insertCurationPost();
elseif ( epictions_uri_slot( 2 ) ) :
$action = epictions_uri_slot( 2 );
if ( has_action( "epictions_client_init_request_{$action}" ) ) :
do_action( "epictions_client_init_request_{$action}" );
else :
@ishansharma
ishansharma / curation.html
Created April 28, 2017 01:18
Curation Template for Brian
<div style="max-width: 100%; overflow: hidden;">{{image}}</div>
{{title}}
{{publish_date}}
{{description}}
<p class="curated_content"><a class="cs_link" href="{{source_url}}" target="_blank" rel="nofollow noopener noreferrer">{{source_url}}</a></p>
<hr />