Skip to content

Instantly share code, notes, and snippets.

Niraj Shah niraj-shah

Block or report user

Report or block niraj-shah

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@niraj-shah
niraj-shah / lfd-v2.php
Last active Mar 20, 2019
LFD Reporting Script using Abuse IP DB v2 API
View lfd-v2.php
#!/usr/local/bin/php
<?php
// AbuseIPDB API v2 Key
$api_key = 'xxx';
// AbuseIPDB API v2 Endpoint
$api_endpoint = 'https://api.abuseipdb.com/api/v2/';
// AbuseIPDB User ID
View lfd.php
#!/usr/local/bin/php
<?php
// get command line arguments
$args = $argv;
// AbuseIPDB API Key
$api_key = 'xxx';
// your AbuseIPDB User ID
@niraj-shah
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
niraj-shah / PasswordProtectPDF.php
Last active Aug 15, 2018
Password Protecting PDFs using PHP
View PasswordProtectPDF.php
<?php
require "vendor/autoload.php";
use setasign\Fpdi\Fpdi;
use setasign\Fpdi\PdfReader;
use setasign\FpdiProtection\FpdiProtection;
class PasswordProtectPDF
{
protected $pdf = null;
@niraj-shah
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
niraj-shah / download_svn.sh
Last active May 10, 2018
SVN Setup on EasyApache4
View download_svn.sh
# move to home directory
cd ~/
# download svn source
wget https://archive.apache.org/dist/subversion/subversion-1.7.14.tar.bz2
# extract source
tar -xzvf subversion-1.7.14.tar.bz2
# enter extracted directory
@niraj-shah
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/mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
View apache.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
Include conf/vhosts/domain.vhost
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
@niraj-shah
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
niraj-shah / aws_sms_example.php
Last active Jan 17, 2018
Using AWS SNS to send SMS messages
View aws_sms_example.php
<?php
require 'vendor/autoload.php';
$sdk = new Aws\Sns\SnsClient([
'region' => 'eu-west-1',
'version' => 'latest',
'credentials' => ['key' => 'xxx', 'secret' => 'xxx']
]);
$result = $sdk->publish([
You can’t perform that action at this time.