Skip to content

Instantly share code, notes, and snippets.

View ishansharma's full-sized avatar

Ishan Sharma ishansharma

View GitHub Profile
@ishansharma
ishansharma / wp_all_posts.php
Created June 4, 2017 17:53
Send all results for a post type with WordPress
<?php
add_action( 'rest_customer_query', 'customer_override_per_page' );
/*
* params is the query array passed to WP_Query
*/
function customer_override_per_page( $params ) {
if ( isset( $params ) AND isset( $params[ 'posts_per_page' ] ) ) {
$params[ 'posts_per_page' ] = PHP_INT_MAX;
}
@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 / 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 / hdfs-site.xml
Created February 16, 2019 21:12
hdfs-site.xml for vagrant
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@ishansharma
ishansharma / core-site.xml
Created February 16, 2019 21:09
Hadoop core-site.xml config for Vagrant
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@ishansharma
ishansharma / ssh_gen.sh
Created February 16, 2019 21:06
Generate SSH Key and Add to Authorized Keys
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat /home/vagrant/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
@ishansharma
ishansharma / hadoop_env.sh
Created February 16, 2019 21:04
Hadoop Environment Variables
echo "export JAVA_HOME=/usr" | sudo tee --append /usr/local/bin/hadoop/etc/hadoop/hadoop-env.sh
echo "export HADOOP_LOG_DIR=/hadoop_logs" | sudo tee --append /usr/local/bin/hadoop/etc/hadoop/hadoop-env.sh
echo "export HDFS_NAMENODE_USER=\"vagrant\"" | sudo tee --append /usr/local/bin/hadoop/etc/hadoop/hadoop-env.sh
echo "export HDFS_DATANODE_USER=\"vagrant\"" | sudo tee --append /usr/local/bin/hadoop/etc/hadoop/hadoop-env.sh
echo "export HDFS_SECONDARYNAMENODE_USER=\"vagrant\"" | sudo tee --append /usr/local/bin/hadoop/etc/hadoop/hadoop-env.sh
echo "export YARN_RESOURCEMANAGER_USER=\"vagrant\"" | sudo tee --append /usr/local/bin/hadoop/etc/hadoop/hadoop-env.sh
echo "export YARN_NODEMANAGER_USER=\"vagrant\"" | sudo tee --append /usr/local/bin/hadoop/etc/hadoop/hadoop-env.sh
@ishansharma
ishansharma / hadoop_exports.sh
Created February 16, 2019 21:02
Adding Hadoop Exports to .bashrs
echo "export JAVA_HOME=/usr" >> /home/vagrant/.bashrc
echo "export HADOOP_LOG_DIR=/hadoop_logs" >> /home/vagrant/.bashrc
echo "export PATH=\$PATH:/usr/local/bin/hadoop/bin:/usr/local/bin/hadoop/sbin" >> /home/vagrant/.bashrc
source ~/.bashrc
@ishansharma
ishansharma / .com.apple.iokit.graphics
Last active September 27, 2018 02:47
A sample of how /var/db/.com.apple.iokit.graphics is structured on macOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/IGPU@2/AppleIntelFramebuffer@0/display0/AppleBacklightDisplay-610-a029</key>
<dict>
<key>startup-timing</key>
<data>
AAAAAAAAAIAAcACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
AAAAIPwAEAAAAAAg/AAQAAAAACD8ABAAAAAAAAoAAKAAAAAwAAAAIAAAAEAG
@ishansharma
ishansharma / error.json
Created June 4, 2017 16:01
WP API Error when more than 100 posts are requested
{
"code": "rest_invalid_param",
"message": "Invalid parameter(s): per_page",
"data": {
"status": 400,
"params": {
"per_page": "per_page must be between 1 (inclusive) and 100 (inclusive)"
}
}
}