Skip to content

Instantly share code, notes, and snippets.

Working from home

Niraj Shah niraj-shah

Working from home
View GitHub Profile
niraj-shah / lfd-v2.php
Last active Mar 3, 2020
LFD Reporting Script using Abuse IP DB v2 API
View lfd-v2.php
// AbuseIPDB API v2 Key
$api_key = 'xxx';
// AbuseIPDB API v2 Endpoint
$api_endpoint = '';
// AbuseIPDB User ID
View lfd.php
// get command line arguments
$args = $argv;
// AbuseIPDB API Key
$api_key = 'xxx';
// your AbuseIPDB User ID
niraj-shah / sequential.js
Created Oct 8, 2018
Sequential Ajax Calls using jQuery
View sequential.js
// parameters for ajax calls
var items = [
{ 'gender': 'male', 'nat': 'US' },
{ 'gender': 'female', 'nat': 'GB' }
// function to trigger the ajax call
var ajax_request = function(item) {
var deferred = $.Deferred();
niraj-shah / PasswordProtectPDF.php
Last active Aug 15, 2018
Password Protecting PDFs using PHP
View PasswordProtectPDF.php
require "vendor/autoload.php";
use setasign\Fpdi\Fpdi;
use setasign\Fpdi\PdfReader;
use setasign\FpdiProtection\FpdiProtection;
class PasswordProtectPDF
protected $pdf = null;
niraj-shah / htaccess
Last active Jul 19, 2018
WordPress .htaccess Restrictions
View htaccess
# .htaccess file for root WordPress directory
# add this line if it's not already present in your .htaccess file
ErrorDocument 401 default
<Files "wp-login.php">
AuthName "WordPress Admin"
AuthUserFile "/path/to/passwd"
AuthType Basic
require valid-user
niraj-shah /
Last active May 10, 2018
SVN Setup on EasyApache4
# move to home directory
cd ~/
# download svn source
# extract source
tar -xzvf subversion-1.7.14.tar.bz2
# enter extracted directory
niraj-shah / mydomain-ssl.conf
Last active Mar 21, 2018
Apache2 vhost and site config setup. `mydomain-ssl.conf` is the SSL site conf, `mydomain.conf` is the regular site conf, and `mydomain.vhost` is the vhost found in `/etc/apache2/conf/vhosts`.
View mydomain-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
Include conf/vhosts/mydomain.vhost
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
Include /etc/letsencrypt/options-ssl-apache.conf
View apache.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
Include conf/vhosts/domain.vhost
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
Include /etc/letsencrypt/options-ssl-apache.conf
niraj-shah / getIP.js
Created Mar 5, 2018
AWS Lambda IP Example
View getIP.js
// include the libraries we need
var request = require('request');
var cheerio = require('cheerio');
// set some defaults
req = request.defaults({
jar: true, // save cookies to jar
rejectUnauthorized: false,
followAllRedirects: true // allow redirections
niraj-shah / aws_sms_example.php
Last active Jan 17, 2018
Using AWS SNS to send SMS messages
View aws_sms_example.php
require 'vendor/autoload.php';
$sdk = new Aws\Sns\SnsClient([
'region' => 'eu-west-1',
'version' => 'latest',
'credentials' => ['key' => 'xxx', 'secret' => 'xxx']
$result = $sdk->publish([